Jump to content

trying to click a button not working (2 different issues)


Go to solution Solved by bogQ,

Recommended Posts

for the first problem my assumption is that some other tab is activated, try to see if it works if you switch to that tab manualy before you try to click or send space on button that is connected to that tab, ofc still try to use ClassnameNN in controlID parametar

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

On the problem where I've got two buttons both with the same name  I've collect some more info

right now my simple script is running

$title = "Edit"
WinActivate($title)
WinWaitActive($title)
sleep(1000)
$text = ControlGetText($title,"","[ClassnameNN:WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad19]")
MsgBox(1,"button text",$text)
 
I just want to see if I'm able to read the text on the button.  I'll try clicking it after.
Results of running the script is the window activates, a second goes by then the messagebox opens and is blank.  
 
This is the information from the info tool for both of the buttons.  They're both in the same window on the same tab.  
>>>> Window <<<<
Title: Edit
Class: WindowsForms10.Window.8.app.0.ea7f4a_r13_ad1
Position: 290, 153
Size: 1045, 666
Style: 0x16CA0000
ExStyle: 0x00050101
Handle: 0x0000000000131428
 
>>>> Control <<<<
Class: WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad1
Instance: 9
ClassnameNN: WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad19
Name: button1
Advanced (Class): [NAME:button1]
ID: 397882
Text: Lookup
Position: 245, 399
Size: 75, 23
ControlClick Coords: 30, 11
Style: 0x5601000B
ExStyle: 0x00000000
Handle: 0x000000000006123A
 
>>>> Window <<<<
Title: Edit
Class: WindowsForms10.Window.8.app.0.ea7f4a_r13_ad1
Position: 290, 153
Size: 1045, 666
Style: 0x16CA0000
ExStyle: 0x00050101
Handle: 0x0000000000131428
 
>>>> Control <<<<
Class: WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad1
Instance: 18
ClassnameNN: WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad118
Name: button1
Advanced (Class): [NAME:button1]
ID: 332222
Text: Lookup
Position: 175, 125
Size: 75, 23
ControlClick Coords: 44, 19
Style: 0x5601000B
ExStyle: 0x00000000
Handle: 0x00000000000511BE
Link to comment
Share on other sites

I got it.  I had to switch to class and instance so something like

ControlClick($title,"","[CLASS:WindowsForms10.BUTTON.app.0.ea7f4a_r13_ad1;Instance:9]")  to specifically get that button.

Now that seems to stay stable on each run of the program,  but is something like the instance # going to change if the programmers move/add/remove controls on that form?   Tying tests to versions is fine I just need to know that I'll need to do it.

Edited by strider3700
Link to comment
Share on other sites

Sure will.

Are the IDs constant, when you relaunch your app?  If so, that's the way to go.

I think all the junk after BUTTON.app.* is unique per session as well, but could be recalling incorrectly.

That, or you can loop through all buttons, until you get the one that matches your name, and IsVisible (controlcommand function)

last attempt:

ConsoleWrite(ControlGetHandle("yourtitle","","[NAME:button1; INSTANCE:1]") & @CRLF)
ConsoleWrite(ControlGetHandle("yourtitle","","[NAME:button1; INSTANCE:2]") & @CRLF)

at least this way, if it works, errors from new buttons MAY only occur when a new button with the same name is added

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

So far the id's and info in the class appears to be stable through numerous launches.   I haven't tried running the tests on a different machine yet but will do so before declaring victory.   I had tried the  [NAME:button1; INSTANCE:2] matching previously and it never seemed to match for me

Link to comment
Share on other sites

Yeah, the 'controls' help file doesn't specify ALL the little quirks of using multiple identifiers.  Some, if they exist at all, negate all other identifiers....such as attempting to get the second instance of an ID...the ID trumps any use of instance.

ID's would certainly be the best, then.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...