Forum Discussion

Former Member's avatar
Former Member
4 years ago

Is there a way to copy a username from inside an AppleScript?

I used to be able to open 1Password Mini in Version 7 and send keystrokes via AppleScript to copy the user name.

However, with Version 8, I am unable to do it. When I send the Cmd + C, it either doesn't copy anything, or it copies "nothing" from another app.

Below is the code I am using, where TheLoginItem contains the username I would like to copy:

tell application "System Events"
set appRef to application process "1Password"
set appName to short name of appRef

set the clipboard to ""

-- Get username
-- Open 1Password Quick Access
keystroke space using {shift down, command down}
delay 0.1
key code 51 -- delete what's already there
delay 0.1
keystroke "TheLoginItem"
delay 0.1

-- copy username
keystroke "c" using command down
delay 0.1
set username to the clipboard
log (username)

end tell


1Password Version: 8.7.0
Extension Version: Not Provided
OS Version: 12.3.1

1 Reply

  • XIII's avatar
    XIII
    Super Contributor

    Maybe because 1Password 8 is now an Electron App?

    Can one use AppleScript in Electron Apps?