Anyone know why VirtueDesktops is not recognizing the following keystroke?
tell application "VirtueDesktops"
tell application "System Events" to keystroke left using {command down, option down, shift down}
end tell
Anyone know why VirtueDesktops is not recognizing the following keystroke?
tell application "VirtueDesktops"
tell application "System Events" to keystroke left using {command down, option down, shift down}
end tell
As far as I know, “left” is a constant, part of the AppleScript component, but with no real use (it may be implemented in some text editor, as part of the Text Suite). You may try “key code 123” instead of “keystroke left”.
Yes, but VirtueDesktops will still not recognize any keystrokes. Even the following example doesn’t work.
tell application "VirtueDesktops"
tell application "System Events" to keystroke "," using {command down, option down, shift down}
end tell
I meant to post this in OS X Applescript. Can you please move it there?
Just noted one thing. Have you tried the regular syntax? (this is, bringing first the app to the foreground)
tell application "System Events"
tell process "blah"
set frontmost to true
keystroke blah...
end
end
Doesn’t work. Have you tried using VirtueDesktops?
I don’t have VirtueDesktops so I can’t offer anything beyond experiences with other software. UI scripting is tricky at times. Be sure to try include delays at key points. Sometimes UI scripts run faster than the OS or applications have time to respond. On a G5 I’ve found “delay 0.2” any time I switch dialogs or a window needs to open to be very helpful.
Try this, which is the syntax I’d have tried:
tell application "VirtueDesktops"
tell application "System Events"
tell process "VirtueDesktops"
keystroke "," using {command down, option down, shift down}
end tell
end tell
end tell
Assuming you’re trying to use a command referencable by comand-option-shift-comma…
Nope. That did not work either.
Is there anyway that you can make keystroke send a combination of keys that is set up to be a hotkey?
Just installed such app. But seems it doesn’t define shortcuts in its “menu”? If it doesn’t, I guess System Events can’t reach “system-wide” shortcuts, as it’s only able to access UI items: defined shortcuts in menu items of apps. As if it wasn’t emulating real keystrokes.
Another stronger alternative was Extra Suites (ES type key), but seems broken, at least in my OS.
for the left + modifier keys I successfully tried this (worked system wide without having the Virtue app frontmost)
tell application "System Events"
key code 123 using {command down, option down, shift down}
end tell
same probably for the other directions:
right: 124
down: 125
up: 126
I think maybe for those of us who don’t have VirtueDesktops it would help if you gave more details…
–Are you trying to select a menu option (keystroke + modifiers)? or…
–Are you trying to enter into a dialog box, text field, document window, or any of a number of other constructs?
If you are doing a menu command, the suggestions most have given should have worked, as long as it shows the keystroke shown to the right of the menu item.
If you are trying to enter a special character like, for example, the tilde’d Spanish n (option-n-n on the keyboard) into a dialog, text field, or document window, then the problem may be the cursor is not positioned correctly in the place you need to “type” in. in which case you’d need to either get to the UI location via the “textbox of document of…” kinds of constructs, or use keystrokes like tab, return, left arrow, etc. to “navigate” to the proper spot before “typing.”
Let me give you an example to illustrate the point. Here’s a handler that is called from within a TextEdit tell block that is used to search a file for a known string, navigate to a certain point after the string, select the rest of the line, omit the paragraph return, copy to clipboard, error trap, and finally copy the found data to the clipboard. TextEdit’s Find feature did not seem scriptable so I had to do the whole operation via UI scriping. This example is to show the different techniques for bopping around the interface…keyboard shortcuts for commands, keyboard shortcuts for buttons, and direct typing:
--find a phrase in TextEdit (use in TextEdit tell block)
on dataGrabber(search_string)
--find-n-replace in TextEdit isn't scriptable, so use UI scripting
tell application "System Events"
tell process "TextEdit"
-- move cursor to start of file
keystroke (ASCII character 30) using {command down}
--initiate Find
keystroke "f" using {command down}
delay small_delay --allow time for dialog to appear
keystroke search_string --enter what to find
keystroke return --start Find
delay small_delay -- wait for find to complete
keystroke "." using {command down} --close Find dialog
--use right-arrow to move over the field data
--(intentionally capture leading space for error trapping, see below)
keystroke (ASCII character 29) --undoes found selection
keystroke (ASCII character 29) --moves over one space right
--highlight data
keystroke (ASCII character 29) using {command down, shift down} --highlight to end of line
keystroke (ASCII character 28) using {shift down} --unhighlight paragraph break
--copy to clipboard
keystroke "c" using {command down}
delay small_delay --give OS a chance to catch-up
end tell
end tell
--return value
set returned_value to the clipboard
--capture empty entries (single blank space)
if returned_value is " " then
set returned_value to "<not provided>" --provide dummy value to make it obvious to user
else
--remove extranous leading space
tell application "Finder" to set returned_value to (text items 2 through (count text items of returned_value) of returned_value) as string
end if
return returned_value
end dataGrabber
Hello
I downloaded VirtueDesktops to make tests.
This script seems to work.
Set the property choix to values from 1 thru 7
property choix : 3 (* a number from 1 to 7 *)
tell application "VirtueDesktops" to tell application "System Events" to tell process "VirtueDesktops"
if choix = 1 then
keystroke (ASCII character 28) using {shift down}
else if choix = 2 then
keystroke (ASCII character 29) using {shift down}
else if choix = 3 then
keystroke (ASCII character 30) using {shift down}
else if choix = 4 then
keystroke (ASCII character 31) using {shift down}
else if choix = 5 then
keystroke tab using {option down} -- browser
else if choix = 6 then
keystroke tab using {shift down}
else if choix = 7 then
keystroke "o" using {command down, option down}
else
beep 3
end if
end tell
Yvan KOENIG (from FRANCE samedi 30 septembre 2006 12:41:42)