Script auto correction incorrect when compiling and pressing up key does not work

OK. I currently have a lot of problems with my applescript editor. currently, when I do Key up key down, it will always indicate the letter A. For example.

Report to System Events

key down "u"

key up "u"

    delay 1

end tell

it will be a key press of A, and I do not know why.

^ This is just a minor issue, although my biggest problem is that I want to swap places between three different video game applications. They are all duplicates of the same game. This is how my main script goes.

tell the Video Game program to activate

tell application "System Events"
keystroke a bunch of stuff
end tell

tell the copy of the video game to activate

tell application "System Events"
keystroke a bunch of stuff
end tell

tell Video Game 2 to activate

tell application "System Events"
keystroke a bunch of stuff
end tell

, script, "".

, ?

, , applescript , . .

:)

0
3

, , ​​applescript. . jxa (javascript ui), applescript, :

ObjC.import("Cocoa");

function key(aiKeyCode, aiDelay)
{
    var source = $.CGEventSourceCreate($.kCGEventSourceStateCombinedSessionState),
    keyDown = $.CGEventCreateKeyboardEvent(source, aiKeyCode, true),
    keyUp = $.CGEventCreateKeyboardEvent(source, aiKeyCode, false);
    $.CGEventPost($.kCGAnnotatedSessionEventTap, keyDown);
    delay(aiDelay);
    $.CGEventPost($.kCGAnnotatedSessionEventTap, keyUp);
}
+1

keystroke . App, System Events, - , ..

tell application "System Events" to tell process "App Name" to keystroke "u"

, , .., :

tell application "System Events" to tell process "App Name" to keystroke "u" using {command down, shift down, option down}
0

What the AppleScript editor does is not "auto-correct" - its "compilation". It does not do it wrong. You can change the name of the application on Mac and it will not break the application. The AppleScript editor can still find the Video Game application, even if you change its name to Video 1. This is a function, not an error.

0
source

All Articles