DanMeow Posted July 25, 2020 Share Posted July 25, 2020 (edited) Hello, I managed to get a basic script working that logs into the erp system, runs a stored procedure with parameters etc and waits for the results. Now I'm facing a problem of how to trigger the last action, which is to execute export into excel. In the erp's gui, this is done by a dedicated toolbar, that is not accessible by any shortcut key (I did read the accompanying docs), cannot be reached by Tab etc. I have to click the "Actions" listbox and then one of the list options (Export to Excel) = click Actions, wait, click Export to Excel option from the scroll-down. I can do it using the click commands, but they only work on active window and I need this to run on server. I tried ControlClick with the correct windows handle and without controlId (with various x,y coordinates) without success. To minimise the risk on not providing the right x,y coordinates, I put them into double for-to loops, incrementing each 1-500 with some delays... again no result, not a single successfull click. Furthermore a custom function recommended elsewhere (_MouseClickPlus) also did not work. I even tried to list ALL the window controls (cca 100) and manually send their controlId to the ControlClick method. It clicked all aroung the gui except this very toolbar. This is what the info tool provides reg. the toolbar: (another "fun" thing is that the controlIDs change with each instance) In this situation, is there anything you would advise me to do? Is there perhaps another function worth trying, or try autohotkey or some other scripting tool for this singular purpose? Thank you, Daniel Edited July 25, 2020 by DanMeow typo Link to comment Share on other sites More sharing options...
Nine Posted July 25, 2020 Share Posted July 25, 2020 Have you tried ControlClick with window handle and control handle with the appropriate x/y position within the control ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DanMeow Posted July 25, 2020 Author Share Posted July 25, 2020 I don't have any control handle that would operate this tollbar with the ControlClick (I tried all window control handles manually). But I guess I could try another control's (completely different in the gui but working with the method) and provide the correct coordinates. I will report back how it went. Thank you. Link to comment Share on other sites More sharing options...
Nine Posted July 25, 2020 Share Posted July 25, 2020 (edited) Here an example with Window Explorer how to use the toolbar handle to click a specific area : ;Run ("explorer") ;Sleep(500) Local $hWnd = WinActivate("[CLASS:CabinetWClass]") ;MsgBox ($MB_SYSTEMMODAL,"",$hWnd) Local $hCtrl = ControlGetHandle($hWnd,"","ToolbarWindow321") ;MsgBox ($MB_SYSTEMMODAL,"",$hCtrl) Local $aPos = ControlGetPos ($hWnd, "", $hCtrl) _ArrayDisplay ($aPos) ControlClick ($hWnd, "", $hCtrl, "left", 1, $aPos[0]+$aPos[2]/3, $aPos[1]+$aPos[3]/2) Use the CLASSNN to get the handle of the control Edited July 25, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DanMeow Posted July 25, 2020 Author Share Posted July 25, 2020 Oh man, you helped me so much! This works for the 1st click ("Actions"): Local $hCtrl = ControlGetHandle($hWnd,"","[NAME:_BrowseToolbar_Toolbars_Dock_Area_Top]") ControlClick($hWnd, "", $hCtrl, "left", 1, 46, 17) Now my challenge will be the 2nd click, where the control is not named (and ID's keep changing). But the fact the instance of the class is 1 looks good. Maybe at least this will remain the same... TY again! Link to comment Share on other sites More sharing options...
Nine Posted July 25, 2020 Share Posted July 25, 2020 I believe you could do the same with the new CLASSNN. Try it with the position (should always be the same) of the Excel export. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DanMeow Posted July 25, 2020 Author Share Posted July 25, 2020 got it! ... and it's a new window (class 808 vs 8, missed it completely at first) This works (tested while disconnected from rdc and at different gui positions and sizes) $hWnd = WinGetHandle("prod: 200 ... [CZK] (1) - QAD Enterprise Applications") Local $hCtrl = ControlGetHandle($hWnd,"","[NAME:_BrowseToolbar_Toolbars_Dock_Area_Top]") ControlClick($hWnd, "", $hCtrl, "left", 1, 46, 17) Sleep(1500) $hWnd2 = WinGetHandle("[Class:WindowsForms10.Window.808.app.0.2004eee]") Local $hCtrl2 = ControlGetHandle($hWnd2,"","[Classnn:WindowsForms10.Window.8.app.0.2004eee1]") ControlClick($hWnd, "", $hCtrl2, "left", 1, 14, 86) Perfect, TY! Link to comment Share on other sites More sharing options...
Nine Posted July 25, 2020 Share Posted July 25, 2020 Glad it works HNB2018 and Musashi 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Luli Posted April 22 Share Posted April 22 Hi guys, I am facing the same issue with a script for Teradata SQL. I need the script to open a connection and to do so it must be able to click on the area I marked in red. Even the debug mode isn't helping because it says that everything is executed successfully but the new window is not opening. A copy of my script: ConsoleWrite("Waiting for Teradata SQL Assistant window..." & @CRLF) Local $hWnd = WinWait("Teradata SQL Assistant", "", 10) ; Check if the window handle was obtained successfully If $hWnd Then ConsoleWrite("Teradata SQL Assistant window found." & @CRLF) ; Get the handle of the main window $hWnd = WinGetHandle("Teradata SQL Assistant") ; Check if the main window handle is valid If $hWnd Then ConsoleWrite("Activating Teradata SQL Assistant window..." & @CRLF) ; Activate the Teradata SQL Assistant window WinActivate($hWnd) WinWaitActive($hWnd) ; Find and click the toolbar area to start a connection ConsoleWrite("Finding toolbar area..." & @CRLF) Local $hToolbar = ControlGetHandle($hWnd, "", "[NAME:_MainWnd_Toolbars_Dock_Area_Top]") ; Check if the toolbar control handle was obtained successfully If $hToolbar Then ConsoleWrite("Toolbar area found. Clicking..." & @CRLF) ; Click on the toolbar area (adjust the coordinates as needed) ControlClick($hWnd, "", $hToolbar, "left", 1, 25, 65) Else ConsoleWrite("Error: Failed to find the toolbar area." & @CRLF) MsgBox(16, "Error", "Failed to find the toolbar area.") EndIf Else ConsoleWrite("Error: Failed to get the handle of the main window." & @CRLF) MsgBox(16, "Error", "Failed to get the handle of the main window.") EndIf Else ConsoleWrite("Error: Teradata SQL Assistant window not found." & @CRLF) MsgBox(16, "Error", "Teradata SQL Assistant window not found.") EndIf 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