Alex1 Posted May 6, 2007 Posted May 6, 2007 Hey, I'm trying to create a code which would click f3 every, say 10 seconds, and then hit f1 two seconds after hitting f3. This is for a game, and I'm not exactly sure where to start. Thanks a lot for your help. ~ Alex
erebus Posted May 6, 2007 Posted May 6, 2007 (edited) Start by reading the helpfile for the Send() and ControlSend() functions. Read the examples, try to write something by yourself and if you need more help, shoot. Edited May 6, 2007 by erebus
Alex1 Posted May 6, 2007 Author Posted May 6, 2007 I've coded in Flash before, and I'm not sure how similar this is to that. Do I need some sort of starter to tell it when to run? I'm not sure how to make it keep on running that action indefinitely.
Administrators Jon Posted May 6, 2007 Administrators Posted May 6, 2007 While 1 Sleep(10000) Send("{F3}") Sleep(2000) Send("{F1}") WEnd Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Alex1 Posted May 6, 2007 Author Posted May 6, 2007 (edited) Thanks jon, but how could i get that to keep repeating? Preferably, I'd like a constantly repeating script that makes f3 be pressed every 10 seconds, and f1 be pressed every 13 seconds EDIT: Thanks for the help! It does repeat... I didn't realize. Thanks again I think I can modify it now how I would like. Edited May 6, 2007 by Alex1
Administrators Jon Posted May 6, 2007 Administrators Posted May 6, 2007 Thanks jon, but how could i get that to keep repeating? Preferably, I'd like a constantly repeating script that makes f3 be pressed every 10 seconds, and f1 be pressed every 13 secondsThat script repeats. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Vindicator209 Posted May 6, 2007 Posted May 6, 2007 While...Wend its a loop =P [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
The_Noob Posted May 7, 2007 Posted May 7, 2007 (edited) i tend to use do... until 1=2 to do my loops... i should prolly learn while ... wend theyre (supposedly) better... Perhaps have somthing like $time = 1 ;declares $time as a variable do ;starts the loop if $time = 10 then send("keys here") ;do at 10 seconds if $time = 13 then send("keys here") ;do at 13 seconds if $time = 13 then $time = 1 ;every 13 seconds it will reset $time to 1 sleep(1000) ;pauses for one second. $time = $time + 1 ;increases $time by one until 1 = 2 ;will loop until 1 = 2... which never happens Somthing like that, If you can code other languages you should be able to manipulate that to work. autoit wont read anything after ; so use them for notes. hey since i brought it up... whats the advantages of using do loops vs using while loops? #edit# Heh i just realized that what i put does the same thing as what Jon did, but in like twice as many lines. Duh... lol Edited May 7, 2007 by The_Noob
Vindicator209 Posted May 7, 2007 Posted May 7, 2007 (edited) =P While...Wend isint necessarly better, but in about say 10000 times using it, you would save... about 10000 keypresses =P... though it is different if you use sCiTE's auto match... lol but whats easier to explain?" 1 = infinite", or "1 never becomes 2 unless you declare it 2 within your loop"? heh...lol *ahem* off topic =P Edited May 7, 2007 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
herewasplato Posted May 7, 2007 Posted May 7, 2007 (edited) ...but whats easier to explain?" 1 = infinite", or "1 never becomes 2 unless you declare it 2 within your loop"?While we are off topic: An explanation of "1 = infinite" might draw some discussion from those that say that "1 = True" which might take quite a few words to explain. While True Sleep(99) WEnd @The_Noob, As for the difference between While/WEnd and Do/Until: A While/WEnd loop may not execute the code inside the loop even once if the expression after the While is false. A Do/Until loop will execute at least some of the code inside the loop at least once. -MSP- Edited May 7, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Alex1 Posted May 7, 2007 Author Posted May 7, 2007 Could someone guide me to the best place to find good tutorials? The next thing I'd like to make is something that clicks down, types something in, presses enter, and does that every 1 minute or so (or alternating messages).
Vindicator209 Posted May 7, 2007 Posted May 7, 2007 what game are you talking about? well, start a timer: $timer=TimerInit() Then, somewhere in one of your loops, tell it to keep cheking it: If TimerDiff($timer) > 60000 Then ;"greater than" because your loop likely wont be instantly looping MouseClick("left") ;click Send("message") ;type somthing in Send("{enter}") ;press enter $timer=TimerInit() ;Reset timer EndIf ;endif I havent exactly checked that yet but somewhere in that area =P [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
November Posted May 7, 2007 Posted May 7, 2007 Hi, And something like this? AdlibEnable("F3", time in ms);define to run the func in ms AdlibEnable("F1", time in ms);define to run the func in ms ;<script HERE> func F3(); Press F3 Send("{F3}") EndFunc Func F1(); Press F1 Send("{F1}") EndFunc Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font]
The_Noob Posted May 7, 2007 Posted May 7, 2007 Hi, And something like this? AdlibEnable("F3", time in ms);define to run the func in ms AdlibEnable("F1", time in ms);define to run the func in ms ;<script HERE> func F3(); Press F3 Send("{F3}") EndFunc Func F1(); Press F1 Send("{F1}") EndFunc Cheers now that just totally confused me. But thanks for the information on while vs do is helpfull. I apprieate it. Thanks!
Alex1 Posted May 8, 2007 Author Posted May 8, 2007 Thanks for the help guys... one more question, how do I randomize something? Like, make something happen every set interval, but within a 0-4 second time of that interval (and have the following action still come an equal time after?). Thanks
PsaltyDS Posted May 8, 2007 Posted May 8, 2007 $Delay = Random(250, 4000, 1) AdlibEnable("F3", $Delay);define to run the func in ms AdlibEnable("F1", $Delay);define to run the func in ms Cheers! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
herewasplato Posted May 8, 2007 Posted May 8, 2007 (edited) Hi, And something like this? AdlibEnable("F3", time in ms);define to run the func in ms AdlibEnable("F1", time in ms);define to run the func in ms ;<script HERE> func F3(); Press F3 Send("{F3}") EndFunc Func F1(); Press F1 Send("{F1}") EndFunc CheersThat won't quite work as you thought - thy this code and maybe you will see what I mean:AdlibEnable("F3", 2000) AdlibEnable("F1", 3000) While 1 Sleep(1111111111) WEnd Func F3() ToolTip("F3 at 2000") Sleep(1000) ToolTip("") EndFunc ;==>F3 Func F1() ToolTip("F1 at 3000") Sleep(1000) ToolTip("") EndFunc ;==>F1 Edit: typo Edited May 8, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
herewasplato Posted May 8, 2007 Posted May 8, 2007 $Delay = Random(250, 4000, 1) AdlibEnable("F3", $Delay);define to run the func in ms AdlibEnable("F1", $Delay);define to run the func in ms Cheers! Only one AdlibEnable will be active per script - right? [size="1"][font="Arial"].[u].[/u][/font][/size]
PsaltyDS Posted May 8, 2007 Posted May 8, 2007 Only one AdlibEnable will be active per script - right?To quote the great philosopher Simpson: "DOH!" You're right of course. I was only trying to demo saving a randomized integer for the delay and didn't think that through. It would also be redundant to set two AdLibEnable's for the same time base even if you could - just combine the functions. :"> Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
herewasplato Posted May 8, 2007 Posted May 8, 2007 ...how do I randomize something?Run this and see what it teaches you:While 1 $slp = Random(500, 4000, 1) ToolTip("Random Sleep " & $slp) Sleep($slp) ToolTip("Fixed Sleep 2000") Sleep(2000) WEndAfter this, it is time for you to post some code... and then we can help correct any problems based on that code. [size="1"][font="Arial"].[u].[/u][/font][/size]
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