tell application "Copernicus"
activate
delay 2
tell application "System Events" to tell process "Copernicus"
keystroke (ASCII character 61) using {control down}
delay 5
end tell
end tell
Forgive the question, but I don’t have Copernicus. It’s quite rare (but not unheard of) for the Control key to be the sole modifier in a keyboard shortcut. Are you sure it’s not the Command key that’s meant?
Nigel you are right, however I have set it up this way (you can do in control panel of the app.). and I have tried other combinations to no avail. thanks for thinking with me however, I remain puzzled as to why it does not work…
(only if you have still got your “Previous Systems” folder on your machine.)
KeyboardViewerServer*** appears to be the previous Leopard implementation of the current Snow Leopard app KeyboardViewer - /System/Library/InputMethods/KeyboardViewer (I can’t get KeyboardViewer to do anything)
(i.e. KeyboardViewerServer appears to have been replaced in Snow Leopard)
So if you don’t have the “Previous Systems” folder on your machine please disregard this post.
Otherwise try this. It should allow you to get a dialog to display if you press just the ctrl key.
Save this script as a stay open application and run it. Then press the ctrl key and see if the dialog comes up.
The Symbol is Technical Symbol Up arrowhead.
on run
try
tell application "System Events"
if not ((some process whose name contains "KeyboardViewerServer") exists) then
tell application "KeyboardViewerServer" to activate
end if
end tell
on error
tell application "KeyboardViewerServer" to activate
end try
end run
on idle
tell application "System Events"
if ((get value of checkbox "⌃" of first window of application process "KeyboardViewerServer") as number) = 1 then
activate me
tell application "TextEdit" --------- replace with whatever
activate
display dialog "Is this weird or what ?" with title "Would this help?"
tell me to quit
end tell
end if
end tell
return 0.05
end idle
This qualifies as a wild guess !
Val
*** The Path to KeyboardViewerServe is
Your HD
Previous Systems
System
Library
Components
KeyboardViewer.component ------- (you have to open package)
Contents
SharedSupport
KeyboardViewerServer.app
if you only want the dialog to come up when ctrl = (both) are pressed
use
if ((get value of checkbox "⌃" of first window of application process "KeyboardViewerServer") as number) = 1 and ((get value of checkbox "=" of first window of application process "KeyboardViewerServer") as number) = 1 then
I’ve just downloaded Copernicus for a quick look. I set Control-= as the preference for “Show Main Window” and can confirm that, while it works manually, it doesn’t do anything when scripted.
I suspect (but don’t know) that it’s because it’s linked into some background system that can invoke hidden applications, whereas the System Events commands are for delivering keystroke information to the GUI of the frontmost process.
If, by any chance, it’s Copernicus’s main Tool Window you’re trying to get, there’s a GUI shortcut for it shown in the “Window” menu: Command-1.
tell application "Copernicus" to activate
tell application "System Events" to keystroke "1" using command down
Thanks Delpucci, as I wrote before, I do not understand how checkModifierKeys would help me? I also do not have a old system on my Mac. in 10.6, if I am not mistaken, it is replaced with the application keyboardSee, this too would not help me or?
Nigel thanks, I did see this as I tried to script the Tool Window, as it would be a workaround. however no luck there either, unless you are able to do so I can not see it to be of any help.
tell application "Copernicus"
activate
repeat 3 times
tell application "System Events" to tell process "Copernicus"
key code 24 using {control down}
end tell
end repeat
end tell
when I execute the command via the keyboard it indeed takes several seconds before the save box comes up (I set it to do that). however via the script nothing happens. are you saying it works, with a time laps, for you using the script?
Not sure as to what is not working with the other scripts in the background, but this does it.
tell application "Copernicus"
activate
delay 3
tell application "System Events"
key down control
key down "1"
delay 2
key up control
key up "1"
end tell
end tell
Of course I set the command in Copernicus preferences to ‘Control 1 (1 on the numerical pad!)’. Using the same code with ‘Control =’ or ‘Control I’ etc did not work. this does. strange.