Jump to content

AutoIt Script language errors and help with window info tool


Recommended Posts

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

Link to comment
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?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

 

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

Link to comment
Share on other sites

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

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

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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?

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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. 

"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 comment
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?

Link to comment
Share on other sites

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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