AutoHotkey Community

It is currently May 26th, 2012, 9:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: June 30th, 2009, 11:57 pm 
Hello, firstly I would like to congratulate you and thank you for making such a wonderful, free program.

Secondly, I would like to ask please, if there is a way to set a delay between keys entered by the script in milliseconds?

I play CSS and the server requires that you type guns into chat in order to select your weapons. I would like to automate this by binding the entire process to the one of the two buttons on the left of my mouse (Razer Deathadder).

This is what I have so far:

XButton1::Send,yguns{ENTER}1393

This would work, but there needs to be a time gap between 'y' (brings up chat) being entered, 'guns' being entered, 'enter' being entered-lol, and '1', '2' and '3' being entered.

Thank you.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 12:05 am 
http://www.autohotkey.com/docs/commands/Sleep.htm


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 12:33 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
SetKeyDelay

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 12:52 am 
Thank you so much.

This is how it looks, it seems to work inconsistently.. Not sure why.

XButton1::
Send,y
Sleep,5
Send,guns
Sleep,5
Send,{ENTER}
Sleep,42
Send,1
Sleep,41
Send,3
Sleep,48
Send,9
Sleep,39
Send,3
Sleep,11


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 1:32 am 
Offline

Joined: June 28th, 2007, 1:08 am
Posts: 662
Please use the code tags when posting.

Your inconsistency may be due to server load at the time of your request, therefore taking more than your allotted time between sending {Enter} and the next commands.

If I read it correctly, you are sending a series of commands that interact directly with the server, so issues such as ping and server load will effect how much delay would be required and you would have a fairly low consistency during the course of a single match.

Going off of your values, I would say your average response time is between 30 and 60ms. Try increasing the delays where the server has to respond until you have an acceptable success rate.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 3:20 am 
Thank you very much, trying your suggestion now! Why didn't I think about server response times before?!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 3:33 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Since you seem to be using some very small Sleep times I thought it'd be worthwhile to point this out:

Due to the granularity of the OS's time-keeping system, Delay is typically rounded up to the nearest multiple of 10 or 15.6 milliseconds (depending on the type of hardware and drivers installed). For example, a delay between 1 and 10 (inclusive) is equivalent to 10 or 15.6 on most Windows NT/2000/XP systems.


So in those spots where you're using a very small delay it's meaningless to a certain extent. Also you can avoid stacking a bunch of Sleep commands in your script and condense things down if you use SetKeyDelay:


Code:
XButton1::
SetKeyDelay, 50, 25 ; delay between keystrokes of 50ms with a keypress duration of 25ms
Send yguns{ENTER}1393

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 4:25 am 
Offline

Joined: June 14th, 2009, 7:48 pm
Posts: 331
[size=150]Sheepdisease[/size] wrote:
Why didn't I think about server response times before?!



:D :P :oops: :lol:

uıɐɹq ɹnoʎ pǝƃɐɯɐp ǝsɐǝsıpdǝǝɥs ǝɥʇ ǝsnɐɔǝq : ɹǝʍsuɐ

:D :P :oops: :lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 10:55 am 
awannaknow wrote:
[size=150]Sheepdisease[/size] wrote:
Why didn't I think about server response times before?!



:D :P :oops: :lol:

uıɐɹq ɹnoʎ pǝƃɐɯɐp ǝsɐǝsıpdǝǝɥs ǝɥʇ ǝsnɐɔǝq : ɹǝʍsuɐ

:D :P :oops: :lol:


Haha!

sinkfaze wrote:
Since you seem to be using some very small Sleep times I thought it'd be worthwhile to point this out:

Due to the granularity of the OS's time-keeping system, Delay is typically rounded up to the nearest multiple of 10 or 15.6 milliseconds (depending on the type of hardware and drivers installed). For example, a delay between 1 and 10 (inclusive) is equivalent to 10 or 15.6 on most Windows NT/2000/XP systems.


So in those spots where you're using a very small delay it's meaningless to a certain extent. Also you can avoid stacking a bunch of Sleep commands in your script and condense things down if you use SetKeyDelay:


Code:
XButton1::
SetKeyDelay, 50, 25 ; delay between keystrokes of 50ms with a keypress duration of 25ms
Send yguns{ENTER}1393


Wow, thank you for the tidy script. That looks much nicer. Is there a way to set up multiple functions in the same script? For instance, can I also set up some bindings to the home, end and pause keys to control windows media player? Like for instance, if I wanted to go to the previous song using the 'home' key, whilst I am in-game, how would I go about doing this? I just tries what I thought would work, but it complained about the original script that I have already posted (am using the new one now). Then I want the 'end' key to act as trigger for next song. Then the same goes for 'pause', which will obviously be used to pause and unpause the music.

Thank you all so very much for your help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 11:15 am 
Offline

Joined: March 27th, 2009, 1:00 am
Posts: 26
If you have a multimedia keyboard you could do something like

Code:
Home::
Send {Media_Prev}
return


Remember to add a return after your xbutton1:: code too if you're going to add this to your script.


Look in the help file under "List of Keys, Mouse Buttons, and Joystick Controls" for more media/hotkey information.


You can also do it with http://wmpkeys.sourceforge.net/.

Good luck.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 11:47 am 
Offline

Joined: June 30th, 2009, 11:51 pm
Posts: 4
In addition to that, how about sending a left mouse click?

I think it would be something like this:

XButton2::
SetKeyDelay, 50, 25
Send yguns{ENTER}13934
Send MouseClick LButton


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 12:01 pm 
Offline

Joined: March 27th, 2009, 1:00 am
Posts: 26
Code:
MouseClick [, WhichButton , X, Y, ClickCount, Speed, D|U, R]


The bracketed parameters are optional and the default is left. So all you really need is...

Code:
XButton2::
SetKeyDelay, 50, 25
Send yguns{ENTER}13934
MouseClick
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 3:50 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Dozerdog wrote:
In addition to that, how about sending a left mouse click?


Code:
/*
See these links:
http://www.autohotkey.com/docs/commands/Click.htm http://www.autohotkey.com/docs/commands/Send.htm#Click
*/
XButton2::
SetKeyDelay, 50, 25
Send yguns{ENTER}13934{Click}
return

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 8:20 pm 
Offline

Joined: June 30th, 2009, 11:51 pm
Posts: 4
Thank you both very much!

Is it normal that executing one command seems to execute all in the list?

This is the script:

XButton1::
SetKeyDelay, 50, 25
Send yguns{ENTER}1393

XButton2::
SetKeyDelay, 50, 25
Send yguns{ENTER}13934{Click}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2009, 8:36 pm 
Offline

Joined: June 28th, 2007, 1:08 am
Posts: 662
Place return after the first command

Code:
XButton1::
SetKeyDelay, 50, 25
Send yguns{ENTER}1393
Return

XButton2::
SetKeyDelay, 50, 25
Send yguns{ENTER}13934{Click}
return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], Google Feedfetcher, krajan, oldbrother, Yahoo [Bot] and 64 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