Sign in to follow this  
Followers 0
GSM

Sending Keystrokes to Unactive Programs

23 posts in this topic

Hello everyone.

Not sure how the best way to explain this would be but here goes.

I've been making little programs for friends to make thier lives easier on some games, nothing really big just some bots. I was wondering is there a way to send certain keys to inactive programs. (IE it would be like the game is maximized and you press F1, but it would stay minimized)

Not so much where it would activate the "game" or whatnot and press it then reactivate whatever you were using before hand. Most of these would take a couple seconds to reload the full screen game. So instead of activating it it would just send the keystroke to the program.

Thanks,

GSM

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello everyone.

Not sure how the best way to explain this would be but here goes.

I've been making little programs for friends to make thier lives easier on some games, nothing really big just some bots. I was wondering is there a way to send certain keys to inactive programs. (IE it would be like the game is maximized and you press F1, but it would stay minimized)

Not so much where it would activate the "game" or whatnot and press it then reactivate whatever you were using before hand. Most of these would take a couple seconds to reload the full screen game. So instead of activating it it would just send the keystroke to the program.

Thanks,

GSM

Take a look at HotKeySet() / WinSetState() in the helpfile:

HotKeySet("{F1}", "MinimizeGame")
HotKeySet("{F2}", "RestoreGame")

While 1
;script here
    Sleep(1000)
WEnd

Func MinimizeGame()
    WinSetState("Game Title", "", @SW_MINIMIZE)
EndFunc

Func RestoreGame()
    WinActivate("Game Title")
EndFunc

Edit:

Forgot ['/code] tag!!

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

No I was thinking more like ControlSend() but I can't seem to get it to work with the game. I got the title right but the ControlID I have no clue what to put for it... Even if I just leave it blank it doesn't seem to want to send.

Share this post


Link to post
Share on other sites

No I was thinking more like ControlSend() but I can't seem to get it to work with the game. I got the title right but the ControlID I have no clue what to put for it... Even if I just leave it blank it doesn't seem to want to send.

what game is it?

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

No I was thinking more like ControlSend() but I can't seem to get it to work with the game. I got the title right but the ControlID I have no clue what to put for it... Even if I just leave it blank it doesn't seem to want to send.

Well, you are asking specifically for this... I don't know what your trying to send to the window with control send... are you sending F1?

Dim $Control = 1
HotKeySet("{F1}", "MinimizeGame")
HotKeySet("{F2}", "RestoreGame")

While 1
;script here
    Sleep(1000)
WEnd

Func MinimizeGame()
    While $Control = 1
        If $Control = 1 Then
            If Not BitAnd(WinGetState("Game Title", ""), 16 ) Then WinSetState("Game Title", "", @SW_MINIMIZE)
        EndIf
        Sleep(10)
    Wend
    $Control = 1
EndFunc

Func RestoreGame()
    $Control = 2
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Or if your trying to send a specific key to a window, I guess I'm not understanding why your not using ControlSend() already???

ControlSend("Title", "Text", "ControlID", "{F1}") << if this was what you were after sending F1 to the minimized window... (I don't know if F1 for your game automatically minimizes the window and keeps it down) then there you go... Else, the code I gave you above will work and keep the window minimized until you press the F2 key.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

No I was thinking more like ControlSend() but I can't seem to get it to work with the game. I got the title right but the ControlID I have no clue what to put for it... Even if I just leave it blank it doesn't seem to want to send.

there's a possibility that even with good control send commands, ie:

HotKeySet("{PAUSE}","ICantThinkOfAFunnyFunctionNameImTooTiredAndHaventHadAnyEnergyDrinksTodayButThisIsStillALongOneTh

ough")
while 1
    Sleep(100)
WEnd

Func ICantThinkOfAFunnyFunctionNameImTooTiredAndHaventHadAnyEnergyDrinksTodayButThisIsStillALongOneThough

()
    Run("Notepad")
    ControlSend("Untitled - Notepad",15,"This would go to notepad window regardless of what window is active/maximized")
    Exit
EndFunc

your game may block the keys you're using as hotkeys, preventing the function from ever being called. alot of newer multiplayer games are doing things like this to stop people from using bots. I'd say to check your hotkey first, just have it display a tooltip or something so that you can see the key is working, then work on controlsend.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Couple different games (rose, silkroad and wow)

I know the function is something like

ControlSend("SilkRoad", "", "", "{F1}")

I know when you do this with Notepad it works and the ControlID is Edit1,

but am I suppose to just leave the ControlID blank for the game(s)?

(I know one or two other games I have tried this with have blocked me from other things so it could just be it won't work)

Edited by GSM

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Couple different games (rose, silkroad and wow)

I know the function is something like

ControlSend("SilkRoad", "", "", "{F1}")

I know when you do this with Notepad it works and the ControlID is Edit1,

but am I suppose to just leave the ControlID blank for the game(s)?

blank control id won't work. it's been suggested before, but when it was actually tried, it didn't do anything.

***edit*** when i'm sending to games, typically i'll just winactivate() the game, which makes it the active window regardless of state, then use Send()

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

So, is there a default or anything I could put there? (Edit1 doesn't work either)

Is there a way to keep the game minimized though?

(Trying to get it to run and not disturbe the user as he/she goes about thier business)

Edited by GSM

Share this post


Link to post
Share on other sites

If the game activates itself automatically, then 'ControlSend()' won't work unless you are sending a specific command that that game has set for a hotkey to minimize.

ControlSending keys to a minimized game without a control id in theory would work sometimes, like cameronsdad, I've yet to duplicate this.

Does the applications you want to send to, not have a control id for any area?

There is also a udf called ControlSendPlus() ... Although I'm not entirely sure what it does to be honest, it may be worth doing a search for.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Right, well I have no idea what the ControlIDs would be or how to find out what they are...

Share this post


Link to post
Share on other sites

There's a very cool tool that comes with AutoIt... it's called AutoInfo. That will give you all kinds of information.

Start >> All Programs >> Autoit v3 >> Auto Window Info


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I tried the Auto Window Info but nothing shows up for the Control ID. = /

I also looked for ControlSendPlus() but I can't find the download for it, I mean I found it but it doesn't work.

Share this post


Link to post
Share on other sites

I have been looking for a way to send all keystrokes to a specific window when it is not active and I have not been able to get it to work. I have tried the ControlSend() function with no control Id and the function works but not when the window is no longer the active window. I have been searching all over the fourms to see if anyone has found a way to do this, and I have read the autoit help file up and down :)

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I have been looking for a way to send all keystrokes to a specific window when it is not active and I have not been able to get it to work. I have tried the ControlSend() function with no control Id and the function works but not when the window is no longer the active window. I have been searching all over the fourms to see if anyone has found a way to do this, and I have read the autoit help file up and down :)

@madmax

Are you pulling up every game botting thread that had suggested that you may not be able to automate, and posting in it?

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

@madmax

Are you pulling up every game botting thread that had suggested that you may not be able to automate, and posting in it?

I have been reading all botting threads. Not sure what you are getting at or how your comment has anything to do with what has been asked in this thread. But yes I have been posting in bot threads. I have created my bot and it is working fine. I just want to find a way to send keystrokes to the window when it is not active. This is for the case of ppl running the game in window mode.

I guess I will keep making the window active for now. But I want to find a way to send to non-active windows.

Thx

:)

Edited by madmax

Share this post


Link to post
Share on other sites

@madmax

Are you pulling up every game botting thread that had suggested that you may not be able to automate, and posting in it?

Were you suggesting, I go post in all bot threads and see if I find someone who has figured out how to do the action I want to do? If so, I am sorry didn't mean to be asmart ass :)

Share this post


Link to post
Share on other sites

I have been reading all botting threads. Not sure what you are getting at or how your comment has anything to do with what has been asked in this thread. But yes I have been posting in bot threads. I have created my bot and it is working fine. I just want to find a way to send keystrokes to the window when it is not active. This is for the case of ppl running the game in window mode.

I guess I will keep making the window active for now. But I want to find a way to send to non-active windows.

Thx

:)

Wouldn't making your own thread make more sense then running through every botting post that had a specific question asked that you want to know the answer to, and posting to it? That's no better than spamming.

Were you suggesting, I go post in all bot threads and see if I find someone who has figured out how to do the action I want to do? If so, I am sorry didn't mean to be asmart ass :D

Smart ass? I took it quite the opposite! See ... someone smart wouldn't be bringing up 13 month old posts.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

He wouldnt be suggesting, Note, The question mark.

Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

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