Jump to content

How to access controls for CLASS:#32770 that the control ID is not unique? - repost


Recommended Posts

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:

au1.thumb.PNG.b341b1be3fb7735b62124f742c5588fc.PNG

 

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.

au2.thumb.PNG.1bcb458117124d630279d976017252a3.PNG

 

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.

au3.thumb.PNG.7caa23af9eb0d4cda64eaa8823c8898a.PNG

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]')
 

au4.thumb.PNG.0d5de19187d999e04b70ec63703febf0.PNG

 

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 post
Share on other sites

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 post
Share on other sites
  • Moderators

What you should have done is simply asked to have it moved, rather than creating another post. Threads merged.

"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 post
Share on other sites
23 minutes ago, eastam said:

What else information do you need? 

He wants a runable script that can be run.

Link to post
Share on other sites
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 by eastam
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...