Jump to content

ControlSend Problem: Instance Number CHANGES


Recommended Posts

I was running through a test script that was working fine, and it fails to enter text into a control suddenly.

Weird... since it was working last night...

I pull up WinInfo and check the control, to find its INSTANCE NUMBER HAS CHANGED!

I run the app as a user, and follow aong with WinInfo... sure enough, depending on which way I bring my windows up, my instances CHANGE... making my script completely unreliable.

Two questions: 1) Am I crazy? Or have others seen this behavior?

2) Does anyone have a work-around?

I was thinking that I could do a mouse click at the control's position, and grab the ID, and then use it instead of the CLASS and INSTANCE... but there seems to be no way of doing this...

So, am I stuck with just using mouse-clicks and SENDS() followed by mouse clicks, right mouse click, select all, copy? (Yuck!)

Link to comment
Share on other sites

Sending {TAB}s to navigate to the control might help a bit..

Well, I can mouseclick into the position, too.

It's just the documentation says:

"ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send - and yes it does send shift, ctrl, alt etc."

But if the instance changes, then it is fully unreliable. The ControlSend function also talks about an ID and even shows a snippet of how to use it:

ControlClick("My Window", "", "[ID:254]")

But there is no function available (that I can see) in AutoIt that allows you to get the ID. If they are referring to what UISpy calls: "RuntimeId" then this, too, will change every time a program is executed. Which would be fine, if I had a way of getting them and storing it in an internal table or something... but again, I see no function for getting a runtime ID within AutoIt.

Anyone who is running AutoIt against a program that is using a tab control will have the same problem I am seeing. It appears that AutoIt is making an assumption that you are running a program which is a single window full of a static list of controls. But a Tabbed control, or in my case an application that uses only one screen, and changes the controls on them depending on choices, renders all of the control functions unreliable.

Or, so it seems... I am hoping someone tells me I am oh-so-wrong...

Link to comment
Share on other sites

No - you are not crazy :-)

Try the link that SmOke_N posted.

OK, SmOke_N (and 'herewasplato' ) Thanks for helping maintain my sanity...

Interesting script... here's the thing... for speed sake, I have converted my scripts to c# code and am just using the DLL... so, has anyone translated this into a function? (Be nice to add it to the DLL... but even just a class code...)

I can do it... but I figured, hey, if someone already had it done...?

Link to comment
Share on other sites

  • 5 months later...

any suggestions for Instance Number/ID changing each time the application is launched?

i've tried the ControlClick, but does not good if the Instance or ID change.

thanks

ControlClick("Spyware Terminator Center 2.5.1.028", "", "[CLASS:TPicBtn; INSTANCE:102]")
ControlClick("Spyware Terminator Center 2.5.1.028", "", 328500)
ControlClick("Spyware Terminator Center 2.5.1.028", "", "[CLASS:TPicBtn; INSTANCE:96]")
ControlClick("Spyware Terminator Center 2.5.1.028", "", 459608)

Posted Image

Posted Image

Link to comment
Share on other sites

  • 9 years later...

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...