Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Last active April 7, 2018 16:08
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 stringsn88keys/b0bb6ba514e474a364606adbac9bd2a8 to your computer and use it in GitHub Desktop.
Save stringsn88keys/b0bb6ba514e474a364606adbac9bd2a8 to your computer and use it in GitHub Desktop.
AppleScript to track who you're chatting with and save it to a parseable file.
set myFile to open for access (choose file name) with write permission
try
repeat
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
if (frontApp = "HipChat") then
-- set things to entire contents of group 1 of group 1 of group 1 of window 1
-- set things to UI elements of group 1 of group 1 of group 1 of window 1
try
-- I think this is the PM
set myList to name of UI element of group 2 of group 1 of group 3 of UI element 1 of scroll area 1 of group 1 of group 1 of group 1 of group 1 of window "HipChat" of application process "HipChat" of application "System Events"
write (item 1 of myList) & ";" & ((current date)) & linefeed to myFile
delay 15
on error
-- Chat room?
set myList to name of UI element of group 1 of group 3 of UI element 1 of scroll area 1 of group 1 of group 1 of group 1 of group 1 of window "HipChat" of application process "HipChat" of application "System Events"
write (item 2 of myList) & ";" & ((current date)) & linefeed to myFile
delay 15
end try
end if
if (frontApp = "Teams") then
set myTitle to title of window 2 of process "Microsoft Teams" of application "System Events"
write myTitle & ";" & (current date) & linefeed to myFile
delay 15
end if
if (frontApp = "RubyMine") then
-- need to also capture the directory which is in the first element
set staticTexts to value of static text of window 1 of process "RubyMine" of application "System Events"
set gitMe to {}
repeat with theText in staticTexts
if theText begins with "Git" then
set gitMe to theText
end if
end repeat
write gitMe & ";" & (current date) & linefeed to myFile
delay 15
end if
end tell
end repeat
on error errstr number errNum
close myFile
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment