Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.3: Restore the Key Caps application via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Restore the Key Caps application via AppleScript
Authored by: dennisbest on Jan 06, '05 12:28:17PM

Here's what worked for me without having to leave a script open. I just close the window when I'm done with the keyboard viewer - I don't really care if it's still running and taking no resources. This puppy checks to see if it is open and visible... if not, it tries to quit and reopen it. And then it just tries it all over again just in case. (For some reason repeat routines weren't working... and the quit errors only seemed to occur once... so I just gave up elegance for functionality.) It won't win an award for coding but it has worked for me 100% of the time. This script does not need to stay open. Just place it in your scripts menu or wherever you like.

try
tell application "System Events"
if exists process "KeyboardViewerServer" then
set windList to every window of application process "KeyboardViewerServer"
if (count of windList) is 0 then
tell application "KeyboardViewerServer"
quit
end tell
end if
else
tell application "Finder"
open item "System:Library:Components:KeyboardViewer.component:Contents:SharedSupport:KeyboardViewerServer.app" of the startup disk
end tell
end if
end tell
on error
tell application "System Events"
if exists process "KeyboardViewerServer" then
set windList to every window of application process "KeyboardViewerServer"
if (count of windList) is 0 then
tell application "KeyboardViewerServer"
quit
end tell
end if
else
tell application "Finder"
open item "System:Library:Components:KeyboardViewer.component:Contents:SharedSupport:KeyboardViewerServer.app" of the startup disk
end tell
end if
end tell
end try



[ Reply to This | # ]