Skip to content

Instantly share code, notes, and snippets.

@isofew
Created October 8, 2016 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isofew/f125752ea6ffd573f1361c9937277f53 to your computer and use it in GitHub Desktop.
Save isofew/f125752ea6ffd573f1361c9937277f53 to your computer and use it in GitHub Desktop.
; get/set GUI combobox/listbox in command line
Global $argc = $CmdLine[0]
If $argc < 1 Then
Usage()
EndIf
Switch $CmdLine[1] Then
Case "get"
If $argc < 3 Then
Usage()
EndIf
ConsoleWrite(Get($CmdLine[2], $CmdLine[3]))
Case "set"
If $argc < 4 Then
Usage()
EndIf
Set($CmdLine[2], $CmdLine[3], $CmdLine[4])
Case Else
Usage()
EndSwitch
Func Usage()
ConsoleWrite("Usage: windows [get|set] window control [value]")
Exit(1)
EndFunc
Func Get($window, $control)
Return ControlCommand($window, "", $control, "GetCurrentSelection")
EndFunc
Func Set($window, $control, $value)
Local $ref = ControlCommand($window, "", $control, "FindString", $value)
ControlCommand($window, "", $control, "SetCurrentSelection", $ref)
ControlClick($window, "", $control)
ControlSend($window, "", $control, "{ENTER}")
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment