Reputation: 25
I'm very new to Applescript and I was looking to create an application that automatically switches between the desktops or spaces (as Apple calls them). Here is the code I have so far:
tell application "System Events"
key code 39 using {control down}
end tell
If I replace the "key code 39 using {control down}" section with keystroke "n" or any other key letter, it appears to work, but with my current code nothing occurs. Why would it not be executing?
Upvotes: 1
Views: 1650
Reputation: 3466
Code 39 is not the arrow you want for space changes. I found a list of numbers in another answer and key code 124 was the equivalent of using the right arrow to switch to the next space in my setup. I plugged that number into your code:
tell application "System Events"
key code 124 using {control down}
end tell
And this successfully switched to my next space.
Note that with your code, something did happen when running it inside of Script Editor: an apostrophe was added to the end of the code.
Upvotes: 2