Skip to content

Instantly share code, notes, and snippets.

@pryorda
Last active December 3, 2024 22:08
Show Gist options
  • Select an option

  • Save pryorda/c68b69b95244afc3c5487a047a2efa8a to your computer and use it in GitHub Desktop.

Select an option

Save pryorda/c68b69b95244afc3c5487a047a2efa8a to your computer and use it in GitHub Desktop.

Revisions

  1. pryorda revised this gist Dec 3, 2024. 5 changed files with 0 additions and 81 deletions.
    29 changes: 0 additions & 29 deletions GetADPass
    Original file line number Diff line number Diff line change
    @@ -1,29 +0,0 @@
    on getFrontAppPath()
    set frontAppPath to (path to frontmost application) as text
    set myPath to (path to me) as text

    if frontAppPath is myPath then
    try
    tell application "Finder" to set bundleID to id of file myPath
    tell application "System Events" to set visible of (first process whose bundle identifier is bundleID) to false

    -- we need to delay because it takes time for the process to hide
    -- I noticed this when running the code as an application from the applescript menu bar item
    set inTime to current date
    repeat
    set frontAppPath to (path to frontmost application) as text
    if frontAppPath is not myPath then exit repeat
    if (current date) - inTime is greater than 1 then exit repeat
    end repeat
    end try
    end if
    return frontAppPath
    end getFrontAppPath

    tell application "Terminal"
    set frontAppPath to my getFrontAppPath()
    create window "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    delay 0.2
    tell application frontAppPath to activate
    end tell
    24 changes: 0 additions & 24 deletions GetAdPassTerminal
    Original file line number Diff line number Diff line change
    @@ -1,24 +0,0 @@
    set myScript to "/usr/local/bin/lpass show --sync=now --clip -q --password AD; exit"

    tell application "Terminal"
    activate
    do script myScript
    end tell

    set isBusy to true
    repeat until isBusy is false
    tell application "Terminal"
    tell window 1
    set isBusy to busy as boolean --> Test if busy
    end tell
    end tell
    delay 1 --> Check every second
    end repeat

    tell me to activate
    # display dialog "Terminal is No Longer Busy!"
    my displayDialog()

    on displayDialog()
    display notification "Password Copied" with title "LastPass CLI" sound name "Submarine"
    end displayDialog
    8 changes: 0 additions & 8 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    # This is "the" process to create keyboard shortcuts from applescripts on MAC OS X
    1. Open Automator
    2. Click Service if the menu opens, otherwise File -> New -> Quick Action
    3. Set "Workflow receives" to "no input"
    4. In the left panel, click utilities -> Run AppleScript -> Copy and Paste one of the applescript from one of the attached files.
    5. Click File -> Save. Take note of what you saved the service as
    6. Go to System Preferences -> Keyboard -> Shortcuts -> Services and scroll all the way to the bottom. Your service should be here and you can set the key sequence.
    7. Open some application and test if the sequence works.
    10 changes: 0 additions & 10 deletions RunIterm
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    if application "iTerm" is running then
    tell application "iTerm"
    create window with default profile
    activate
    end tell
    else
    tell application "iTerm"
    activate
    end tell
    end if
    10 changes: 0 additions & 10 deletions RunTerminal
    Original file line number Diff line number Diff line change
    @@ -1,10 +0,0 @@
    if application "Terminal" is running then
    tell application "Terminal"
    activate
    end tell
    else
    tell application "Terminal"
    do script ""
    activate
    end tell
    end if
  2. pryorda revised this gist Dec 17, 2019. 1 changed file with 19 additions and 14 deletions.
    33 changes: 19 additions & 14 deletions GetAdPassTerminal
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,24 @@
    set myScript to "/usr/local/bin/lpass show --sync=now --clip -q --password AD; exit"

    tell application "Terminal"
    activate
    delay 1
    #tell window 1
    # set selected tab to tab 1
    do shell script "/usr/local/bin/lpass show --sync=now --clip -q --password AD"

    #delay 10.0
    #tell application "System Events"
    # tell process "Terminal"
    # keystroke "w" using {command down}
    # end tell
    #end tell
    #end tell
    do script myScript
    end tell
    # display notification "All graphics have been converted." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"

    display notification "Password Copied" with title "LastPass CLI" sound name "Submarine"
    set isBusy to true
    repeat until isBusy is false
    tell application "Terminal"
    tell window 1
    set isBusy to busy as boolean --> Test if busy
    end tell
    end tell
    delay 1 --> Check every second
    end repeat

    tell me to activate
    # display dialog "Terminal is No Longer Busy!"
    my displayDialog()

    on displayDialog()
    display notification "Password Copied" with title "LastPass CLI" sound name "Submarine"
    end displayDialog
  3. pryorda revised this gist Dec 14, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions GetADPass
    Original file line number Diff line number Diff line change
    @@ -20,9 +20,9 @@ on getFrontAppPath()
    return frontAppPath
    end getFrontAppPath

    tell application "iTerm"
    tell application "Terminal"
    set frontAppPath to my getFrontAppPath()
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    create window "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    delay 0.2
    tell application frontAppPath to activate
  4. pryorda revised this gist Dec 14, 2019. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions GetAdPassTerminal
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@

    tell application "Terminal"
    activate
    delay 1
    #tell window 1
    # set selected tab to tab 1
    do shell script "/usr/local/bin/lpass show --sync=now --clip -q --password AD"

    #delay 10.0
    #tell application "System Events"
    # tell process "Terminal"
    # keystroke "w" using {command down}
    # end tell
    #end tell
    #end tell
    end tell
    # display notification "All graphics have been converted." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"

    display notification "Password Copied" with title "LastPass CLI" sound name "Submarine"
  5. pryorda revised this gist Dec 14, 2019. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions RunTerminal
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    if application "Terminal" is running then
    tell application "Terminal"
    activate
    end tell
    else
    tell application "Terminal"
    do script ""
    activate
    end tell
    end if
  6. pryorda revised this gist Jul 20, 2019. 1 changed file with 27 additions and 2 deletions.
    29 changes: 27 additions & 2 deletions GetADPass
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,29 @@
    on getFrontAppPath()
    set frontAppPath to (path to frontmost application) as text
    set myPath to (path to me) as text

    if frontAppPath is myPath then
    try
    tell application "Finder" to set bundleID to id of file myPath
    tell application "System Events" to set visible of (first process whose bundle identifier is bundleID) to false

    -- we need to delay because it takes time for the process to hide
    -- I noticed this when running the code as an application from the applescript menu bar item
    set inTime to current date
    repeat
    set frontAppPath to (path to frontmost application) as text
    if frontAppPath is not myPath then exit repeat
    if (current date) - inTime is greater than 1 then exit repeat
    end repeat
    end try
    end if
    return frontAppPath
    end getFrontAppPath

    tell application "iTerm"
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    set frontAppPath to my getFrontAppPath()
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    delay 0.2
    tell application frontAppPath to activate
    end tell
  7. pryorda revised this gist Jul 20, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # This is "the" process to create keyboard shortcuts from applescripts on MAC OS X
    1. Open Automator
    2. Click Service if the menu opens, otherwise File -> New -> Service -> Choose
    3. Set "Service Receives selected" to "no input"
    2. Click Service if the menu opens, otherwise File -> New -> Quick Action
    3. Set "Workflow receives" to "no input"
    4. In the left panel, click utilities -> Run AppleScript -> Copy and Paste one of the applescript from one of the attached files.
    5. Click File -> Save. Take note of what you saved the service as
    6. Go to System Preferences -> Keyboard -> Shortcuts -> Services and scroll all the way to the bottom. Your service should be here and you can set the key sequence.
  8. pryorda revised this gist Apr 16, 2018. 2 changed files with 9 additions and 9 deletions.
    4 changes: 2 additions & 2 deletions GetADPass
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    tell application "iTerm"
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    end tell
    14 changes: 7 additions & 7 deletions RunIterm
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    if application "iTerm" is running then
    tell application "iTerm"
    create window with default profile
    activate
    end tell
    tell application "iTerm"
    create window with default profile
    activate
    end tell
    else
    tell application "iTerm"
    activate
    end tell
    tell application "iTerm"
    activate
    end tell
    end if
  9. pryorda revised this gist Apr 16, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,3 +5,4 @@
    4. In the left panel, click utilities -> Run AppleScript -> Copy and Paste one of the applescript from one of the attached files.
    5. Click File -> Save. Take note of what you saved the service as
    6. Go to System Preferences -> Keyboard -> Shortcuts -> Services and scroll all the way to the bottom. Your service should be here and you can set the key sequence.
    7. Open some application and test if the sequence works.
  10. pryorda revised this gist Apr 16, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # This is "the" process to create keyboard shortcuts from applescripts on mac
    # This is "the" process to create keyboard shortcuts from applescripts on MAC OS X
    1. Open Automator
    2. Click Service it the menu opens, otherwise File -> New -> Service -> Choose
    2. Click Service if the menu opens, otherwise File -> New -> Service -> Choose
    3. Set "Service Receives selected" to "no input"
    4. In the left panel, click utilities -> Run AppleScript -> Copy and Paste one of the applescript from one of the attached files.
    5. Click File -> Save. Take note of what you saved the service as
  11. pryorda revised this gist Apr 16, 2018. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,7 @@
    # This is "the" process to create keyboard shortcuts from applescripts on mac
    #
    1. Open Automator
    2. Click Service it the menu opens, otherwise File -> New -> Service -> Choose
    3. Set "Service Receives selected" to "no input"
    4. In the left panel, click utilities -> Run AppleScript -> Copy and Paste one of the applescript from one of the attached files.
    5. Click File -> Save. Take note of what you saved the service as
    6. Go to System Preferences -> Keyboard -> Shortcuts -> Services and scroll all the way to the bottom. Your service should be here and you can set the key sequence.
  12. pryorda created this gist Apr 16, 2018.
    4 changes: 4 additions & 0 deletions GetADPass
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    tell application "iTerm"
    create window with default profile command "/usr/local/bin/lpass show --sync=now --clip -q --password AD"
    activate
    end tell
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # This is "the" process to create keyboard shortcuts from applescripts on mac
    #
    10 changes: 10 additions & 0 deletions RunIterm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    if application "iTerm" is running then
    tell application "iTerm"
    create window with default profile
    activate
    end tell
    else
    tell application "iTerm"
    activate
    end tell
    end if