infinitenight Posted November 3, 2007 Share Posted November 3, 2007 I've never written a macro before so bare with whatever obvious mistakes I may have made here... Basically the macro I have created so far just hits 4 keys (7,8,9,0) every 8.1 seconds. Works well enough, but I would like to modify this so that I can toggle this on and off with a hotkey. What I've got so far: HotKeySet("`","Twist") Func Twist() $loop = 0 While $loop = 0 Sleep(8100) Send("7") Sleep(100) Send("8") Sleep(100) Send("9") Sleep(100) Send("0") WEnd EndFunc I've tryed following the examples in the help file as best I could but can't get the hotkey to work. Can anyone point out what mistakes I have made here? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 3, 2007 Moderators Share Posted November 3, 2007 HotKeySet() has the exact example you're talking about in the help file. 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. Link to comment Share on other sites More sharing options...
Walls192 Posted November 3, 2007 Share Posted November 3, 2007 (edited) Try using: HotKeySet("{WHATEVER KEY}", "Twist") Edited November 3, 2007 by Walls192 Link to comment Share on other sites More sharing options...
Achilles Posted November 3, 2007 Share Posted November 3, 2007 ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFunc My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
infinitenight Posted November 3, 2007 Author Share Posted November 3, 2007 I assumed at first that the example was actually calling some kind of pause funtion, which was not very helpful for what I wanted to do. After reading responces and doing more testing I figured it out and got what I wanted, so thanks Global $Twist HotKeySet("`", "ToggleTwist") ;;;; Body of program would go here;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func ToggleTwist() $Twist = NOT $Twist While $Twist Send("7") Sleep(100) Send("8") Sleep(100) Send("9") Sleep(100) Send("0") Sleep(8100) WEnd EndFunc Link to comment Share on other sites More sharing options...
infinitenight Posted November 4, 2007 Author Share Posted November 4, 2007 ALMOST got what I wanted anyway The script worked fine while testing in notepad, but when I try to use it in the program (game actually) that I created it for, I get nothing. I inserted some WinActive code lines that.. sort of worked. If I hit the hotkey outside of the game, it would bring up the game and start the macro. But I can't start or stop the macro while the game is the active window. Any ideas what could be going on here? Is it possible to get around this? Link to comment Share on other sites More sharing options...
Achilles Posted November 4, 2007 Share Posted November 4, 2007 Does the game use the hotkey you are trying to use in your script? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
infinitenight Posted November 4, 2007 Author Share Posted November 4, 2007 No it doesn't. It also does not use gameguard (I've a lot of people posting about this blocking them). Haven't found anything helpful yet Link to comment Share on other sites More sharing options...
rasim Posted November 4, 2007 Share Posted November 4, 2007 What occurs here first time and second time? $Paused = NOT $Paused Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now