 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sheepdisease Guest
|
Posted: Tue Jun 30, 2009 10:57 pm Post subject: Brilliant program, please help me configure a script? |
|
|
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. |
|
| Back to top |
|
 |
Z_Gecko Guest
|
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
|
| Back to top |
|
 |
Sheepdisease Guest
|
Posted: Tue Jun 30, 2009 11:52 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Elesar
Joined: 28 Jun 2007 Posts: 622 Location: Somewhere around 35 12N 101 49W
|
Posted: Wed Jul 01, 2009 12:32 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Sheepdisease Guest
|
Posted: Wed Jul 01, 2009 2:20 am Post subject: |
|
|
| Thank you very much, trying your suggestion now! Why didn't I think about server response times before?! |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Jul 01, 2009 2:33 am Post subject: |
|
|
Since you seem to be using some very small Sleep times I thought it'd be worthwhile to point this out:
| Sleep - Remarks wrote: | | 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 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
awannaknow
Joined: 14 Jun 2009 Posts: 324
|
Posted: Wed Jul 01, 2009 3:25 am Post subject: |
|
|
| Sheepdisease wrote: | | Why didn't I think about server response times before?! |
uıɐɹq ɹnoʎ pǝƃɐɯɐp ǝsɐǝsıpdǝǝɥs ǝɥʇ ǝsnɐɔǝq : ɹǝʍsuɐ
 |
|
| Back to top |
|
 |
Sheepdisease Guest
|
Posted: Wed Jul 01, 2009 9:55 am Post subject: |
|
|
| awannaknow wrote: | | Sheepdisease wrote: | | Why didn't I think about server response times before?! |
uıɐɹq ɹnoʎ pǝƃɐɯɐp ǝsɐǝsıpdǝǝɥs ǝɥʇ ǝsnɐɔǝq : ɹǝʍsuɐ
 |
Haha!
| sinkfaze wrote: | Since you seem to be using some very small Sleep times I thought it'd be worthwhile to point this out:
| Sleep - Remarks wrote: | | 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. |
|
| Back to top |
|
 |
Astrognaw
Joined: 27 Mar 2009 Posts: 26
|
Posted: Wed Jul 01, 2009 10:15 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Dozerdog
Joined: 30 Jun 2009 Posts: 4
|
Posted: Wed Jul 01, 2009 10:47 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Astrognaw
Joined: 27 Mar 2009 Posts: 26
|
Posted: Wed Jul 01, 2009 11:01 am Post subject: |
|
|
| 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 |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Jul 01, 2009 2:50 pm Post subject: |
|
|
| 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 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Dozerdog
Joined: 30 Jun 2009 Posts: 4
|
Posted: Wed Jul 01, 2009 7:20 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Elesar
Joined: 28 Jun 2007 Posts: 622 Location: Somewhere around 35 12N 101 49W
|
Posted: Wed Jul 01, 2009 7:36 pm Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|