Sign in to follow this  
Followers 0
Balug

While loop or..?

14 posts in this topic

Hey guys,

i got a question.

I wanna create a bot then when you press F10 that he will press press enter and then re-press enter untill u press F11 to stop it.

I allready got this:

#Include <Misc.Au3>
Hotkeyset("{F10}", "Start")
HotKeySet("{F11}", "Stop")
GUICtrlCreateLabel("Press F10 to Start The bot!")
GUICtrlCreateLabel("Press F11 to Stop The bot!")

but now i dono how to continue.

could you explain to me how to continue?

Thanks

~B

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hey guys,

i got a question.

I wanna create a bot then when you press F10 that he will press press enter and then re-press enter untill u press F11 to stop it.

I allready got this:

#Include <Misc.Au3>
Hotkeyset("{F10}", "Start")
HotKeySet("{F11}", "Stop")
GUICtrlCreateLabel("Press F10 to Start The bot!")
GUICtrlCreateLabel("Press F11 to Stop The bot!")

but now i dono how to continue.

could you explain to me how to continue?

Thanks

~B

This should work (not tested):

HotKeySet("{F10}","SendEnter")
HotKeySet("{F11}","StopSend")

Global $STATE

While 1
    Sleep(50)
WEnd

Func SendEnter()
    $STATE = 0
    Do
        Send("{ENTER}")
    Until $STATE = 1
EndFunc

Func StopSend()
    $STATE = 1
EndFunc
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Could you explain more please cause i wanna learn from it to!

And thanx:)

btw: i want him to press {ENTER} Each 500 ms. not that when u press F10 that he Once Press {ENTER}

Edited by Balug

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

;#Include <Misc.Au3> No need for this

Hotkeyset("{F10}", "Start")
HotKeySet("{F11}", "Stop")

;GUICtrlCreateLabel("Press F10 to Start The bot!") No need for this (You have no GUI)
;GUICtrlCreateLabel("Press F11 to Stop The bot!") No need for this (You have no GUI)

MsgBox(0,"Instructions", "Press F10 to Start, F11 to Stop") ; Tell the user how this works with a message box


$x = 1 ; random variable

While 1 ; Start an infinite loop
if $x = 1 then ; Checks if $x = 1 if it is it will sleep
    sleep(10) ; This will keep the script running ,but will do nothing 
Endif
If $x = 0 ; Checks if $x = 0 if it is then it will press enter
send('{Enter}') ; Sends enter
sleep(500) ; sleeps for 500 ms 
Endif
WEnd

Func start(); if you press F10 this will happen
$x = 0 ; Change $x to equal 0
Endfunc

Func stop(); if you press F11 this will happen
$x = 1; Change $x to equal 0
Endfunc

I think that will work

Edited by DexterMorgan

code

Share this post


Link to post
Share on other sites

This should work (not tested):

HotKeySet("{F10}","SendEnter")
HotKeySet("{F11}","StopSend")

Global $STATE

Func SendEnter()
    $STATE = 0
    Do
        Send("{ENTER}")
    Until $STATE = 1
EndFunc

Func StopSend()
    $STATE = 1
EndFunc
Heh! whooOOooosh!!

Wanna put a loop in there Andreik? :P

Here's another way with an explanation:

;----- This include holds the variables/functions for _IsPressed -----
#include <Misc.au3>

;----- we're going to be using _IsPressed a lot so we open up the dll -----
$dll = DllOpen("user32.dll")

;----- while 1 = 1 ....i.e. ALWAYS! -----
While 1 = 1
    ;----- sleep for 100 ms -----
    Sleep(100)
    
    ;----- if F10 is pressed... (79 = F10 in hex) -----
    If _IsPressed("79", $dll) = 1 Then
        
        ;----- do the follwing -----
        Do
        
        ;----- send ENTER keypress -----
        Send("{ENTER}")
        
        ;----- sleep for 500 ms -----
        Sleep(500)
        
        ;----- until F11 is pressed (7A = F11 in hex) -----
        Until _IsPressed("7A", $dll) = 1
    
    ;----- complete the 'IF' syntax -----
    EndIf

;----- complete the 'while' syntax -----
WEnd

Be careful with this script, if you run it when you don't need it you'll find windows opening all over the place!

Best to put in conditions eg make sure WinExists = 1, so you can target the correct window.


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Heh! whooOOooosh!!

Wanna put a loop in there Andreik? :P

Here's another way with an explanation:

;----- This include holds the variables/functions for _IsPressed -----
#include <Misc.au3>

;----- we're going to be using _IsPressed a lot so we open up the dll -----
$dll = DllOpen("user32.dll")

;----- while 1 = 1 ....i.e. ALWAYS! -----
While 1 = 1
    ;----- sleep for 100 ms -----
    Sleep(100)
    
    ;----- if F10 is pressed... (79 = F10 in hex) -----
    If _IsPressed("79", $dll) = 1 Then
        
        ;----- do the follwing -----
        Do
        
        ;----- send ENTER keypress -----
        Send("{ENTER}")
        
        ;----- sleep for 500 ms -----
        Sleep(500)
        
        ;----- until F11 is pressed (7A = F11 in hex) -----
        Until _IsPressed("7A", $dll) = 1
    
    ;----- complete the 'IF' syntax -----
    EndIf

;----- complete the 'while' syntax -----
WEnd

Be careful with this script, if you run it when you don't need it you'll find windows opening all over the place!

Best to put in conditions eg make sure WinExists = 1, so you can target the correct window.

Nice i think that was what i was looking for :( will check atm :idea: Thanks for the Explain with it.

Thanks for the Other fast reply's to!

Share this post


Link to post
Share on other sites

Heh! whooOOooosh!!

Wanna put a loop in there Andreik? :P

Here's another way with an explanation:

;----- This include holds the variables/functions for _IsPressed -----
#include <Misc.au3>

;----- we're going to be using _IsPressed a lot so we open up the dll -----
$dll = DllOpen("user32.dll")

;----- while 1 = 1 ....i.e. ALWAYS! -----
While 1 = 1
    ;----- sleep for 100 ms -----
    Sleep(100)
    
    ;----- if F10 is pressed... (79 = F10 in hex) -----
    If _IsPressed("79", $dll) = 1 Then
        
        ;----- do the follwing -----
        Do
        
        ;----- send ENTER keypress -----
        Send("{ENTER}")
        
        ;----- sleep for 500 ms -----
        Sleep(500)
        
        ;----- until F11 is pressed (7A = F11 in hex) -----
        Until _IsPressed("7A", $dll) = 1
    
    ;----- complete the 'IF' syntax -----
    EndIf

;----- complete the 'while' syntax -----
WEnd

Be careful with this script, if you run it when you don't need it you'll find windows opening all over the place!

Best to put in conditions eg make sure WinExists = 1, so you can target the correct window.

I have a do loop.

When the words fail... music speaks

Share this post


Link to post
Share on other sites

I personally think my example was best :P LOL


code

Share this post


Link to post
Share on other sites

I have a do loop.

lol, ok then. :(

Your script seems to terminate awfully fast!

Respect :P


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

lol, ok then. :(

Your script seems to terminate awfully fast!

Respect :P

You are right.

I don't have a main loop. I thought not send the ENTER key repeatedly.

Thanks for observation.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

i just put WinExists = 1 between the source cause without it wont work :P

----------------------------------------------

wont work with WinExists = 1 either.

I think its just because of the game or programm

Edited by Balug

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

i just put WinExists = 1 between the source cause without it wont work :P

----------------------------------------------

wont work with WinExists = 1 either.

I think its just because of the game or programm

No, sorry, I didn't mean to use that literally - I was being pragmatic, it will need to look something like:

If WinActive("Name of your game/window goes here") = 1 Then Send("{ENTER}")

...but you'll need to find the name of the window you're targetting.

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

What about this

HotKeySet("{F10}", "_DoFunc")
Global $State = 0

While 1
    Sleep(1000)
WEnd

Func _DoFunc()
$State = Not $State
While $State = 1
    Send("{ENTER}")
WEnd
EndFunc

AlmarM

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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  
Followers 0