tsherr Posted February 13, 2008 Share Posted February 13, 2008 Hi All, Sorry to be such a newb, but I'm still working my way through understanding the AutoIT language. Here's my current problem. I'm using AutoIT Window Info to get the ClassnameNN for a control so I can use ControlClick to send a click to it, but it appears the ClassNameNN changes depending on what I've clicked on previously. For instance, I'm trying to write a script to automate running a scan with Spysweeper 4.5. So I'm doing the following: Activate the Spysweeper Window Click on the Options button (TTeButton6) Set the options Click on the Sweep button (TTeButton11) Click on start to run the sweep. Here's the strange thing. If the Home Window is up (the Home button has been clicked) then Options is (TTeButton5) and Sweep is (TTeButton10.) But once I bring up the Options window, then the Sweep button changes to TTeButton11. Clearly I'm misunderstanding the concept of ControlClick or the concept of ClassnameNN, or a little of both. If someone could explain it to me, I'd really appreciate it. I already tried sending commands by use Alt-Letter rather than ControlClick, but that seems to be unreliable. Thanks, T Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 13, 2008 Share Posted February 13, 2008 (edited) Hi All, Sorry to be such a newb, but I'm still working my way through understanding the AutoIT language. Here's my current problem. I'm using AutoIT Window Info to get the ClassnameNN for a control so I can use ControlClick to send a click to it, but it appears the ClassNameNN changes depending on what I've clicked on previously. For instance, I'm trying to write a script to automate running a scan with Spysweeper 4.5. So I'm doing the following: Activate the Spysweeper Window Click on the Options button (TTeButton6) Set the options Click on the Sweep button (TTeButton11) Click on start to run the sweep. Here's the strange thing. If the Home Window is up (the Home button has been clicked) then Options is (TTeButton5) and Sweep is (TTeButton10.) But once I bring up the Options window, then the Sweep button changes to TTeButton11. Clearly I'm misunderstanding the concept of ControlClick or the concept of ClassnameNN, or a little of both. If someone could explain it to me, I'd really appreciate it. I already tried sending commands by use Alt-Letter rather than ControlClick, but that seems to be unreliable. Thanks, T The ClassNameNN is, as the name implies, just the class name of the control (i.e. "TTeButton") and a 1-based instance number. The instance number is relative to the GUI the control is created in. Here's an example: $hGUI1 = GUICreate("Test One", 200, 100, 200, 200) GUICtrlCreateButton("TEST", 50, 50, 100, 30) GUISetState() $hGUI2 = GUICreate("Test Two", 200, 100, 400, 400) GUICtrlCreateButton("TEST", 50, 50, 100, 30) GUISetState() Do Until GUIGetMsg() = -3oÝ÷ Øw«{ljz-êÞÅ©©ì!Èbìi'n°z{fË"!zr%jË^v+^vØb²,µ«¢+ØÀÌØí¡U$ÄôU% ÉÑ ÅÕ½ÐíQÍÐ=¹ÅÕ½Ðì°ÈÀÀ°ÄÀÀ°ÈÀÀ°ÈÀÀ¤)U% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½ÐíQMPÅÕ½Ðì°ÔÀ°ÔÀ°ÄÀÀ°ÌÀ¤)U%MÑMÑÑ ¤((ÀÌØí¡U$ÈôU% ÉÑ ÅÕ½ÐíQÍÐQݼÅÕ½Ðì°ÈÀÀ°ÄÀÀ°ÐÀÀ°ÐÀÀ¤(ÀÌØí ÕÑѽ¸ôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½ÐíQMPÅÕ½Ðì°ÔÀ°ÄÀ°ÄÀÀ°ÌÀ¤)U% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí9==@ÅÕ½Ðì°ÔÀ°ÔÀ°ÄÀÀ°ÌÀ¤)U%MÑMÑÑ ¤()¼)U¹Ñ¥°U%Ñ5Í ¤ôÀÌØí ÕÑѽ¸()M±À ÄÀÀÀ¤)U% Ñɱ±Ñ ÀÌØí ÕÑѽ¸¤)M±À ÌÀÀÀ¤)U% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí9QMPÅÕ½Ðì°ÔÀ°ÄÀ°ÄÀÀ°ÌÀ¤()¼)U¹Ñ¥°U%Ñ5Í ¤ô´Ì Notice when you run AU3Info.exe on the second GUI this time, you see Button1 ("TEST") and Button2 ("NOOP"). When you click on "TEST", it gets deleted and if you check the "NOOP" button, it becomes Button1. After 3sec a replacement button is created ("NEW TEST") and now it is Button2. Lots of programs delete/add entire GUIs while they run, and can delete/add controls on GUIs that stay up. When that happens the ClassNameNN of a control can change, as demonstrated, but the HWND of a control will NOT change as long as it exists. If the control is recreated, even if it winds up with the same ClassNameNN it WILL have a new HWND. Hope that helps. Edit: Typo. Edit 2.0: Replaced missing second example Edited February 13, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
tsherr Posted February 13, 2008 Author Share Posted February 13, 2008 The ClassNameNN is, as the name implies, just the class name of the control (i.e. "TTeButton") and a 1-based instance number. The instance number is relative to the GUI the control is created in. Here's an example: $hGUI1 = GUICreate("Test One", 200, 100, 200, 200) GUICtrlCreateButton("TEST", 50, 50, 100, 30) GUISetState() $hGUI2 = GUICreate("Test Two", 200, 100, 400, 400) GUICtrlCreateButton("TEST", 50, 50, 100, 30) GUISetState() Do Until GUIGetMsg() = -3 Notice when you run AU3Info.exe on the second GUI this time, you see Button1 ("TEST") and Button2 ("NOOP"). When you click on "TEST", it gets deleted and if you check the "NOOP" button, it becomes Button1. After 3sec a replacement button is created ("NEW TEST") and now it is Button2. Lots of programs delete/add entire GUIs while they run, and can delete/add controls on GUIs that stay up. When that happens the ClassNameNN of a control can change, as demonstrated, but the HWND of a control will NOT change as long as it exists. If the control is recreated, even if it winds up with the same ClassNameNN it WILL have a new HWND. Hope that helps. Edit: Typo. That does explain my problem, but it leaves me with this problem. How can I make sure AutoIT always clicks on the same button in a program? T Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 13, 2008 Share Posted February 13, 2008 In the help file, drill down to: AutoIt > Function Reference > Window Management > double-click on "Controls" and read about how you can use the "Text" method to use with ControlGetHandle to get a HWND of the control. Then use the HWND as the controlID for the ControlClick function. Happy Trails, newbe. Das Häschen benutzt Radar 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