pranaynanda

AutoIt Script language errors and help with window info tool

20 posts in this topic

#1 ·  Posted (edited)

1. I have a script that was running fine until earlier today. I needed to make some modifications so I did them. The problem however came when I was trying to do this something as simple as this:

If
;code
;code
;code
;code
;code
Else
;code
;code
;code
;code
EndIf

The Scite editor could not differentiate between If and else statement (because I could see it is splitting the scope for both) and kept returning errors like the If has no EndIf and an Else cannot be declared without an If. That's when I clicked on the Language menu button and clicked on AutoIt3 (it was already AutoIt but I did that just to be sure). After that even a simple statement like $StartTime=TimerInit() was giving a syntax error and the similar thing happened to all the variables close to it. And the points where those variables were being used, the error was like they have been used before they have been declared and I didn't even move a hair. The variables were declared before they were used. Now the code does not work.

2. Also, I was using the Window Info tool but it could not identify the text that was visible to me. It was not coming up in the visible text or the hidden text.

3. I can't seem to understand the difference between Opt("PixelCoordMode", 0) and Opt("PixelCoordMode", 2). Also I cannot understand the same with Opt("GUICoordMode", 0) and Opt("PixelCoordMode", 2). How does the PixelCoordMode differ from GUICoordMode?

Edited by pranaynanda

Share this post


Link to post
Share on other sites



12 minutes ago, pranaynanda said:

... was running fine until earlier today ...

you messed up your script, and SciTE is not to blame. restore from backup and start introducing your changes, more carefully this time, building scopes one at a time.

15 minutes ago, pranaynanda said:

... Window Info tool but it could not identify the text that was visible to me ...

yes, that happens. the text may be wrapped in another type of control, typically seen in Java or other widget platform. what do you DO know about the window you try to automate? classes? controls?

18 minutes ago, pranaynanda said:

the difference between Opt("PixelCoordMode", 0) and Opt("PixelCoordMode", 2)

the "client area" is the area of the window excluding the title bar, window edges, scroll bars, status bar, menu bar, and perhaps other elements which i forget.

as for GUICoordMode - i never used it, so i cannot offer any assistance except you run the examples in both modes and see the difference for yourself.

Share this post


Link to post
Share on other sites
8 minutes ago, orbs said:

you messed up your script

No mess up man. It was just a simple if ... do ... until ..else..do..until.. endif thing on the code that was working previously. Somehow it is working now, don't ask me how cuz I don't know.

8 minutes ago, orbs said:

what do you DO know about the window you try to automate? classes? controls?

For the second part, the control is a canvas and the class is a window.

9 minutes ago, orbs said:

the "client area" is the area of the window excluding the title bar, window edges, scroll bars, status bar, menu bar, and perhaps other elements which i forget.

For the third part, the control is pretty much a window. within the main window.

Share this post


Link to post
Share on other sites
13 minutes ago, pranaynanda said:

the control is a canvas

the canvas control is just a placeholder on which you can put other controls (such as labels with text) in a desired arrangement. it does not have a text property of its own. so investigate further into that control. can you post a screenshot?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Cant post a screenshot but the canvas has a Treeview. And that's where I want it to read. You're right about one thing that it is most likely Java.

Edited by pranaynanda

Share this post


Link to post
Share on other sites

 

 

Share this post


Link to post
Share on other sites

Thank you for that. Btw, what is a SunAwtCanvas?

Share this post


Link to post
Share on other sites
2 minutes ago, pranaynanda said:

what is a SunAwtCanvas?

that is a custom Java canvas control. it operates in a similar way to the Windows canvas control, except it's built by Java and used to host Java controls. you cannot interact with it as you do with Windows controls.

Share this post


Link to post
Share on other sites

So that is exactly what I'm trying to do. So should I accept that it can't be done now? All I wanted to shift the focus to that control no matter whatever gets explicitly selected. I tried ControlFocus but it didn't do the job.

Share this post


Link to post
Share on other sites
3 minutes ago, pranaynanda said:

So should I accept that it can't be done now? 

You should accept that without showing the window, or giving any more information than you have, that no one is going to be able to magically divine what you are trying to accomplish and fix it for you. We need the name of the application you're trying to manipulate, or a screenshot of the window at the very least, in order to suggest options. Help us help you.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

18 minutes ago, pranaynanda said:

... All I wanted to shift the focus to that control ...

can you do that by simulating key press? for example, most windows allow the TAB key to rotate focus between elements. if you can activate the window and send some TABs, you may be able to do what you want.

but then, why are you doing that? just shifting focus to an element is hardly useful. eventually, you'll want to operate on the element, right? think forward a bit to see where that gets you.

Edited by orbs

Share this post


Link to post
Share on other sites
17 minutes ago, orbs said:

but then, why are you doing that? just shifting focus to an element is hardly useful. eventually, you'll want to operate on the element, right? think forward a bit to see where that gets you.

 

It's actually a bot that does a performance test on our CAD based application. I want to shift the focus there just to reassure that the control has the focus. Sometimes, the window wouldn't load properly in time and the actions taken place will be as the other control.

TAB was a great idea the application doesn't work that way.

Is there by any chance possible that the same control loaded in a window every time has a different instance ID every time?

Share this post


Link to post
Share on other sites
3 minutes ago, pranaynanda said:

Is there by any chance possible that the same control loaded in a window every time has a different instance ID every time?

yes that is possible.

another suggestion: if you can WinMove() the entire application window to a prefixed size and position, then most likely the control in question will have the same coordinates on screen, then MouseClick() that coordinates may work.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Okay, I'm somewhat in it. So, now the story is that to debug, I used a messagebox to confirm whether ControlFocus was doing it right or not. Surprisingly, I've found out that if I use the message box the script great. But if I don't use the message box, I'm back to start. Any suggestions on how to interpret this?

Edit:

P.S: Is there any way I can get a list of all the handles that exist in a window?

Another Edit: I can get it to work without the message box on Window type of control. I can't get the same on that canvas.

Another observable thing is that the focus does not go at once for that canvas, it has to be shifted somewhere to so that when it gets back the focus is on the right object.

Edited by pranaynanda

Share this post


Link to post
Share on other sites

Guys, I've tried WinActivate, ControlFocus, and ControlClick. Nothing has worked so far. I just want to ensure that an element has focus so that the code following runs as desired. The object is SunAwtCanvas. I don't want to use MouseClick() because it will interfere with other processes.

Share this post


Link to post
Share on other sites

As was stated pretty clearly in post #8 of this thread, you are not going to be able to interact with the controls on a Java window the same as you would a normal window. There is a Java UDF out there if you do a forum search, though I don't know the range of its capabilities. 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

That didn't help but thanks! I would be more than happy if you could suggest me on something. The control that I'm trying to bring focus to works perfectly on other 8 machines except for the one that has the trouble. We've tried reinstalling the application a couple of times but that hasn't helped. To tell you again what it is all about, We have a bot that calculates performance on our CAD application using TimeDiff(). One of our machines is facing a trouble with getting the right focus. It cannot be an application issue as the same setup works same across the globe. It is not even a AutoIt issue has the scripts do the job perfect everywhere else. To ensure that the control gets focus, I've tried  WinActivate, ControlFocus, and ControlClick. Can you please suggest me where the problem could be?

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

27 minutes ago, pranaynanda said:

Can you please suggest me where the problem could be?

probably you insisting on being perfect, where good enough is good enough. so you have 8 machines giving you performance stats, why insist on the 9th? when you analyze the stats, is the standard deviation too large to require additional data? if so, would another one help in any way? i doubt it (actually i don't doubt it, i know it won't).

also, for those 8 machines, how can you trust the control actually got focus? if you issue a command to set focus to a control - whatever method that would be - you need to get feedback, that is to read the control status to verify it got the focus. otherwise it's just guessing.

and yet another aspect - here you perform "performance" test on to the GUI, not on the engine. it may be better to test for milestone not by the GUI, but by a more direct condition - for example, when an output file is produced, or when the CPU usage of the process is drastically reduced, etc.

EDIT: perhaps your program supports pre-process and post-process custom commands?

Edited by orbs

Share this post


Link to post
Share on other sites

Most probably you might not have completed the "previous if statement". Please check it once. 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

@orbs thanks man! I would like to justify it by telling that when I do ControlClick(), it does not work whereas MouseClick() works.

EDIT: Can I know why is that MouseClick() works and ControlClick() does not?

Edited by pranaynanda

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