Jump to content

How to "Send" keystroke to minimized window


Guest KimNg
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

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

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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