Sign in to follow this  
Followers 0
Guest KimNg

How to "Send" keystroke to minimized window

14 posts in this topic

Hi,

I am new to AutoIt. While creating my first script, I ran across a problem. I could not find any way in the documentation to send keystrokes to an inactive or minimized window without making it active.

I got around it by first activating the window, sent the keystrokes and minimized it again. This, however, is risky and cumbersome. I may accidentally send unintended keystrokes such as when I was typing in another window and the script was activated after "Sleep".

I would like to be able to use some variation of the "Send" command to send the keystrokes to the windows without having to activate it. You have the command to get the handle of the window. So, all we need is a variation of that command which specifies the target handle for the keystroke(s) without activating the window. This would be a lot safer for those who ran the script in the background and do other works in the foreground.

If you have that command already or a better workaround, please let me know what it is and where I can find it.

Thank you very much for your time.

Regards,

Kim

Share this post


Link to post
Share on other sites



If there is a specific control on the inactive form that you need to communicate with you can look at the Control* functions specifically ControlSend.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

check out the helpsection about Controls :

ControlSend ( "title", "text", "classnameNN", "string" [, flag] )

EDIT: how much more help can you get with a few minutes ??? :)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi guys,

Thanks for the speedy replies.

I just tried using "ControlSend" but it does not work. I put MsgBox just before sending the "ControlSend" to make sure I was running the right script and it was at the right spot. I guess the "Send" command is more generic/system-wide than "ControlSend".

It is for a game which uses its own custom control. I used the "AU3_Spy" but did not get anything useful except for the xy coordinates and pixel color. Even the buttons in the game did not register as controls.

I just searched through and read this forum and I guess I am stuck with activating the window before sending the string and then minimizing it. It seemed a few others wanted the same functionality. Hopefully, the developers can add this functionality to the "Send" command in the future.

Also, I would like to be able to use window handle rather than window title (i.e. after using the command to get the handle). That way, I can be assured of which window the string is going to be sent to especially if I have multiple windows of the same application (the other windows being opened after the first window and the script were started making the script unique to the first window). Also, using handle makes the script cleaner. I can get the handle at the top of the script. So, any changes to the Title or Text need to be done only at the line that gets the handle. Right now, I get around that by assigning the Title to a variable and use that variable whenever the Title is needed.

BTW: don't get me wrong. This is a great program. I like it.

Again, thank you very much for the help. If anyone has other suggestions, please let me know.

Thank you & have fun.

Kim Ng

Share this post


Link to post
Share on other sites

You can using handles. Check here WinTitleMatchMode=4

and Wingethandle here.

ControlSend works only in standard MS controls, if your application don't use them there is no know way to access them when without focus.

Share this post


Link to post
Share on other sites

Hi ezzetabi;

Thank you for the tip. I re-read the documentation for the handle stuff and tried it. It works exactly like I wanted. Thank you very much for your help.

Now, if only I can send keystrokes with the windows minimized (for non-standard controls) then I am set. <grin>

Have fun,

Kim Ng

Share this post


Link to post
Share on other sites

Just wondering, is your name Kim Nyguen?

Share this post


Link to post
Share on other sites

Just wondering, is your name Kim Nyguen?

<{POST_SNAPBACK}>

Nope.

Share this post


Link to post
Share on other sites

Hey there devs, on this note, I was wondering if you could add PostMessage controls to autoit's wide variety of functions? PostMessage is a great way to activate and command controls for non visible windows. Things like winamp can easily be controlled without being activated

I found out all the usages of PostMessage from AutoHotKey here

I have found it useful for a great deal of applications where ControlSend just doesn't work. Once you get the hang of it, it's a huge help :)

Thanks

Share this post


Link to post
Share on other sites

Hey there devs, on this note, I was wondering if you could add PostMessage controls to autoit's wide variety of functions? PostMessage is a great way to activate and command controls for non visible windows. Things like winamp can easily be controlled without being activated

I found out all the usages of PostMessage from AutoHotKey here

I have found it useful for a great deal of applications where ControlSend just doesn't work. Once you get the hang of it, it's a huge help  :)

Thanks

<{POST_SNAPBACK}>

Its on the ToDO list .... http://www.autoitscript.com/forum/index.php?showtopic=898

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hey, thats great!

Edited by Trancexually

Share this post


Link to post
Share on other sites

Since a couple of version this is untrue.

It is undocumented but in every WinTitleMatchMode you can use the HANDLES as usual wintitles! So handle= is unneeded now!

Thanks Jon!

You can using handles. Check here WinTitleMatchMode=4

Share this post


Link to post
Share on other sites

You can also do SendMesage (and I think PostbMessage) using DllCall with the unstable.


Who else would I be?

Share this post


Link to post
Share on other sites

Can you give me an example script ? I would like to see it

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  
Followers 0