AutoHotkey Community

It is currently May 26th, 2012, 10:20 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: October 25th, 2009, 1:30 am 
Offline

Joined: October 25th, 2009, 1:17 am
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 4:23 am 
Offline

Joined: May 22nd, 2007, 1:06 am
Posts: 73
Code:
Loop,
{
SetTitleMatchMode, 2
IfWinActive, GameTitle ;Replace GameTitle with the title name of the game
Send, 3
Sleep, 200
Send, 2
Sleep, 200
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 5:28 am 
Offline

Joined: October 25th, 2009, 1:17 am
Posts: 3
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 7:50 am 
Offline

Joined: May 22nd, 2007, 1:06 am
Posts: 73
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
}
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Full Screen Keys
PostPosted: October 25th, 2009, 3:35 pm 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
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).

"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 6:12 pm 
Offline

Joined: October 25th, 2009, 1:17 am
Posts: 3
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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, JSLover, Leef_me, patgenn123, rbrtryn, XstatyK and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group