| View previous topic :: View next topic |
| Author |
Message |
pr1nce
Joined: 25 Oct 2009 Posts: 3
|
Posted: Sun Oct 25, 2009 12:30 am Post subject: Send repeated keys to a fullscreen game |
|
|
Hi
I need a script that automatically sends repeated keys to an active game with a delay between the keys.
Heres the whole deal. In the game I play you can shovel and possibly get items from shoveling. I put the shovel in the quickslot 3 so whenever I press 3 it digs and the "Pick-Up" action in quickslot 2.
I need the script to press "3" and then "2" 8 seconds later and then start the loop again. All this automatic, but it could have a start key if necessary.
| Code: | Loop 6000
{
Send {3 down} {3 up}
Sleep 8000
Send {2 down} {2 up}
} |
This is the code I wrote and it worked like a charm one time. But ever since it doesn't work. I run AutoHotKey and then maximize the game and nothing happens.
I checked by putting the game down and opened AHK window and the script runs fine, it just doesn't reflect in-game for x reason.
If you can help it would be appreciated or point me to another forum thred that gives better steps. I already searched and couldn't find it. If you need more info I'll be around.
Thank you. |
|
| Back to top |
|
 |
tekkie2412
Joined: 22 May 2007 Posts: 73
|
Posted: Sun Oct 25, 2009 3:23 am Post subject: |
|
|
| Code: |
Loop,
{
SetTitleMatchMode, 2
IfWinActive, GameTitle ;Replace GameTitle with the title name of the game
Send, 3
Sleep, 200
Send, 2
Sleep, 200
}
|
|
|
| Back to top |
|
 |
pr1nce
Joined: 25 Oct 2009 Posts: 3
|
Posted: Sun Oct 25, 2009 4:28 am Post subject: |
|
|
I just tried that and it didnt work at all.
What it did is it kept pressing 2 every second or so.
When I enter the game title should I put it as written at the bottom in the windows bar on the game or the .exe name?
Thx again |
|
| Back to top |
|
 |
tekkie2412
Joined: 22 May 2007 Posts: 73
|
Posted: Sun Oct 25, 2009 6:50 am Post subject: |
|
|
Put whats written in the window bar. Try enclosing the If in brackets also, not sure if it will make a difference in this case.
| Code: |
Loop,
{
SetTitleMatchMode, 2
IfWinActive, GameTitle ;Replace GameTitle with the title name of the game
{
Send, 3
Sleep, 200
Send, 2
Sleep, 200
}
}
|
|
|
| Back to top |
|
 |
Scratch
Joined: 22 Jan 2009 Posts: 72
|
Posted: Sun Oct 25, 2009 2:35 pm Post subject: Full Screen Keys |
|
|
Try Sendplay instead of Send ?
Perhaps the game has a low level keyboard hook...
From the AHK Docs:
"
SendPlay's biggest advantage is its ability to "play back" keystrokes and mouse clicks in a broader variety of games than the other modes. For example, a particular game may accept hotstrings only when they have the SendPlay option.
Of the three sending modes, SendPlay is the most unusual because it does not simulate keystrokes and mouse clicks per se. Instead, it creates a series of events (messages) that flow directly to the active window (similar to ControlSend, but at a lower level).
" |
|
| Back to top |
|
 |
pr1nce
Joined: 25 Oct 2009 Posts: 3
|
Posted: Sun Oct 25, 2009 5:12 pm Post subject: |
|
|
Thank you tekkie the last one worked very well. I did have to put a bracket in front of IfWinActive and then it worked perfectly thanks a lot.
**EDIT**
For some odd reason, each script only works once. When I restart the game and the script it doesnt work anymore. The same script int he same situation.
Problem with the program or is it on the game side? |
|
| Back to top |
|
 |
|