Jump to content
Sign in to follow this  
TheMaskedCucumbus

Focus/timing conflicts with other OS driven applications

Recommended Posts

TheMaskedCucumbus

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Zedna

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.

Share this post


Link to post
Share on other sites
TheMaskedCucumbus

Ok, thanks for trick :)

I won't work on this app in the next few days, but I'll get back to you when I'll have modified source code to make it more robust/OS events independent.

Edited by TheMaskedCucumbus

Share this post


Link to post
Share on other sites
JohnN

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.