Created
May 27, 2016 16:39
-
-
Save mickdekkers/bc40d01ca80c69488019b7f019368b26 to your computer and use it in GitHub Desktop.
Change your Skype status programmatically
This file contains 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
#NoEnv | |
#NoTrayIcon | |
#SingleInstance ignore | |
; The path to Skype's executable | |
skypePath := "C:\Program Files (x86)\Skype\Phone\Skype.exe" | |
; Used to identify Skype's main window | |
skypeWin := "ahk_exe Skype.exe ahk_class tSkMainForm" | |
; The X coordinate of all the status buttons | |
statusXCoord := 56 | |
; The Y coordinate of the "Change your status" button | |
changeStatusYCoord := 110 | |
; The Y coordinates of the statuses | |
statusYCoords := {Online: 130, Away: 155, DoNotDisturb: 175, Invisible: 195, Offline: 220} | |
; Require exactly one command line argument | |
; "The left side of a non-expression if-statement is always the name of a variable." -- https://autohotkey.com/docs/Scripts.htm#cmd | |
if 0 != 1 | |
{ | |
; Exit the script with code 1 (error) | |
ExitApp, 1 | |
} | |
; The first (and only) command line argument is the requested status | |
Loop, %0% | |
{ | |
requestedStatus := %A_Index% | |
break | |
} | |
; Check if the requested status is valid | |
requestedStatusOk := false | |
for status in statusYCoords { | |
if (requestedStatus = status) { | |
requestedStatusOk := true | |
break | |
} | |
} | |
if (!requestedStatusOk) { | |
; Exit the script with code 1 (error) | |
ExitApp, 1 | |
} | |
; Open Skype's main window | |
Run, %skypePath% | |
WinWaitActive, %skypeWin%,, 10 | |
if ErrorLevel { | |
; Exit the script with code 1 (error) | |
ExitApp, 1 | |
} else { | |
; Save the mouse cursor's current position | |
CoordMode, Mouse, Screen | |
MouseGetPos, X, Y | |
CoordMode, Mouse, Window | |
; Click "Change your status" | |
Click %statusXCoord%, %changeStatusYCoord% | |
Sleep, 10 | |
; Click the new Status | |
statusYCoord := statusYCoords[requestedStatus] | |
Click %statusXCoord%, %statusYCoord% | |
Sleep, 10 | |
; Press Esc to close the context menu in case the Status is unchanged | |
Send {Esc} | |
Sleep, 10 | |
; Minimize the Skype window | |
WinMinimize, %skypeWin% | |
; Move the mouse cursor back to its starting position | |
CoordMode, Mouse, Screen | |
Click, %X%, %Y%, 0 | |
; Exit the script | |
ExitApp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment