Jump to content
Sign in to follow this  
lancey

Help in creating a loop program

Recommended Posts

lancey

guys i need to create a program to simulate keystrokes every 1 minute "space bar" is pressed and every 2 minutes "F4" is pressed.

i need to use this program for one of my gaming applications so when im not around or eating it will still run.

i am new to this forum and program so please help me. If you can please give me a script or whole program thanks a lot guys. ^^

Share this post


Link to post
Share on other sites
MisterBates

guys i need to create a program to simulate keystrokes every 1 minute "space bar" is pressed and every 2 minutes "F4" is pressed.

i need to use this program for one of my gaming applications so when im not around or eating it will still run.

i am new to this forum and program so please help me. If you can please give me a script or whole program thanks a lot guys. ^^

Lookup the following in the help file:
  • While loop - to get your program looping
  • TimerInit - to initialize/re-initialize timers
  • TimerDiff - to check timers (timers work in milliseconds)
  • WinActivate - to ensure your key strokes are sent to the correct window
  • Send - to send your keystrokes
Providing a working script would not develop your AutoIt skills :rolleyes:

Share this post


Link to post
Share on other sites
lancey

thanks a lot i while provide the script that i will make guys please double check thanks. Sir for starters can you show me the basic syntax format of the program so that i can study it, thanks

Edited by lancey

Share this post


Link to post
Share on other sites
MisterBates

Sir for starters can you show me the basic syntax format of the program so that i can study it, thanks

Not sure what you mean. To get up and going (I assume you are using SciTE that came with AutoIt), open windows explorer, right-click where you want to keep your script, and choose "New/AutoIt Script". This will create a ".au3" file for you. Right-click this and choose "edit" and SciTE will start. SciTe has been customized to understand AutoIt scripting, so go to end of file and start typing "while" etc. etc. If you want to understand a keyword, put your cursor inside the word and hit F1 to get help.

Try to make the script, and post it back here ... people who show effort get helped :rolleyes:

Share this post


Link to post
Share on other sites
FreeFry

Lookup the following in the help file:

  • While loop - to get your program looping

  • TimerInit - to initialize/re-initialize timers
TimerDiff - to check timers (timers work in milliseconds)WinActivate - to ensure your key strokes are sent to the correct windowSend - to send your keystrokesProviding a working script would not develop your AutoIt skills :rolleyes:

Sleep is also an alternative to using Timerinit & TimerDiff :rambo:

Share this post


Link to post
Share on other sites
MisterBates

While 1

; action 1

; sleep 1 minute

; action 2

; sleep 1 minute

WEnd

Would need to be :rolleyes:

While 1

; action 1

; sleep 1 minute

; action 1 & 2

; sleep 1 minute

WEnd

... although personally I prefer timers as they give a good result even if the script gets low/no CPU cycles...

Share this post


Link to post
Share on other sites
lancey

Thanks guys i am currently on the Learning stages of the program. My algorithm would be like this:

1. I will run a program

2. login: Username and password

3. Application running: the program requires me to hit the "spacebar" every 1 minute and "F4" a minute after the spacebar was hit.

4. should always loop like this

So its like...

minute 1:00 spacebar

minute 2:00 F4

minute 3:00 spacebar

minute 4:00 F4

..

... up until i stop the program

5. im quite new to this so please help me ^^

6. Im not quite sure if this program will be recognized by the gaming application, for it needs something like simulating a real keyboard press by the user.

7. Thanks again guys, i hope you can help me.

Edited by lancey

Share this post


Link to post
Share on other sites
MisterBates

Thanks guys i am currently on the Learning stages of the program. My algorithm would be like this:

1. I will run a program

2. login: Username and password

3. Application running: the program requires me to hit the "spacebar" every 1 minute and "F4" a minute after the spacebar was hit.

4. should always loop like this

So its like...

minute 1:00 spacebar

minute 2:00 F4

minute 3:00 spacebar

minute 4:00 F4

..

... up until i stop the program

5. im quite new to this so please help me ^^

6. Im not quite sure if this program will be recognized by the gaming application, for it needs something like simulating a real keyboard press by the user.

7. Thanks again guys, i hope you can help me.

How about this (one running, exit using [ESC] or using the exit taskbar menu item):

hotkeyset("{Esc}", "ExitScript")
while 1
    WinActivate("Title of window I want to send keys to"); Replace title with the title of your application window
    send("{SPACE}")
    sleep(1000); 1000 milliseconds = 1 second
    WinActivate("Title of window I want to send keys to")
    send("{F4}")
    sleep(1000)
WEnd
Func ExitScript()
  Exit
EndFunc

Edit: Missed the exit capability

Edited by MisterBates

Share this post


Link to post
Share on other sites
lancey

alright guys here is my program...

; Body

MsgBox(1,"Auto Battle","Do you want to start the program")

WinActivate("APPXN TITLE")

WinWaitActive("APPXN TITLE")

; Loop

$i = 0

While $i <> -1

Sleep(1000)

Send("{SPACE}")

Sleep(1000)

Send("{F4}")

$i += 1

WEnd

but for some reason it doesnt work, i tried using it on notepad*it works* but on the actual application doesn't, is it because of the game guard? please help me..

Share this post


Link to post
Share on other sites
Misha

Yes, protections might stop it.

Share this post


Link to post
Share on other sites
Hirax

I would think that the code would look something like this.. Please read the comments I stuck in there that way you will better understand the actual source, and program. To start the program press F11, and to exit the program press F10.

HotKeySet( "{F10}" , "Exit" ) ;Setting the hotkey to F10 to exit the program

HotKeySet( "{F11}" , "Start" ) ;Setting start to start the program

Func Exit() ;Creating the function called exit

Exit ;the statement used to exit the program

EndFunc ;Ending the UDF exit

Func Start() ;Creating the UDF Start

While 1 ;Creating the loop and starting it

Sleep(100000) ;sleep for 1 minute I think I might have gotten my numbers wrong might want to check it

Send("{SPACE}") ;send the space bar button

Sleep(200000) ;sleep for 2 minute I think I might have gotten my numbers wrong might want to check it

Send("{F4}") ;Sending the key F4

Sleep(300000) ;sleep for 3 minute I think I might have gotten my numbers wrong might want to check it

Send("{SPACE}") ;Sending the key SPACE again

Sleep(400000) ;sleep for 4 minute I think I might have gotten my numbers wrong might want to check it

Send("{F4}") ;Sending the key F4

WEnd ;Ending the loop

EndFunc ;Ending the UDF Start

Share this post


Link to post
Share on other sites
lancey

I would think that the code would look something like this.. Please read the comments I stuck in there that way you will better understand the actual source, and program. To start the program press F11, and to exit the program press F10.

HotKeySet( "{F10}" , "Exit" ) ;Setting the hotkey to F10 to exit the program

HotKeySet( "{F11}" , "Start" ) ;Setting start to start the program

Func Exit() ;Creating the function called exit

Exit ;the statement used to exit the program

EndFunc ;Ending the UDF exit

Func Start() ;Creating the UDF Start

While 1 ;Creating the loop and starting it

Sleep(100000) ;sleep for 1 minute I think I might have gotten my numbers wrong might want to check it

Send("{SPACE}") ;send the space bar button

Sleep(200000) ;sleep for 2 minute I think I might have gotten my numbers wrong might want to check it

Send("{F4}") ;Sending the key F4

Sleep(300000) ;sleep for 3 minute I think I might have gotten my numbers wrong might want to check it

Send("{SPACE}") ;Sending the key SPACE again

Sleep(400000) ;sleep for 4 minute I think I might have gotten my numbers wrong might want to check it

Send("{F4}") ;Sending the key F4

WEnd ;Ending the loop

EndFunc ;Ending the UDF Start

will this work if there is a game guard? thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×