sending key to a window not very responsive

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
conner

sending key to a window not very responsive

Post by conner » Thu Apr 08, 2004 5:42 pm

Hi. Although I did set focus to a specific window, sending keys to imitate the pressing of keys on a keyboard doesn't seem to be very responsive. For example, when I send key "q" while in a window, it make take it up to 5 tries and above, sometimes doesn't even register, before q is recognized in the program.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Apr 08, 2004 9:26 pm

Really!? This is a new one on me. Please post a copy of your script and we'll see what might need changing to make it work reliably. Could just need a bit longer for the window to be ready before it can accept keyboard input.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Apr 08, 2004 11:29 pm

Have you tried using WaitReady> ?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Fri Apr 09, 2004 12:56 am

Your dsecribed scenario occurs sometimes. In the absence of a sample script (the problematic portion), no one can offer you a meaningful solution.

SetFocus won't take immediate effect especially in outlook 2003. Bob's solution usually works fine.

Happy scripting.

jalbt51
Junior Coder
Posts: 31
Joined: Sat Mar 06, 2004 4:40 pm

Post by jalbt51 » Sun Apr 11, 2004 2:27 pm

re: the issue of waiting long enough after opening or setting focus to a window- would the right way be

first: SetFocus>window_title
WaitReady>

or second: WaitReady>
SetFocus>window_title
??
Thanks again for all the help jalbt51

PS the reason I ask such a basic question is that sometimes the wrong way WILL work Then one, thinking that the wrong way is the right way, will write faulty script that will cause a more important application later to crash.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Apr 11, 2004 4:16 pm

I am sure you are opening up a debate here, which will be good for all of us.
As noted on an earlier posting today, these are my normal sequences:
WaitWindowOpen>WindowName*
SetFocus>WindowName*
WaitReady>1
I also have SK_DELAY=10 vs. default of 0.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Apr 11, 2004 6:49 pm

Hi jalbt51,

There's no magic answer to your question. It all depends upon the actual situation. To help choose the right approach, you have to ask the following questions:
1. Will the script run without any intervention?
2. What kind of application? The script will be coded differently for MathCAD, ClipMagic, FileMaker, and Office Outlook 2003. For example, for Outlook 2003, SetFocus> takes relatively longer than ClipMagic to succeed.
3. Are there other applications running simultaneously?
4. How fast is your computer? The script intended for Pentium 3.4GHz with HT will be different than the one for AMD 300MHz.

If Microsoft Paint is the only application running, no SetFocus> is necessary.

For maximum assurance that the desired window is properly opend, I prefer GetRectCheckSum>. The disadvantage of using GetRectCheckSum> is it's relatively slow.

Good luck and happy scripting.

jalbt51
Junior Coder
Posts: 31
Joined: Sat Mar 06, 2004 4:40 pm

Post by jalbt51 » Tue Apr 13, 2004 7:19 pm

About the original send key question: I've that found the following sort of thing works in Windows Paint.


Press CTRL
Send>v,r
wait>0.15
Release CTRL
SetFocus>Resize/Resample image*
wait>0.07

This particular one opens the resize dialog window in an already open IrfanView window
(there has to be an opened picture ready). The waits can be short(it depends on how busy and how fast your system is), but they do need to be there. Virtual events take longer. WHATEVER you do turn off those darn transition effects at DisplayProperties, Effects, use transition effects...

As far as WaitReady> goes, you'll have to ask the experts.
jalbt51

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts