Skip to content

Instantly share code, notes, and snippets.

@diogotito
Last active April 28, 2019 17:22
Show Gist options
  • Save diogotito/192e952b1d2c5aa12ee886507b4f8c76 to your computer and use it in GitHub Desktop.
Save diogotito/192e952b1d2c5aa12ee886507b4f8c76 to your computer and use it in GitHub Desktop.
An AutoHotKey script to bind F8 to a click in the "Stop Thymio" button in Aseba Studio.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#If WinActive("ahk_exe " "asebastudio.exe")
F8::
WinGetPos, WinX, WinY, WinW, WinH
MouseGetPos, x, y
; ImageSearch, FoundX, FoundY, %WinX%, %WinY%, WinX+WinW, WinY+WinH, StopThymioTe.png
; ImageSearch, FoundX, FoundY, 0, 800, 600, 1000, StopThymioText.png
ImageSearch, FoundX, FoundY, %WinX%, %WinY%+600, WinX+600, WinY+WinH, *TransBlack StopThymioBlack.png
if (ErrorLevel = 2) {
MsgBox "Could not conduct the search"
}
if (ErrorLevel = 1) {
; MsgBox "Icon could not be found on the screen"
ImageSearch, PaneX, PaneY, %WinX%, WinY, WinX+100, WinY+WinH, StopThymioOpenedPane.png
PaneX += 50
; MsgBox "Opened pane detected at %PaneX%x%PaneY%"
ImageSearch, ToolsX, ToolsY, %WinX%, WinY+WinH-100, WinX+100, WinY+WinH, StopThymioLocalTools.png
; MsgBox "Local Tools detected at %ToolsX%x%ToolsY%"
MouseClick, Left, ToolsX, ToolsY
Sleep, 50
ImageSearch, FoundX, FoundY, %WinX%, %WinY%, WinX+WinW, WinY+WinH, *TransBlack StopThymioBlack.png
MouseClick, Left, FoundX, FoundY,
Sleep, 50
MouseClick, Left, PaneX, PaneY
Sleep, 50
} else {
MouseGetPos, x, y
MouseClick, Left, FoundX, FoundY,
Sleep, 50
}
MouseMove, %x%, %y%
#if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment