Soundarya Posted April 12, 2023 Share Posted April 12, 2023 In my Mainframe application there is a "Tool Bar" and it has Run Macro option. Is there a way to click on that "Run Macro" option using auotit ? Link to comment Share on other sites More sharing options...
Danp2 Posted April 12, 2023 Share Posted April 12, 2023 I'm sure that there's a way to do it, but we can't guide you with only this limited information. What does AU3Info display when you examine this control? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Soundarya Posted April 12, 2023 Author Share Posted April 12, 2023 (edited) @Danp2 Thanks for checking this. Here is the windows info. I noticed that "Run Macro" is inside the Toolbar, but I don't see any visible text related to Macro. Please check and let me know if I have to provide any additional info. Sorry I have to remove the title as it holds some confidential information that I am not supposed to share. >>>> Window <<<< Title: Class: IEFrame Position: -8, -8 Size: 1296, 696 Style: 0x17CF0000 ExStyle: 0x00000100 Handle: 0x003A1030 >>>> Control <<<< Class: Afx:ToolBar:400000:8:10003:10 Instance: 2 ClassnameNN: Afx:ToolBar:400000:8:10003:102 Name: Advanced (Class): [CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2] ID: 59392 Text: Toolbar Position: 0, 0 Size: 981, 53 ControlClick Coords: 643, 23 Style: 0x5600084C ExStyle: 0x00000000 Handle: 0x005A0A50 >>>> Mouse <<<< Position: 643, 46 Cursor ID: 0 Color: 0xB7DCFA >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Toolbar Button Bar 2 Button Bar 1 >>>> Hidden Text <<<< Navigation Bar Address Bar Address Combo Control Page Control Search Bar Address Combo Control Page Control Favorites Bar Add to Favorites bar ITBarHost Menu Bar Button Bar 3 Edited April 12, 2023 by Soundarya Link to comment Share on other sites More sharing options...
Danp2 Posted April 12, 2023 Share Posted April 12, 2023 I'm not sure how to advise you on this. Maybe someone else will jump in with some suggestions. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted April 12, 2023 Share Posted April 12, 2023 (edited) Is it IE embeded ? 50 minutes ago, Soundarya said: Class: IEFrame 2 hours ago, Soundarya said: Is there a way to click on that "Run Macro" option using auotit ? Did you try to use UIASpy ? Edited April 12, 2023 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Nine Posted April 12, 2023 Share Posted April 12, 2023 Check if UDF/GUI/Toolbar Management functions can see your tool bar... “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...
Soundarya Posted April 13, 2023 Author Share Posted April 13, 2023 (edited) Thank you all for sharing the suggestions. Now I could access the tool bar with below code and I tried to loop through each button and printed the button names, where I saw the button name "Run Macro". Which is really great. Now I want to click on the button, I tried to do with Button Index, but failed in the process. Still trying. If some one have already did the same please share your thoughts. Func PassportInputs() Local $IE = _IECreate(I given my link to passposrt) $hWnd = ControlGetHandle("", "", "[CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2]") ; Get number of buttons $iCount = _GUICtrlToolbar_ButtonCount($hWnd) ; Loop through buttons For $i = 1 To $iCount - 1 Step 1 ; $iCmdID = _GUICtrlToolbar_IndexToCommand($hWnd, $i) $sText = _GUICtrlToolbar_GetButtonText($hWnd, $iCmdID) MsgBox(0,"",$sText) Next EndFunc Edited April 13, 2023 by Soundarya Link to comment Share on other sites More sharing options...
mLipok Posted April 13, 2023 Share Posted April 13, 2023 Please read: * How to post code on the forum * try this: Func PassportInputs() Local $IE = _IECreate(I given my link To passposrt) $hWnd = ControlGetHandle("", "", "[CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2]") ; Get number of buttons $iCount = _GUICtrlToolbar_ButtonCount($hWnd) ; Loop through buttons For $i = 1 To $iCount - 1 Step 1 ; $iCmdID = _GUICtrlToolbar_IndexToCommand($hWnd, $i) $sText = _GUICtrlToolbar_GetButtonText($hWnd, $iCmdID) If $sText ='Run Macro' Then _GUICtrlToolbar_ClickIndex($hWnd, $iCmdID) Next EndFunc ;==>PassportInputs Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Nine Posted April 13, 2023 Share Posted April 13, 2023 (edited) Another way is to get the position of the button with _GUICtrlToolbar_GetButtonRect, then use ControlClick to the middle of the rectangle. Tested on my own toolBar and it is working fine. ps. _GUICtrlToolbar_ClickIndex requires that the window containing the toolbar be active (at least visible) since it is using MouseClick. Edited April 13, 2023 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...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 @Nine Continuation on above topic. All I could do with my Mainframe Tool bar is only Get the Text of the button. But When I perform any action like control click and other it is not happening. I tried MouseClick and it worked using the Click co-ordinates. Any idea why the control click is not working. Link to comment Share on other sites More sharing options...
Nine Posted April 26, 2023 Share Posted April 26, 2023 (edited) As per help file on ControlClick : Quote Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick(). Is the tool ran x64 ? or elevated ? And post your last script attempt that does not work. When you post code, use the method shown in the link... Edited April 26, 2023 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...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 @Nine Below is my recent code. I tried to print he button names and it is successful, but when I do click button it is not happening. Func PassportInputs() Local $IE = _IECreate("My link to the app") sleep(10000) $hWnd = ControlGetHandle("","",'[CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2]') ; Get number of buttons $iCount = _GUICtrlToolbar_ButtonCount($hWnd) ; Loop through buttons For $i = 1 To $iCount - 1 Step 1 ; <<<<< You may need single step $iCmdID = _GUICtrlToolbar_IndexToCommand($hWnd, $i) ;MsgBox(0,"",$iCmdID) $sText = _GUICtrlToolbar_GetButtonText($hWnd, $iCmdID) ;MsgBox(0,"",$sText) If $sText ='Run Macro' Then _GUICtrlToolbar_ClickButton($hWnd,$iCmdID) EndIf Next EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted April 26, 2023 Share Posted April 26, 2023 It's possible that your string comparison isn't matching so that the _GUICtrlToolbar_ClickButton never gets executed. You should add a ConsoleWrite inside the If structure so that you can be sure it is working as expected. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 @Danp2 I tried to do a message box to see it enters If loop and yes it did. So only problem is with click Link to comment Share on other sites More sharing options...
Nine Posted April 26, 2023 Share Posted April 26, 2023 (edited) As I already told you, _GUICtrlToolbar_ClickButton is based on MouseClick and you also said that MouseClick is working. So there is something wrong in your code ( @Danp2 may have just nailed it ). Another way to check if the click is performed correctly, make the click move the cursor : _GUICtrlToolbar_ClickButton($hWnd, $iCmdID, "left", True) ; will move the cursor to the click area ps. put some consoleWrite here and there to follow the path of your script and post both your new script and the console result here... FYI. buttons are 0-based -- so loop should start at 0 not 1 Edited April 26, 2023 by Nine Danp2 1 “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...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 (edited) @Nine Func PassportInputs() Local $IE = _IECreate("Link to App") sleep(10000) $hWnd = ControlGetHandle("","",'[CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2]') ; Get number of buttons $iCount = _GUICtrlToolbar_ButtonCount($hWnd) ; Loop through buttons ConsoleWrite($hWnd & @CRLF) For $i = 0 To $iCount - 1 Step 1 ; $iCmdID = _GUICtrlToolbar_IndexToCommand($hWnd, $i) ;MsgBox(0,"",$iCmdID) $sText = _GUICtrlToolbar_GetButtonText($hWnd, $iCmdID) ;MsgBox(0,"",$sText) If $sText = 'Run Macro' Then ConsoleWrite($sText & @CRLF) ConsoleWrite($hWnd & @CRLF) ConsoleWrite($iCmdID & @CRLF) _GUICtrlToolbar_ClickButton($hWnd, $iCmdID, "left", True) EndIF Next EndFunc Console >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\SZP0544\Documents\FMB Automation\FMB Automation.au3" --> IE.au3 V3.1-0 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023179, Browser has been deleted prior to operation.) 0x002D1A6C Run Macro 0x002D1A6C 31016 >Exit code: 0 Edited April 26, 2023 by Soundarya Link to comment Share on other sites More sharing options...
Danp2 Posted April 26, 2023 Share Posted April 26, 2023 Did the mouse cursor move to the correct location? I'm wondering if there could be an issue due to screen scaling. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 (edited) @Danp2 , No the cursor did not move at all . But when I do command "MouseMove" it moves Edited April 26, 2023 by Soundarya Link to comment Share on other sites More sharing options...
Danp2 Posted April 26, 2023 Share Posted April 26, 2023 That could be due to screen scaling because you are potentially providing a different set of x / y values from that calculated by _GUICtrlToolbar_ClickButton. Post the output from running the following code -- #include <WinAPIGdi.au3> #include <GuiToolbar.au3> #include <IE.au3> ; https://www.autoitscript.com/forum/topic/199363-more-elegant-way-than-this-to-get-monitor-scaling/?do=findComment&comment=1430331 Global $scale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth ConsoleWrite("Scale = " & _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] & " / " & @DesktopWidth & " = " & $scale & @CRLF) Local $IE = _IECreate("Link to App") sleep(10000) $hWnd = ControlGetHandle("","",'[CLASS:Afx:ToolBar:400000:8:10003:10; INSTANCE:2]') ; Get number of buttons $iCount = _GUICtrlToolbar_ButtonCount($hWnd) For $i = 0 To $iCount - 1 Step 1 ; $iCmdID = _GUICtrlToolbar_IndexToCommand($hWnd, $i) $sText = _GUICtrlToolbar_GetButtonText($hWnd, $iCmdID) If $sText = 'Run Macro' Then ; from _GUICtrlToolbar_ClickButton Local $tRECT = _GUICtrlToolbar_GetButtonRectEx($hWnd, $iCmdID) Local $tPoint = _WinAPI_PointFromRect($tRECT) $tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint) Local $iX, $iY _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) ConsoleWrite("x:" & $iX & " / y:" & $iY & @CRLF) EndIF Next Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Soundarya Posted April 26, 2023 Author Share Posted April 26, 2023 (edited) @Danp2 Thanks for trying this out. Here is the console for the given code >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\SZP0544\Documents\FMB Automation\FMB Automation.au3" Scale = 1280 / 1280 = 1 --> IE.au3 V3.1-0 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023179, Browser has been deleted prior to operation.) x:199 / y:33 >Exit code: 0 Edited April 26, 2023 by Soundarya 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