Rob Posted January 20, 2004 Posted January 20, 2004 (edited) I'm just messing around with AutoIt, and I'm wanting to make a simple, configurable script that presses a button on the keyboard over and over until stopped. This is what I have so far: Config.ini ;jump button [Jump] jump=a test.au3 sleep(5000) AutoItSetOption("SendKeyDelay", 50) $vjump = IniRead("config.ini","Jump","jump","jump not found") send($vjump) What I'm wanting to do is make the delay itself configurable. This script will actually serve a purpose by leveling up a jumping skill in Morrowind. I know it's not required and I could just test to see how long it takes to click on the window, but I want to do it for the knowledge itself. This is how I thought it would be done. Config.ini ;delay to start script [Delay] delay=sleep(10000) test.au3 AutoItSetOption("SendKeyDelay", 50) $vsleep = IniRead("config.ini","Delay","delay","delay not found") $vjump = IniRead("config.ini","Jump","jump","jump not found") send($vjump) It immediately presses the button and closes. I'm obviously doing it wrong. Also, how do I get the script to repeat itself until it's manually stopped? I downloaded this a while back but am just now playing with it so forgive my lack of knowledge. Edited January 20, 2004 by Rob
Developers Jos Posted January 20, 2004 Developers Posted January 20, 2004 (edited) config.INI: [Jump] jump=a [Delay] delay=10000 Script: ; set hotkey so when pause is pressed the script will stop hotkeyset("{Pause}","StopExec") AutoItSetOption("SendKeyDelay", 50) While 1 $vsleep = IniRead("config.ini","Delay","delay",1000) $vjump = IniRead("config.ini","Jump","jump","") send($vjump) ; send chars defined in INI sleep($vsleep) ; sleep amount of msec defined in INI wend Func StopExec() $mrc=Msgbox(4,"Cancel Execution?","You pressed PAUSE. Do you want to cancel the Program?") if $mrc = 6 then Exit EndFunc Edited January 20, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Rob Posted January 20, 2004 Author Posted January 20, 2004 hotkeyset("{Pause}","StopExec") I get an error saying uknown function name. It's probably something I'm doing wrong.
Developers Jos Posted January 20, 2004 Developers Posted January 20, 2004 rob, Are you running ver 3.0.85 or better ? if you are then pls sent me your script and i will have a look.... Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Rob Posted January 20, 2004 Author Posted January 20, 2004 I wasn't aware AutoIt was updated so often. I fixed it. Thanks a lot!
scriptkitty Posted January 20, 2004 Posted January 20, 2004 If you want to start and stop your script, you can modify something like this: $x=2 hotkeyset("{Pause}","Stop") hotkeyset("^!g","Start") While 2 If $x=1 Then send("a"); put what ever you want in this section. sleep(1000);1 second pause between sending Wend Func Stop() $x=2 EndFunc Func Start() $x=1 EndFunc Try this out for size, change hotkeys acordingly $x=2 hotkeyset("{Pause}","Stop") hotkeyset("^!g","Start"); Starts on Ctrl+Alt+g $vsleep = IniRead("config.ini","Delay","delay",1000) $vjump = IniRead("config.ini","Jump","jump","") While 1 If $x=1 Then send($vjump) ; send chars defined in INI sleep(1) ; Just incase $vsleep is not defined sleep($vsleep) ; sleep amount of msec defined in INI EndIf Wend Func Stop() $x=2 EndFunc Func Start() $x=1 EndFunc AutoIt3, the MACGYVER Pocket Knife for computers.
scriptkitty Posted January 20, 2004 Posted January 20, 2004 After thinking about it, Pause would be a nice key to toggle starting and stoping the macro. So here is a version that uses Pause to actually pause it, and Ctrl+Alt+e to exit Note, uses your Ini file. $x=2 hotkeyset("{Pause}","Start"); Initially this will start the macro hotkeyset("!^e","exit1"); this exits the macro from memory $vsleep = IniRead("config.ini","Delay","delay",1000) $vjump = IniRead("config.ini","Jump","jump","") While 1 If $x=1 Then send($vjump) ; send chars defined in INI sleep(1) ; Just incase $vsleep is not defined sleep($vsleep) ; sleep amount of msec defined in INI EndIf Wend Func Stop() $x=2 hotkeyset("{Pause}","Start"); changes to make Pause start macro EndFunc Func Start() $x=1 hotkeyset("{Pause}","Stop"); changes to make Pause stop macro EndFunc Func exit1() Exit(1) EndFunc AutoIt3, the MACGYVER Pocket Knife for computers.
Rob Posted January 21, 2004 Author Posted January 21, 2004 Hey thanks a lot for the help. I have a new problem however. This is probably just something I need to deal with in the the Morrowind tech forum. However, when I run the script in the game, it doesn't seem to respond correctly. It will run perfectly outside of the game, but whenever I load the script and start it outside of the game, it won't jump (press E) but it will continue to hit E inside of the game console. Whenever I start the script and load it inside the game, it won't even type in the console. It seems like that game isn't responding to the external program. It's weird because it's just pressing E over and over again. Again, this may not be able to be answered in this forum.
scriptkitty Posted January 21, 2004 Posted January 21, 2004 (edited) Try removing the exit one, the "E" might be getting captured or such. It shouldn't but... Morrowwind might not like macros, if it is a online game. So you might not get much support. $x=2 hotkeyset("{Pause}","Start"); Initially this will start the macro ;hotkeyset("!^e","exit1"); this exits the macro from memory ; the semicolon commented out the exit part. $vsleep = IniRead("config.ini","Delay","delay",1000) $vjump = IniRead("config.ini","Jump","jump","") While 1 If $x=1 Then send($vjump); send chars defined in INI sleep(1) ; Just incase $vsleep is not defined sleep($vsleep); sleep amount of msec defined in INI EndIf Wend Func Stop() $x=2 hotkeyset("{Pause}","Start"); changes to make Pause start macro EndFunc Func Start() $x=1 hotkeyset("{Pause}","Stop"); changes to make Pause stop macro EndFunc Func exit1() Exit(1) EndFunc edit...also what Windows version, and DirectX version? Edited January 21, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
CyberSlug Posted January 21, 2004 Posted January 21, 2004 Scriptkitty is probably on the right track asking about DirectX version. However, I wonder if such games have bot-prevention mechanisms? Maybe increasing the delay to a human-producable value and adding on something like Random(100,200) for randomness would help. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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