Get text from a list box; use AutoHotKey to grab items from programs

Get text from a list boxSometimes I’d like to be able to, progromatically, extract values listed inside a program.  Unfortunately many programs I use do not allow the ability to get text from a list box.

One of AHKs great strengths is how well it “hooks” into Windows.  I wrote an AutoHotKey script which allows me to copy and paste a list of items selected in the window.  There are lots of options like retrieve all items, only those selected, obtain the count of either previously mentioned.  Once you have all the items you can send instructions back to the list box and specify which one you want selected (thus if you frequently go back and select the same items, it can automate the process.

 
loop {
  ControlGet, Sel_CT, List, Count Selected, SysListView321, A ;Gets count of items selected from last active window
  ToolTip % Sel_CT
sleep, 300
}
Browser_Forward::Reload

#IfWinActive ahk_class #32770 ;Only run below if in Specific window type
Browser_Back::
ControlGet, Selected_Items,List,Selected      ,SysListView321, A ;gets Selected Items in last active window
ControlGet, Selected_CT   ,List,Selected Count,SysListView321, A ;gets count of selected items in last active window

ControlGet, All_Items,List,      ,SysListView321, A ;gets list of all items in last active window
ControlGet, All_CT   ,List, Count,SysListView321, A ;gets count of all items in last active window

Clipboard:=Selected_Items
MsgBox % "Number of Items selected: " Selected_CT "`r`r" Selected_Items
MsgBox % "Number of Items selected: " All_CT "`r`r" All_Items
return
#IfWinActive

Get text from a list box

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.