Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created April 8, 2018 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/fb61747defd41692aeeb7c838d204cca to your computer and use it in GitHub Desktop.
Save OKsign/fb61747defd41692aeeb7c838d204cca to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_82.2</name>
<url type="shell">
osascript -e '
-- user input
set T1 to {"ocr", "hhh","ap"}
set T2 to {"optical...", "hello","applescript"}
-- end of user input
set MaxLen to 0
repeat with x in T1
set Lenx to (length of x) as integer
if Lenx > MaxLen then
set MaxLen to Lenx
end if
end repeat
repeat MaxLen times
tell application "System Events"
key code 123 using shift down
delay 0.02
end tell
end repeat
tell application "System Events"
keystroke "c" using command down
delay 0.5
set CopT to (the clipboard as text)
delay 0.03
repeat with x in T1
delay 0.04
if CopT ends with x then
set F1 to x
set LenF1 to length of F1
repeat with N from 1 to (count T1)
delay 0.03
if (item N of T1) is (F1 as text) then
set rWith to (item N of T2)
end if
end repeat
set the clipboard to rWith
delay 0.03
tell application "System Events"
key code 124
delay 0.03
repeat LenF1 times
key code 51
delay 0.02
end repeat
delay 0.03
keystroke "v" using command down
delay 0.03
key code 49
end tell
exit repeat
end if
end repeat
if CopT does not end with x then
tell application "System Events"
key code 124
end tell
end if
end tell
'
</url>
</vkopenurldef>
<item>
<name>My Key 82.2: Use Autocorrect in ATOM</name>
<item>
<name>Press SEMICOLON (;)</name>
<identifier>My Key 82.2: Use Autocorrect in ATOM_Press SEMICOLON (;)</identifier>
<only>Atom</only>
<autogen>
--KeyToKey--
KeyCode::SEMICOLON, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_82.2,
</autogen>
</item>
<item>
<name>Hold SEMICOLON (;)</name>
<identifier>My Key 82.2: Use Autocorrect in ATOM_Hold SEMICOLON (;)</identifier>
<only>Atom</only>
<autogen>
--HoldingKeyToKey--
KeyCode::SEMICOLON, ModifierFlag::NONE,
@begin
KeyCode::SEMICOLON,
@end
@begin
KeyCode::VK_OPEN_URL_82.2,
@end
Option::NOREPEAT,
</autogen>
</item>
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment