Jump to content

Focus/timing conflicts with other OS driven applications


Recommended Posts

Hello,

I'm new to AutoIt programming language and I'm writing some photographs computation program with it.

I chose AutoIt because this program needs to get various data from other programs that I can't drive in other ways than keyboards/mouse events programming.

At the time, result is good, but this application is not robust at all : when program is running, mouse pointer is moving on the screen, keyboard inputs are auto-typed and so on, but execution falls in no man's land when program is disturbed by some other OS driven event (another program pop-up, firewall warning, ...), that steals focus to active window.

So I'm thinking of 2 solutions to solve this :

1/ have a thread that protect the program active window focus to be lost (that means that I can't do no other action on my computer when program is running).

2/ putting the program alone in some virtual machine, that would have independent keyboard, mouse and focus events (that's maybe not possible).

More generally, I get other problems caused by overall system/OS health : sometimes, computer is slowing down a little, so that some events that I send to OS applications aren't well-executed, even if I use timing operations (WinWaitActive(), Sleep(), ...).

This problematic is so present in AutoIt event programming that I would be surprised if no other topic yet deal with it. Unfortunately, my english is not so good, and I can't find really good related posts using the forum search function.

Just for fun, and I hope it will be understood as a compliment, I held AutoIt as :

- great work for the team which builds this tool, since it must not be easy to allow those special interactions with Windows OS.

- great path to get results nearly unreachable with other programming ways.

- weak applications building, since events are too much OS/system state dependent (timing problems).

- baby coding :D

Finally, yeah, AutoIt is very cool stuff :)

Hope you can give me some piece of information or point me to related topics, see you.

Edited by TheMaskedCucumbus
Link to comment
Share on other sites

Sounds like you basic problem is assuming that a window will stay the focus of the desktop while the script runs. There are better ways. For example, use ControlSend() instead of Send(). ControlSend() will work on a control without assuming focus, Send() won't.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Try to use ControlSend() ControlClick(), ControlSetText() ControlGetText() WinMenuSelectItem(), ... instead of Send()

and WinWait() instead WinWaitActive() after Run()

This way you may have your script resistive against another active windows.

I also recoded one of my script by above listed rules to achieve possibility to run script from scheduler on locked Windows station.

In Windows locked state applications runs hidden and haven't focus and active status.

Link to comment
Share on other sites

  • 7 months later...

Try to use ControlSend() ControlClick(), ControlSetText() ControlGetText() WinMenuSelectItem(), ... instead of Send()

and WinWait() instead WinWaitActive() after Run()

This way you may have your script resistive against another active windows.

I also recoded one of my script by above listed rules to achieve possibility to run script from scheduler on locked Windows station.

In Windows locked state applications runs hidden and haven't focus and active status.

I'm dealing with this exact issue. All works great when I'm actively on the Terminal Server session. However, if it's minimized (or disconnected), it doesn't work.

I was originally using SEND(), but tried to switch to ControlSend(), based upong this thread/posting. I'm having a difficult time getting it to work, and I think it's because of how the silly CLASS is named by this application. I'm curious if the embedded colons are the problem?

The Class is: Afx:3ae0000:8:10003:0:0

The Instance is: 4

The ClassnameNN is: Afx:3ae0000:8:10003:0:04

It seems like NOTHING I try related to this control works.

I'm simply trying to select a certain menu option within this application. However, WinMenuSelectItem() does NOT work, as I'm guessing this application does NOT use Standard menus (as warned in the WinMenuSelectItem() help info).

All I can ever get to go through is the ALT to activate the menu system, but NO keystrokes ever go through the application from that point forward. I've tried every alternative I can come up with, to no avail.

When using ControlSend(), I don't even have to specific a CONTROL, and the ALT "activates" the menus, as desired. However, I CANNOT get ANYTHING else to work.

The normal keystrokes for this menu are ALT-T (to activate the Tools menu) and then E and S. E is the sub-menu option and S is the actual item being selected.

This works GREAT when actively watching:

Send("!tes")

I've tried BOTH entering the keystrokes (TES) and entering cursor controls (right, down, etc., once the menus are activated). No luck.

Some things I've tried:

ControlSend("FrontRange GoldMine Premium Edition","","Afx:3ae0000:8:10003:0:04","!tes")

ControlSend("FrontRange GoldMine Premium Edition","","[CLASSNN:Afx:3ae0000:8:10003:0:04]","!tes")

ControlSend("FrontRange GoldMine Premium Edition","","[CLASS:Afx:3ae0000:8:10003:0:0;INSTANCE:4]","!tes")

ControlSend("FrontRange GoldMine Premium Edition","","[TEXT:Menu Bar]","!tes")

I've altered the "!tes" in multiple ways, again, with no success.

Any and all help would be greatly appreciated. Thanks in advance.

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