-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChime Channel Chooser.scpt
68 lines (53 loc) · 2.05 KB
/
Chime Channel Chooser.scpt
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
global fzfMatch
on convertListToString(theList, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theString to theList as string
set AppleScript's text item delimiters to ""
return theString
end convertListToString
on alfred_script(q)
clickChannel(q)
end alfred_script
on clickChannel(q)
--CONFIG:Set path for dependancy cliclick (https://www.bluem.net/en/mac/cliclick/)
set cliclickpath to "/usr/local/bin/cliclick" --<--replace null with path of cliclick i.e. "/usr/local/bin/cliclick"
if cliclickpath is null then
return "ERROR: cliclickpath varriable is not set"
end if
set channelLocation to getChannel(q)
tell application "System Events"
tell application "Amazon Chime" to activate
tell application process "Amazon Chime"
-- From http://macscripter.net/viewtopic.php?pid=170532#p170532
perform action "AXRaise" of (first window whose name contains "Amazon Chime")
try
tell UI element 1 of row channelLocation of table 1 of scroll area 1 of splitter group 1 of window "Amazon Chime"
set {xPosition, yPosition} to position
set {xSize, ySize} to size
end tell
-- modify offsets if hot spot is not centered:
--click at {xPosition + (xSize div 10), yPosition + (ySize div 2)}
do shell script cliclickpath & " c:" & (xPosition + (xSize div 10)) & "," & (yPosition + (ySize div 2))
end try
end tell
end tell
return fzfMatch
end clickChannel
on getChannel(q)
tell application "System Events"
tell application process "Amazon Chime"
set allRowNames to get name of first UI element of every row of table 1 of scroll area 1 of splitter group 1 of window "Amazon Chime"
set channels to my convertListToString(allRowNames, "
")
set fzfMatch to do shell script "echo " & quoted form of channels & "| /usr/local/bin/fzf -f " & quoted form of q & "|head -1"
set iterate to 1
repeat with eachRowName in allRowNames
log iterate & eachRowName
if text of eachRowName is fzfMatch then
return iterate
end if
set iterate to iterate + 1
end repeat
end tell
end tell
end getChannel