Skip to content

Instantly share code, notes, and snippets.

@apsun
Created October 20, 2015 00:08
Show Gist options
  • Select an option

  • Save apsun/7a0901dcfe32ee0f93b9 to your computer and use it in GitHub Desktop.

Select an option

Save apsun/7a0901dcfe32ee0f93b9 to your computer and use it in GitHub Desktop.
; In order to tack on a layer on abstraction, this script
; wraps many commonly used AHK commands as functions.
WarningMsgBox(title, message)
{
MsgBox, 48, %title%, %message%
}
InfoMsgBox(title, message)
{
MsgBox, 64, %title%, %message%
}
ErrorMsgBox(title, message)
{
MsgBox, 16, %title%, %message%
}
GetForegroundWindowHandle()
{
return WinExist("A")
}
GetHandleFromClass(className)
{
return WinExist("ahk_class " . className)
}
WaitClassActive(className)
{
WinWaitActive, ahk_class %className%
}
WaitClassNotActive(className)
{
WinWaitNotActive, ahk_class %className%
}
WaitClassExist(className)
{
WinWait, ahk_class %className%
}
WaitClassNotExist(className)
{
WinWaitClose, ahk_class %className%
}
ClassExists(className)
{
return WinExist("ahk_class " . className) != 0
}
ClassActive(className)
{
return WinActive("ahk_class " . className) != 0
}
WaitHandleActive(handle)
{
WinWaitActive, ahk_id %handle%
}
WaitHandleNotActive(handle)
{
WinWaitNotActive, ahk_id %handle%
}
WaitHandleNotExist(handle)
{
WinWaitClose, ahk_id %handle%
}
HandleExists(handle)
{
return WinExist("ahk_id " . handle) != 0
}
HandleActive(handle)
{
return WinActive("ahk_id " . handle) != 0
}
GetControlText(className, controlClassNN)
{
ControlGetText, ctrlText, %controlClassNN%, ahk_class %className%
return ctrlText
}
ClickControl(className, controlClassNN)
{
oldDelay := A_ControlDelay
SetControlDelay, -1
ControlClick, %controlClassNN%, ahk_class %className%,,,, NA
SetControlDelay, %oldDelay%
}
FocusControl(className, controlClassNN)
{
ControlFocus, %controlClassNN%, ahk_class %className%,,,, NA
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment