Jump to content
Sign in to follow this  
Informant

AutoIt Newbie - Auto-Typer Help

Recommended Posts

Informant

I'm trying to make an auto-typer program but I just can't stop the typing. Here's what I currently got:

#include <GuiConstants.au3>

; GUI
GuiCreate("Auto-Typer", 330, 160)

; INPUT
GuiCtrlCreateLabel("Text", 10, 10)
$input = GuiCtrlCreateInput("", 45, 10, 200, 20)

; INPUT2
GuiCtrlCreateLabel("Every", 10, 50)
$input2 = GuiCtrlCreateInput("1000", 45, 50, 100)
GuiCtrlCreateLabel("Miliseconds", 150, 50)
GUICtrlSetStyle ( $input2, $ES_NUMBER)

; INPUT3
GuiCtrlCreateLabel("Speed", 10, 80)
$input3 = GUICtrlCreateInput("100", 45, 80)
GUICtrlSetStyle ( $input3, $ES_NUMBER)

; START BUTTON
$Button_1   = GuiCtrlCreateButton("Start", 10, 110, 100)
GUICtrlSetState( $Button_1, $GUI_FOCUS)

; STOP BUTTON
$Button_2   = GuiCtrlCreateButton("Stop", 110, 110, 100)

; EXIT BUTTON
$Exit       = GUICtrlCreateButton("Exit", 210, 110, 100)
GUISetState()

While 1 
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Exit
            Exit
        Case $msg = $Button_1 
            Do
                $text = GUICtrlRead($input,1) 
                $time = GUICtrlRead($input2,1) 
                $speed = GUICtrlRead($input3,1) 
                WinSetOnTop ("Auto-Typer", "", 1)
                WinActivate("Untitled")
                Opt("SendKeyDelay", $speed) 
                Sleep( $time )
                Send($text & "{ENTER}" )
            Until $msg = $Button_2
    EndSelect
WEnd
Edited by Informant

Share this post


Link to post
Share on other sites
Nahuel

Here's the problem:

Do
;...
 Until $msg = $Button_2

Before the script enters the Do..Until loop, the value of $msg is $Button_1. Now, there's nothing inside the loop that changes that value, so the loop will go on for ever. So, adding $msg=GuiGetMsg() inside this loop should fix the problem. However, you have a Sleep() there that is going to cause some trouble. So I say you should look in the file for AdlibEnable(). This calls a specified function every X milliseconds.

Share this post


Link to post
Share on other sites
Informant

Yea, it works perfectly now. Thank you very much, Nahuel! :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.