Created
April 21, 2018 09:48
-
-
Save OKsign/6f06d5a81090479e2319dd481d8ab88b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <root> | |
| <vkopenurldef> | |
| <name>KeyCode::VK_OPEN_URL_87</name> | |
| <url type="shell"> | |
| osascript -e ' | |
| set sName to "87" | |
| tell application "System Events" | |
| tell process "SystemUIServer" | |
| click (menu bar item 1 of menu bar 1 whose description is "AppleScript") | |
| end tell | |
| delay 0.2 | |
| tell application "System Events" | |
| keystroke sName | |
| delay 0.2 | |
| key code 36 | |
| end tell | |
| end tell | |
| ' | |
| </url> | |
| </vkopenurldef> | |
| <item> | |
| <name>My Key 87.1: Lock/Unlock Active Document_Hold L</name> | |
| <identifier>My Key 87.1: Lock/Unlock Active Document_Hold L</identifier> | |
| <not>FINDER,ITUNES,FIREFOX,SAFARI,GOOGLE_CHROME,MAIL,VLC,QUICKTIME,SYSTEM_PREFERENCES,OPERA</not> | |
| <autogen> | |
| --HoldingKeyToKey-- | |
| KeyCode::L, ModifierFlag::NONE, | |
| @begin | |
| KeyCode::L, | |
| @end | |
| @begin | |
| <!-- run via script menu --> | |
| KeyCode::VK_OPEN_URL_87, | |
| @end | |
| Option::NOREPEAT, | |
| </autogen> | |
| </item> | |
| </root> | |
| <!-- script for my key 87.1 | |
| -- user options | |
| set CloseWindow to "yes" -- "yes" or "no" | |
| -- end of user options | |
| tell application "System Events" | |
| set activeApp to (get name of first process where it is frontmost) | |
| end tell | |
| delay 0.02 | |
| tell application "System Events" | |
| tell process activeApp | |
| set docPath1 to value of attribute "AXDocument" of window 1 | |
| end tell | |
| end tell | |
| if docPath1 is not missing value then | |
| if docPath1 contains "%20" then | |
| set prevTIDs to AppleScript's text item delimiters | |
| set AppleScript's text item delimiters to the "%20" -- search | |
| set the item_list to every text item of docPath1 -- original text | |
| delay 0.04 | |
| set AppleScript's text item delimiters to the " " -- replace | |
| set docPath1 to the item_list as string | |
| set AppleScript's text item delimiters to prevTIDs | |
| end if | |
| delay 0.02 | |
| if docPath1 contains "%" then | |
| set prevTIDs to AppleScript's text item delimiters | |
| set AppleScript's text item delimiters to the "%25" -- search | |
| set the item_list to every text item of docPath1 -- original text | |
| delay 0.04 | |
| set AppleScript's text item delimiters to the "%" -- replace | |
| set docPath1 to the item_list as string | |
| set AppleScript's text item delimiters to prevTIDs | |
| end if | |
| delay 0.02 | |
| if docPath1 contains "localhost" then -- remove characters | |
| set docPath1 to ((characters 17 thru -1 of docPath1) as string) | |
| else | |
| set docPath1 to ((characters 8 thru -1 of docPath1) as string) | |
| end if | |
| end if | |
| set tar to POSIX file docPath1 | |
| tell application "Finder" | |
| select tar | |
| set tar to (get selection) | |
| delay 2 | |
| repeat with f in items of (get selection) | |
| if f is not locked then | |
| delay 0.02 | |
| set locked of f to true | |
| else | |
| delay 0.02 | |
| set locked of f to false | |
| end if | |
| end repeat | |
| delay 0.5 | |
| if CloseWindow is "yes" then | |
| close window 1 | |
| end if | |
| display notification "Done!" with title "my key 87.1" | |
| end tell | |
| --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment