Sign in to follow this  
Followers 0
MarkJoel60

ControlSend Problem: Instance Number CHANGES

9 posts in this topic

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!)

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

How about the control location, is it always the same? That's another semi-reliable identification method :P

Share this post


Link to post
Share on other sites

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

No - you are not crazy :-)

Try the link that SmOke_N posted.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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...?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

You did not say if you had tried the info presented in post #5 of this thread.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


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
Sign in to follow this  
Followers 0