9 posts in this topic
I know there are listbox and listview, but now I have?
here is the video of infowindow
I tried to read mouse selection like for listbox:
$listWindow = "[CLASS:TFormResearchGR]" $topicsList = "[CLASS:TMWrapper; INSTANCE:255]" WinWait($listWindow, "", 60) $hdlWindow = WinGetHandle($listWindow) $hdlList = ControlGetHandle($hdlWindow, "", $topicsList) _GUICtrlListBox_ClickItem($hdlList, 0, "left") $countOfList = _GUICtrlListBox_GetCount($hdlList) ConsoleWrite("Count of list: " & $countOfList & @LF) count of list is not working.
I realiezed that there are difference between listbox and listview, but this is something different.
and till now I never saw that you can go inside with infotool and also get instances.
so Im confused how to get the list number and the names of selection?
Best example I could find is here
The way I understand this, the standard Windows messages, such as Left/Right Click etc are covered by AutoIt macros, but the real power is locked up inside this WM_NOTIFY . I have tried, but I am not even sure I understand what I am looking at.
I need help understanding this. What I am looking for is Help file or Tutorial explaining how this works?
Perhaps if there is a script showing both the working of an AutoIt macro and the WM_NOTIFY in action, it would help.
Right now I am so lost, I do not even know what are the right questions to ask. One issue I have is on ListViews, how to combine the "Click" of a line with a standard Switch loop? Like users clicks a line, then get the loop to detect the click and ;do something ...
This is not a working example -- I'm asking about the principle...
Here we have the often seen code to detect a double-click on an item in one ListBox (ID in $idListBox is of course created by other code).
To catch that ListBox item, I have only added $sBookmark to it. This could be a pick list application.
$idListBox = 0x004A0FB0 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _ $sBookmark If Not IsHWnd($idListBox) Then $hWndListBox = GUICtrlGetHandle($idListBox) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $idListBox, $hWndListBox $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) ) Switch $iCode Case $LBN_DBLCLK ConsoleWrite("you double-clicked " & $sBookmark & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
Now, my question is: can one modify the _WM_COMMAND function to allow for a dynamic number of ListBoxes? (meaning, user-defined -- the amount of ListBoxes/pick lists can change at any time).
Let's assume I dynamically obtained an array with ListBox ID's for (in this case) 5 pick lists:
One part of the solution seems to work with the For... Next loop I added below, but I'm wondering if that is the ultimate? (knowing this Func has to be as fast as possible)
The part where I can't find anything that works for a dynamic amount of ListBox ID's is in the Case check...
I tried _ArrayToTxt($aIdListBox, ", ", 1), messed with Eval(), and trying Case $aIdListBox[start] To $aIdListBox[end]
Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _ $sBookmark For $i = 1 To UBound($aIdListBox) - 1 ; is this solution fast enough? (it seems to work well) If Not IsHWnd($aIdListBox[$i]) Then $hWndListBox = GUICtrlGetHandle($aIdListBox[$i]) ExitLoop ; cause there can only be one hit(?) EndIf Next $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case [WHAT TO PUT HERE if nr of ListBoxes is dynamic?], $hWndListBox ; <= MAIN question $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) ) Switch $iCode Case $LBN_DBLCLK ConsoleWrite("you double-clicked " & $sBookmark & @CRLF) EndSwitch Return $GUI_RUNDEFMSG EndFunc - - -
As a workaround, I can probably add the maximum number of allowed ListBoxes to the Case check, seperated by commas, but only display the number of ListBoxes needed. But I'm hoping it can be made truly dynamical...?
Thank You : )
I got a problem, hope someone can help me, many thanks.
I'm trying to read items from a listbox1($ListChoCom) to an array, and load this array to another listbox2($ListSuitCmd) which is on the different tab. But, now, I cannot select items on the listbox2. I only can select from listbox1. Here is the code and the screenshots.
Func btnNext2() Dim $SelCmdArray For $i = 0 To _GUICtrlListBox_GetCount($ListChoCom) - 1 $SelCmdArray[$i] = _GUICtrlListBox_GetText($ListChoCom, $i) ReDim $SelCmdArray[UBound($SelCmdArray) + 1] GUICtrlSetData($ListSuitCmd, $SelCmdArray[$i]) Next _GUICtrlTab_ClickTab($Tab1, 2) EndFunc Screenshot 1: I can select item from this listbox1.
screenshot2: I cannot select item from listbox2, The item that been highlight is what I select from listbox1.
Thank you very much indeed.
I know this is a crazy idea. But i think it might be a help for somebody. The name of this program is GRM Helper. i.e. GUIRegisterMsg Helper.
This program helps you to write the guiregistermsg function code automatically. You can choose a control from the combo box. Then all events of that control will be displayed in a list view. You can click on an event for it;s details. Then you can check the events which you want to include in your code. Then type some details like; 1) Your control's handle. 2) Line number for inserting GUIRegisterMsg code. 3) Line number for inserting main function.
And press the "Isert To SciTE" button. Your code is ready in scite.
Here is the program.
Updated Version 1.1
GRM Helper V1.1.zip
The code written by this program.
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox If Not IsHWnd($Sample) Then $hWndListBox = GUICtrlGetHandle($Sample) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $Sample, $hWndListBox Switch $iCode Case $LBN_ERRSPACE ; Insert your code here Case $LBN_SELCHANGE ; Insert your code here Case $LBN_DBLCLK ; Insert your code here Case $LBN_SELCANCEL ; Insert your code here EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND