Unable to initiate a handler in Google Chrome using AppleScript

53 views Asked by At

I am trying to use AppleScript Key Code to navigate around in Google Chrome. However, if I pack those repetitive codes into a handler, the handler is unable to process the information. The Script Error shows as following: System Events got an error: Can’t continue Copy_Trello.

set a to {}
set b to {}
set c to {}
set d to {}
set e to {}


on Copy_Trello(Incident, Marketplace, Core_server, Network, Others)
    tell application "System Events"
        key code 124
        delay 0.1
        key code 36
        delay 0.1
        key code 14
        delay 0.1
        key code 8 using command down
        delay 0.2
        copy (the clipboard) to the end of Incident
        delay 0.2
        key code 53
        delay 0.1
        key code 53
        delay 0.1
        key code 125
        delay 0.1
        key code 36
        delay 0.1
        key code 14
        delay 0.1
        key code 8 using command down
        delay 0.1
        copy (the clipboard) to the end of Marketplace
        delay 0.2
        key code 53
        delay 0.2
        key code 53
        delay 0.1
        key code 125
        delay 0.1
        key code 36
        delay 0.1
        key code 14
        delay 0.1
        key code 8 using command down
        delay 0.2
        copy (the clipboard) to the end of Core_server
        delay 0.2
        key code 53
        delay 0.1
        key code 53
        delay 0.1
        key code 125
        delay 0.1
        key code 36
        delay 0.1
        key code 14
        delay 0.1
        key code 8 using command down
        delay 0.2
        copy (the clipboard) to the end of Network
        delay 0.2
        key code 53
        delay 0.1
        key code 53
        delay 0.1
        key code 125
        delay 0.1
        key code 36
        delay 0.1
        key code 14
        delay 0.1
        key code 8 using command down
        delay 0.2
        copy (the clipboard) to the end of Others
        delay 0.2
        key code 53
        delay 0.1
        key code 53
        delay 0.1
    end tell
end Copy_Trello

on up_()
    tell application "System Events"
        repeat 4 times
            key code 126
            delay 0.05
        end repeat
    end tell
end up_

tell application "Google Chrome"
    open location "https://trello.com/"
    delay 4
    tell application "System Events"
        key code 125
        delay 0.3
        repeat 7 times
            Copy_Trello(a, b, c, d, e)
            delay 0.05
            up_()
            key code 124
            delay 0.05
        end repeat
    end tell
end tell

display dialog a & b & c & d & e

Any ideas about this? Thank you in advance.

0

There are 0 answers