eastam Posted September 9, 2019 Share Posted September 9, 2019 Hi everyone, I am new to autoit and I found it is very useful to do automation. Now I am automating a stock order program in Python environment with AutoitX3. I encountered several types of question: 1. How to access Controls with control ID? Sometimes it works (in one PC environment) and sometimes it fails (in another PC environement), but with ClassnameNN, it both works. I will describe it in detail in the following. 2. How to access Controls in a pop-up dialog with Classname #32770 without a title text? To describe my questions, first I instantiated an autoit object: autoit = win32com.client.Dispatch("AutoItX3.Control") With this object, I can execute autoitX related functions. For question 1, please see the following picture: With the code I first fill the "stock number", "stock price" and "amount" in the Edit field with code, and then I need to click the "buy" button which is red circled. The code is autoit.ControlClick(wndTitile,'买入','Button22') # wndTitle here is the Titile which is in Chinese as show in the Autoit windows info tools This code works. However, the intance number changes when I use different computer. Therefore I think that I could use the Control ID for this with following code: autoit.ControlClick(wndTitile,'买入','[CLASS:Button;ID:1006]') # From the picture we could see it's ID is 1006. I used this format to fill the Edit box of "stock number", "stock price" and "amount" , it works. But for the button at the same page, it doesn't. And I tried several different things for it 1. remove the text part as "autoit.ControlClick(wndTitile,'','[CLASS:Button;ID:1006]')", not work; 2. remove the CLASS part as "autoit.ControlClick(wndTitile,'买入','[ID:1006]')" ,not work for the Button here, but works for the Edit box above I don't know why this happen. Can anyone help to figure out how to use Control ID in a correct way? Since the instance number changes all the time, I don't want to use the instance number and need to modify the code everytime. For the second question, it is related to the pop-up dialog #32770 without title text. After the "buy" button above discessed is fired, there will be two pop up dialog with Classname #32770 and without title text, the first one is as following and it is to confirm the buy through press button "Yes" and "No" (which is in Chinese, sorry for that). Through the right summary part, we could see the blue circled button that it is without title and control ID is 6. I can access the button through following code, but I am not sure whether the '[ACTIVE]' is used correctly because for the second button I can never touch it anymore. autoit.ControlClick('[ACTIVE]','是(&Y)','[ID:6]') # works For this button, following codes doesn't work where the title part is changed to [CLASS:#32770]. There is also another floating tool bar for this software is with Classname #32770 and no title text. So this may be the reason that I can't access the button control with title '[CLASS:#32770]'. But how can I? autoit.ControlClick('[CLASS:#32770]','是(&Y)','[ID:6]') # Not work. After this dialog, there comes another dialog, also with classname #32770. Please the picture. I want to access the red circled text part that is Static control. But this time I can never survive with any means. The code is as previous dialog: autoit.ControlGetText('[ACTIVE]','','[ID:1004]') # Not work. autoit.ControlGetText('[ACTIVE]','','[CLASS:Static; ID:1004]') # Not work. autoit.ControlGetText('[ACTIVE]','','Static1') # Not work. autoit.ControlGetText('[CLASS:#32770]','','[ID:1004]') # Not work. autoit.ControlGetText('[CLASS:#32770]','','Static1') # Not work. After several round of trying, I found one thing that there is another control for the program with the same Control ID, i.e. 1004. Please see the picture: It is a ComboBox control in the main program and with the same Control ID, which is red circled. That means there are duplicate control ID in a same program that I was told that control ID is unique some where. When I use following code, I got some text but it is the text of the ComboBox althrough the CLASS is specified as CLASS:Static. This seems to show that CLASS:Static here takes no effect. txt = autoit.ControlGetText('[ACTIVE]','','[CLASS:Static;ID:1004]') Then I think here the '[ACTIVE]' window is not the top most dialog of the program this time,but for the previous pop up dialog. It seems to be the dialog. How can I access the top most window of the program that autoit is access? From other tools I know that they have a function called app.top_window() that accesses to the top_window of the program. I think this may works for current situation that there are multiple #32770 window and no title text to differentiate them. Can I access the top window from autoit with some function? I learned from the forum that maybe the window handle should be unique. But how can I get the window handle or control handle for this case? #32770 dialog without title text. I tried autoit.WinList(wndTitle) after the second dialog pop up. My thinking is that there should be a window handle that is corresponding to the #32770 dialog. But maybe I am wrong, the list is as following: ((1, '网上股票交易系统5.0'), (None, '00150B7A')) The first tuple is the main window, and I think the second is for the pop-up dialog but it is not when I print the window text out with handle '00150B7A'. The window text is similar with the main window's, and is not the text from the pop up dialog. So my question here is how to access the pop-up dialog without title text correctly? And how to access the controls on it with duplicate Control ID? I think if the first question is solved, then the second question may be not a issue any more. BTW, my running environment is: 1. Win10 for both PC 2. Python 3.74 with 32 bit virtual environment separately installed and the code running is under this environment 3. The stock program is with UIA back end, I think. Sorry for the long text, and hope I describe my question clearly. Any one could offer your help is highly appreciated! Thanks in advance. Link to comment Share on other sites More sharing options...
eastam Posted September 9, 2019 Author Share Posted September 9, 2019 Anybody can help? Link to comment Share on other sites More sharing options...
eastam Posted September 10, 2019 Author Share Posted September 10, 2019 Hi all experts, I am not to flush the forum, but I think maybe I post a topic in a wrong block which is with few visit. So I redirect the link of the post here to ask for help. Sorry for inconvenience. Please see the following for the details. Mainly there are two questions: 1. How to access controls with Control ID, other than [CLASS;INSTANCE], since the instance ID will change on different PC. Sometimes it works, but sometime it doesn't. 2. How to access controls of #32770 popup dialog (without title text) which has a duplicated Control ID with other controls in the program (not in dialog). Moderate, Please, please don't kill this thread. Or I prefer to move the original link to this block here with more visitors. Thanks in advance. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 10, 2019 Moderators Share Posted September 10, 2019 What you should have done is simply asked to have it moved, rather than creating another post. Threads merged. eastam 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
eastam Posted September 10, 2019 Author Share Posted September 10, 2019 4 hours ago, JLogan3o13 said: What you should have done is simply asked to have it moved, rather than creating another post. Threads merged. Thanks Moderator, many appreciation. I am new to the forum. Really don't know this. Thanks. Link to comment Share on other sites More sharing options...
eastam Posted September 10, 2019 Author Share Posted September 10, 2019 Anyone could offer your help? Thanks in advance. Summon big God. Link to comment Share on other sites More sharing options...
eastam Posted September 12, 2019 Author Share Posted September 12, 2019 Any one? Link to comment Share on other sites More sharing options...
eastam Posted September 16, 2019 Author Share Posted September 16, 2019 Too complicated? Link to comment Share on other sites More sharing options...
Earthshine Posted September 16, 2019 Share Posted September 16, 2019 If you want help then post your script My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
eastam Posted September 17, 2019 Author Share Posted September 17, 2019 18 hours ago, Earthshine said: If you want help then post your script I already write the scripts in the post. What else information do you need? Link to comment Share on other sites More sharing options...
Nine Posted September 17, 2019 Share Posted September 17, 2019 23 minutes ago, eastam said: What else information do you need? He wants a runable script that can be run. “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...
eastam Posted September 19, 2019 Author Share Posted September 19, 2019 (edited) On 9/17/2019 at 8:29 AM, Nine said: He wants a runable script that can be run. With script he also can't run it bceause the software is the trader software. I think I already describe the problem clearly. It seems to be common issue for #32770 dialog box. The specific issue is that it is without title text property help to identify the window/control. How to access it through window handle or other way? Edited September 19, 2019 by eastam Link to comment Share on other sites More sharing options...
Earthshine Posted September 19, 2019 Share Posted September 19, 2019 UIAutomation could do it My resources are limited. You must ask the right questions 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