Sign in to follow this  
Followers 0
BALA

Hotkey/Loop problem

1 post in this topic

I've been trying to get modify a previous script I made to start when I press F1. The script continuously types out a string at the point your specify until you tell it to stop. I know the "Off" function won't work because most of the time the script is running, the script will be paused. Forgive me if there is a simple solution that I have overlooked, it's been able a year since I've used AutoIt.

#include <Misc.au3>
#include <GUIConstants.au3>

HotKeySet("{F1}", "On")
HotKeySet("{F10}", "Off")

Func On()
    $check = 1
EndFunc

Func Off()
    $check = 0
EndFunc

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-TYPER", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$position1 = GUICtrlCreateCheckbox("Position", 70, 20, 120)
GUICtrlSetOnEvent($position1, "Position")
$label = GUICtrlCreateLabel ("x = " & @LF & "y = "& @LF,  200, 20,80,30,$SS_LEFT)

$on = GUICtrlCreateRadio ("On", 40, 60, 40, 20)
$off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20)
GUICtrlSetState ($off, $GUI_CHECKED)
$input = GUICtrlCreateInput("", 80, 70, 180, 20)

$checkbox = GUICtrlCreateCheckbox ("Input an 'Enter' after text", 41, 100, 140, 20)

$time = GUICtrlCreateInput("5", 210, 127, 40, 20)
GUICtrlCreateLabel ("Time between Posts (in seconds)", 40, 130)

Dim $Position, $i = 0, $Record[1][2]
Global $check = 0

Func CLOSEClicked()
  Exit
EndFunc

Func Position()
  While 1
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            ReDim $Record[$i + 1][2]
            $Record[$i][0] = $Position[0]
            $Record[$i][1] = $position[1]
            GUICtrlSetData($label,"x = "& $Record[$i][0] & @LF & "y = "& $Record[$i][1])
            $i += 1
            ExitLoop
        EndIf
        sleep(10)
    WEnd
EndFunc

While 1
    If GUICtrlRead($on) = $GUI_CHECKED Then
        $check = 1
    EndIf
    If GUICtrlRead($off) = $GUI_CHECKED Then
        $check = 0
    EndIf
    If $check = 1 Then
        MouseClick("left", $Position[0], $position[1], 1)
        Send (""&GuiCtrlRead($input))
        If GUICtrlRead($checkbox) = $GUI_CHECKED Then
            Send("{ENTER}")
        EndIf
        sleep(1000 * GuiCtrlRead($time))
    EndIf
    sleep(10)
WEnd

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

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