-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalfred_bookmark.applescript
executable file
·50 lines (46 loc) · 1.67 KB
/
alfred_bookmark.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/osascript
tell application "System Events"
set ProcessList to name of every process
if "Alfred Preferences" is in ProcessList then
set ThePID to unix id of process "Alfred Preferences"
do shell script "kill -KILL " & ThePID
end if
end tell
tell application "System Events" to quit
set delay_time to 0.3
tell application "Google Chrome"
set theURL to URL of active tab of window 1
end tell
tell application "Alfred 3" to activate
tell application "System Events"
keystroke "," using command down
delay delay_time
tell process "Alfred Preferences"
delay delay_time
-- hack: to ensure that the the "Default results" button isn't selected
-- by default, we select another tab first, then select the "features" tab
click button "Appearance" of toolbar 1 of window 1
click button "Features" of toolbar 1 of window 1
delay delay_time
UI elements of scroll area 1 of window 1
-- bring the left menu to focus first (see hack above, without hack this would work sometimes only)
keystroke tab
delay delay_time
-- hit the down button twice
key code 125
key code 125
end tell
try
tell process "Alfred Preferences"
delay delay_time
click button "Add Custom Search" of tab group 1 of window 1
delay delay_time
-- UI elements of sheet of window 1
set value of text field 2 of sheet 1 of window 1 to theURL
end tell
-- hit tab
tell application "System Events" to key code 48
on error errMsg
display dialog "Error: " & errMsg
end try
end tell