New topic: 

Help please: "virtual keyboard in Snow Leopard"

<http://forums.realsoftware.com/viewtopic.php?t=32201>

       Page 1 of 1
   [ 9 posts ]                 Previous topic | Next topic         Author  
Message       lenpartico           Post subject: Help please: "virtual keyboard 
in Snow Leopard"Posted: Tue Jan 26, 2010 8:43 pm                        
Joined: Fri Sep 30, 2005 10:49 pm
Posts: 197              Hello,

"virtual keyboard in Snow Leopard"

There is a checkbox in System Preferences/Keyboard named "Show keyboard & 
Character Viewer in menu bar".

How can I code for that in a pushbutton in my RB app?

Thanks. 

Lennox   
                            Top               pony           Post subject: Re: 
Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 2010 8:55 pm 
                              
Joined: Sat Nov 11, 2006 2:43 pm
Posts: 475
Location: DFW area, Texas, USA              viewtopic.php?f=7&t=32155     
_________________
Fly like a mouse, run like a cushion, be the small bookcase.
http://www.wish-sandwich.com  
                            Top               lenpartico           Post 
subject: Re: Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 
2010 8:59 pm                        
Joined: Fri Sep 30, 2005 10:49 pm
Posts: 197              Thanks Pony,
I actually had an input there. My post is not to display the keyboard, it is to 
the "Show keyboard & Character Viewer in menu bar".
Any suggestions, there is an applescript for Tiger but it does not work in 
Leopard.
Lennox.   
                            Top               pony           Post subject: Re: 
Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 2010 10:01 
pm                               
Joined: Sat Nov 11, 2006 2:43 pm
Posts: 475
Location: DFW area, Texas, USA              This quick and dirty AppleScript I 
pieced together will toggle it on and off:
Code:tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell


tell application "System Events"
-- The user must have UI Elements enabled
tell application process "System Preferences"
click checkbox "Show Keyboard & Character Viewer in menu bar" of tab group 1 of 
window "Keyboard"
end tell
end tell

tell application "System Preferences"
quit
end tell
     
_________________
Fly like a mouse, run like a cushion, be the small bookcase.
http://www.wish-sandwich.com  
                            Top               lenpartico           Post 
subject: Re: Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 
2010 10:15 pm                        
Joined: Fri Sep 30, 2005 10:49 pm
Posts: 197              Thanks Pony,
Just what I wanted.
Thanks again.
Lennox.   
                            Top               pony           Post subject: Re: 
Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 2010 10:18 
pm                               
Joined: Sat Nov 11, 2006 2:43 pm
Posts: 475
Location: DFW area, Texas, USA              BTW-
If you only want to turn it on (ie not toggle it) then you can modify the 
script to check and see whether the box is already checked. This turns it on if 
its off, and leaves it on if its already on:
Code:tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell


tell application "System Events"
tell application process "System Preferences"
if value of checkbox "Show Keyboard & Character Viewer in menu bar" of tab 
group 1 of window "Keyboard" is not 1 then
  click checkbox "Show Keyboard & Character Viewer in menu bar" of tab group 1 
of window "Keyboard"
end if
end tell
end tell

tell application "System Preferences"
quit
end tell

     
_________________
Fly like a mouse, run like a cushion, be the small bookcase.
http://www.wish-sandwich.com  
                            Top               lenpartico           Post 
subject: Re: Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 
2010 10:30 pm                        
Joined: Fri Sep 30, 2005 10:49 pm
Posts: 197              Thanks again,
But could this all be done without the preference pane being visible?
Lennox.   
                            Top               pony           Post subject: Re: 
Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 2010 10:55 
pm                               
Joined: Sat Nov 11, 2006 2:43 pm
Posts: 475
Location: DFW area, Texas, USA              something like this
Code:tell application "System Preferences"
ignoring application responses
tell application "System Events" to launch "System Preferences"
tell application "System Events" to tell process "System Preferences" to set 
visible to false
set current pane to pane "com.apple.preference.keyboard"
end ignoring
end tell


tell application "System Events"
tell application process "System Preferences"
try
if value of checkbox "Show Keyboard & Character Viewer in menu bar" of tab 
group 1 of window "Keyboard" is not 1 then
  click checkbox "Show Keyboard & Character Viewer in menu bar" of tab group 1 
of window "Keyboard"
end if
end try
end tell
end tell

tell application "System Preferences"
quit
end tell




Obviously you can tidy up the code, and add error handling. Its laid out in  
basic form so you can actually see what is going on. All of this can be nested 
etc.     
_________________
Fly like a mouse, run like a cushion, be the small bookcase.
http://www.wish-sandwich.com  
                            Top               lenpartico           Post 
subject: Re: Help please: "virtual keyboard in Snow Leopard"Posted: Tue Jan 26, 
2010 11:19 pm                        
Joined: Fri Sep 30, 2005 10:49 pm
Posts: 197              Hi pony,

Thanks, but that is not doing anything visible... 

this works every other time...
I get this error 
error "System Events got an error: Can’t get window \"Keyboard\" of 
application process \"System Preferences\"." number -1728 from window 
"Keyboard" of application process "System Preferences"

Code:

tell application "System Preferences"
 
 ignoring application responses
  tell application "System Events" to launch "System Preferences"
  tell application "System Events" to tell process "System Preferences" to set 
visible to false
  set current pane to pane "com.apple.preference.keyboard"
 end ignoring
end tell


tell application "System Events"
 
 tell application process "System Preferences"
  click checkbox "Show Keyboard & Character Viewer in menu bar" of tab group 1 
of window "Keyboard" 
 end tell

end tell

tell application "System Preferences"
 quit
end tell

End Code:


What could I do to make it work everytime?

Thanks.

Lennox.   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 9 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to