SccSLtd Posted November 5, 2015 Posted November 5, 2015 Hi Guys.Im trying to automate a piece of software we use here, its called window designer,Basically trying to automate some of the more labor intensive tasks that we do.importing exporting etc,Basically i need to click an item in the tree then change the highlighted item in the tab on the left here's my testing code as you can see from the commented out commands ive tried a few options.expandcollapse popup#include <Constants.au3> #include <MsgBoxConstants.au3> #include <GuiComboBox.au3> #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <GuiTreeView.au3> #include <GuiTab.au3> Opt("WinTitleMatchMode", 2) Opt("GUIDataSeparatorChar", ",") ;Global $sValue = InputBox("Matlist Extraction", "enter the name of the mat list", "", " M") Global $sValue = "GB70" Global $format = 1 Global $hWnd = ControlGetHandle("[CLASS:TEditMaterialsForm;TITLE:Edit Materials - " & $sValue & ".MAT]", "", "[CLASS:TTreeView; INSTANCE:1]") $hWnd_Tab = ControlGetHandle("[CLASS:TEditMaterialsForm;TITLE:Edit Materials - " & $sValue & ".MAT]", "", "[CLASS:TPageControl; INSTANCE:2]") $searchText = "*** White" WinActivate($hWnd) $hItemFound = _GUICtrlTreeView_FindItem($hWnd, $searchText, True) $name = _GUICtrlTreeView_GetText($hWnd, $hItemFound) $BranchName = $name $countmain = _GUICtrlTreeView_GetSiblingCount($hWnd, $hItemFound) $count = _GUICtrlTreeView_GetChildCount($hWnd, 0) For $j = 0 To $countmain - 1 ConsoleWrite("Processing Branch:" & $BranchName & @LF) For $i = 0 To $count - 1 $iOriginal = Opt("MouseCoordMode") ;Get the current MouseCoordMode $hItemFound = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound) $name = _GUICtrlTreeView_GetText($hWnd, $hItemFound) ;_GUICtrlTreeView_SelectItem($hWnd, $hItemFound) ;_GUICtrlTreeView_SetState($hWnd, $hItemFound, $TVIS_SELECTED) ;_GUICtrlTreeView_SetFocused($hWnd, $hItemFound) ;_GUICtrlTreeView_BeginUpdate ( $hWnd ) _GUICtrlTreeView_ClickItem($hWnd, $hItemFound) ;ControlClick($hWnd,"",$hItemFound) Sleep(3000) ;ControlTreeView("[CLASS:TEditMaterialsForm;TITLE:Edit Materials - " & $sValue & ".MAT]", "", $hWnd, "Select", "#" & $j & "|#" & $i) _GUICtrlTab_SetCurFocus($hWnd_Tab, 3) Sleep(3000) _GUICtrlTab_SetCurFocus($hWnd_Tab, 4) Sleep(3000) ;ConsoleWrite($hItemFound) ConsoleWrite("#" & $j & "|#" & $i) If $i = 0 And $j = 0 Then Send("{TAB}") EndIf Sleep(3000) ControlSend("[CLASS:TEditMaterialsForm;TITLE:Edit Materials - " & $sValue & ".MAT]", "", "[CLASS:TInfoComboBox; INSTANCE:1]", "Sacbolts x 2") $filename = $name ConsoleWrite($filename & @LF) Sleep(3000) Next $hItemFound = _GUICtrlTreeView_GetNextVisible($hWnd, $hItemFound) $count = _GUICtrlTreeView_GetChildCount($hWnd, $hItemFound) $name = _GUICtrlTreeView_GetText($hWnd, $hItemFound) $BranchName = $name Next Problem i have is the software is not behaving as it should to any of the commandclick or treeview select commands.the mouse click works but im trying to avoid using mouse or keyboard commands where i canany suggestions??
spudw2k Posted November 5, 2015 Posted November 5, 2015 (edited) edit:Have you used the au3info tool to verify the control class? Inspected your code closer. Looks like the treeview class in the program you are working with is TTreeView. I am not familiar with that class...so I think my next statement still stands.I believe the _GUICtrlTreeView funcs only interact with SysTreeView32 controls.Maybe someone else will chime in with an idea, but I'm at a loss. Edited November 5, 2015 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
SccSLtd Posted November 5, 2015 Author Posted November 5, 2015 (edited) Hi Thanks for the reply heres the au3info summary.>>>> Window <<<< Title: Edit Materials - GB70.MAT Class: TEditMaterialsForm Position: -8, 0 Size: 1936, 1080 Style: 0x16CF0000 ExStyle: 0x00010100 Handle: 0x0000000000090C18 >>>> Control <<<< Class: TTreeView Instance: 1 ClassnameNN: TTreeView1 Name: Advanced (Class): [CLASS:TTreeView; INSTANCE:1] ID: 3607626 Text: Position: 12, 51 Size: 313, 803 ControlClick Coords: 223, 124 Style: 0x54210027 ExStyle: 0x00000200 Handle: 0x0000000000370C4A >>>> Mouse <<<< Position: 239, 210 Cursor ID: 0 Color: 0x000000 the only issue i have is the clicking of the element at the moment, i think this is a funky issue with the program than with autoit.for example every command you can see in the code in my first post works as i expected it to. selecting the element, reading the text etc all are fine.when i click the element with the mouse it changes the data on the right hand side of the window so show data from that element, i cannot replicate this with any of the commands other than mouse click, is there any other commands that maybe worth a try?thinking they might be using some weird way to detect the clickWorks but uses the mouse_GUICtrlTreeView_ClickItem($hWnd, $hItemFound,"left", False)Selects item but doesnt update the infoControlClick($hWnd,"",$hItemFound) Regards Edited November 5, 2015 by SccSLtd
spudw2k Posted November 5, 2015 Posted November 5, 2015 Ok, I misunderstood/understand better now. I would've thought that the _ClickItem func would work if the rest are working. Very strange. Not sure how much of a difference it will make, but the _ClickItem func does allow a couple of optional parameters. One in particular is to move the mouse to the control. I wonder if there is something special about the class that requires the mouse cursor to move on it. By default, that optional param is False. Might be worth trying to set it to true and see what happens if you haven't already._GUICtrlTreeView_ClickItem($hwnd, $hItemFound, "Left", True) Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
SccSLtd Posted November 5, 2015 Author Posted November 5, 2015 Hiits a bit of a weird problem, this is the first time ive had issues with using autoit with any app. the _GUICtrlTreeView_ClickItem command works perfectly. with false or true set.there must be a difference that im not seeing between controlclick and the treview_cliclitem commandswas wondering if there was any other ways of clicking a control without using the mouse,i would rather stick to working with the controls directly instead of using the mouse clicks so as not to be reliant on the mouse if possible thanks again for the help
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