BatMan22 Posted March 9, 2018 Share Posted March 9, 2018 So I'm trying to display a list of a bunch of selected items.. and double click on the one to use from list view.. I know I've called Globals from all over and plan to clean the code up a bit later but I don't know why my list doesn't show and why my double clicks don't register. I basically stole the code from _GUICtrlListView_Create example in the help file and still I managed to break it expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Clipboard.au3> #include <GuiListView.au3> #include <Misc.au3> Opt("TrayIconDebug", 1) LoadSampleIDsFromBatchPrepToChooseMS() Func LoadSampleIDsFromBatchPrepToChooseMS() Local $sClip Local $wwfail = WinWait("Sample Selection Box", "", 2) If $wwfail = 0 Then TrayTip("Uh oh", "Sample Selection Box not found!", 5) Sleep(1000) Return False EndIf WinActivate("Sample Selection Box") Sleep(250) _ClipBoard_Empty() Global $aArray[1] = ["SampleID's"] Local $i = 1 While 1 _ClipBoard_Empty() Send("^c") Send("{Down}") Sleep(250) $sClip = StringStripWS(ClipGet(), 8) ;~ If StringStripWS($sClip, 8) = "" Then ExitLoop If StringStripWS($sClip, 8) = "" Or $sClip = $aArray[$i - 1] Then ExitLoop Else ReDim $aArray[UBound($aArray) + 1] $i += 1 $aArray[$i - 1] = $sClip EndIf ConsoleWrite("Var is: " & $aArray[$i - 1] & " this cycle. " & "Counter is:" & $i - 1 & @CRLF) WEnd ;~ EndFunc ;==>LoadSampleIDsFromBatchPrepToChooseMS Global $g_hListView Example() Func Example() Local $hGUI, $hImage $hGUI = GUICreate("Form1", 202, 614, 192, 124) Global $g_hListView = _GUICtrlListView_Create("$hGUI", 8, 8, 185, 591) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) For $i = 0 To UBound($aArray) - 1 _GUICtrlListView_AddItem($g_hListView, $aArray[$i], 0) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ; Local $tBuffer $hWndListView = $g_hListView If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Link to comment Share on other sites More sharing options...
Zedna Posted March 9, 2018 Share Posted March 9, 2018 1) Try to add ControlFocus(...) before your Send("^c") to activate your target control 2) What ClassName is your target control (check it by Au3Info)? If it's SysListView32 then use standard AutoIt' ListView functions to get data from it instead of ClipBoard commands BatMan22 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted March 9, 2018 Share Posted March 9, 2018 (edited) Here is fixed second part of your own ListView (display data in ListView): expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiListView.au3> #include <Misc.au3> ;~ Opt("TrayIconDebug", 1) Dim $aArray[3] $aArray[0] = '01' $aArray[1] = '02' $aArray[2] = '03' Global $g_hListView Example() Func Example() Local $hGUI, $hImage $hGUI = GUICreate("Form1", 202, 614, 192, 124) Global $g_hListView = _GUICtrlListView_Create($hGUI, 'Column 1', 8, 8, 185, 591) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ;~ _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) For $i = 0 To UBound($aArray) - 1 _GUICtrlListView_AddItem($g_hListView, $aArray[$i], 0) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ; Local $tBuffer $hWndListView = $g_hListView If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Edited March 9, 2018 by Zedna BatMan22 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
BatMan22 Posted March 9, 2018 Author Share Posted March 9, 2018 10 hours ago, Zedna said: Here is fixed second part of your own ListView (display data in ListView): expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiListView.au3> #include <Misc.au3> ;~ Opt("TrayIconDebug", 1) Dim $aArray[3] $aArray[0] = '01' $aArray[1] = '02' $aArray[2] = '03' Global $g_hListView Example() Func Example() Local $hGUI, $hImage $hGUI = GUICreate("Form1", 202, 614, 192, 124) Global $g_hListView = _GUICtrlListView_Create($hGUI, 'Column 1', 8, 8, 185, 591) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ;~ _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) For $i = 0 To UBound($aArray) - 1 _GUICtrlListView_AddItem($g_hListView, $aArray[$i], 0) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ; Local $tBuffer $hWndListView = $g_hListView If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Hmmm.. I gotta go through that and figure out what I did wrong. Link to comment Share on other sites More sharing options...
BatMan22 Posted March 9, 2018 Author Share Posted March 9, 2018 10 hours ago, Zedna said: 1) Try to add ControlFocus(...) before your Send("^c") to activate your target control 2) What ClassName is your target control (check it by Au3Info)? If it's SysListView32 then use standard AutoIt' ListView functions to get data from it instead of ClipBoard commands No, unfortunately it's not SysListView32, it's microsoft access 2010 basically... I've tried playing with it before but IUI Automation works great some SOME of my applications but something it causes Microsoft Access to crash (our modified version). Sooo.. The controls that work, I left as smart controls but some are dumb controls/clicks/whatever. SimpleSpy spit out the info from the grid below.. I don't even know how to read grid info using IUI automation so I will probably just leave it as a 'dumb' function. If I could read the cells then I wouldn't even need to send the Ctrl-C. Anyways, you rock dude. Thanks for fixing the doubleclick #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=McCampbell Omega_Me - [Prep];controltype:=UIA_WindowControlTypeId;class:=OMain") ;McCampbell Omega_Me - [Prep] _UIA_setVar("oP2","Title:=Sample Selection Box;controltype:=UIA_WindowControlTypeId;class:=OFormPopup") ;Sample Selection Box _UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=OFormSub") ; _UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=OFormChild") ; _UIA_setVar("oP5","Title:=Grid;controltype:=UIA_PaneControlTypeId;class:=OGrid") ;Grid ;~ $oUIElement=_UIA_getObjectByFindAll("Grid.mainwindow", "title:=Grid;ControlType:=UIA_TableControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","Title:=Grid;controltype:=UIA_TableControlTypeId;class:=") ;ControlType:=UIA_TableControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") ;~_UIA_Action("oP3","highlight") _UIA_Action("oP3","setfocus") ;~_UIA_Action("oP4","highlight") _UIA_Action("oP4","setfocus") ;~_UIA_Action("oP5","highlight") _UIA_Action("oP5","setfocus") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click") Link to comment Share on other sites More sharing options...
Earthshine Posted March 10, 2018 Share Posted March 10, 2018 (edited) $str = _UIA_Action($oElement, “getValue”) To read the value as a string Maybe a string array because you’re going to be probably getting an array back but you’ll have to test to see what happens Edited March 10, 2018 by Earthshine BatMan22 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
BatMan22 Posted March 10, 2018 Author Share Posted March 10, 2018 3 hours ago, Earthshine said: $str = _UIA_Action($oElement, “getValue”) To read the value as a string Maybe a string array because you’re going to be probably getting an array back but you’ll have to test to see what happens Yeah it responds with the first cell value then it just turns into a mess. For this scenario, there's two side by side grids, and the only way to tell them apart is by their children, so I would have to program it to look at children to figure everything out and it's out of my time/capability reach right now. Appreciate checking though. Link to comment Share on other sites More sharing options...
Zedna Posted March 10, 2018 Share Posted March 10, 2018 If it's "Microsoft Access" and if you have access to database file (MDB) then use ADO objects to directly read data from this databse. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now