Jump to content

A logical problem?


Recommended Posts

Hi guys,

I am new to AutoIt, I am quite experienced in programming but not scripting and I have been encountering some problems.

I decided to make a autotyper:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $button1, $button2, $button3
    Local $msg
    Global $input, $stop, $interval
    GUICreate("AutoTyper", 180, 100, -1, -1)
    $interval = GUICtrlCreateSlider(40,10,100,30)
    $button1 = GUICtrlCreateButton("Run", 5, 50, 50, 40)
    $button2 = GUICtrlCreateButton("Stop", 65, 50, 50, 40)
    $button3 = GUICtrlCreateButton("Input", 125, 50, 50, 40)
    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button1
                $stop = 0
                while $stop = 0
                    Send($input)
                    Sleep($interval)
                    Send("{Enter}")
                WEnd
            Case $msg = $button2
                $stop = 1
            Case $msg = $button3
                $input=InputBox("Input", "Type the message here.", "", "", 500, 130, 10, 150)
        EndSelect
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>_Main

What is suppose happen is that you write the input then you press run is then sends the input with the interval you chose; you then press stop to stop.

Problem:

The stop button does not work, and I have no idea about the slider to make it change the value of the variable interval.

All help is apreciated

Thanks,

Edited by NewNinja
Link to comment
Share on other sites

You Need to use GUICtrlRead(). All you are doing is sending the Control IDs.

Send(GUICtrlRead($input))
Sleep(GUICtrlRead($interval));; Remember that Sleep is in milliseconds so you may have to add a multiplier here For Example Sleep(GUICtrlRead($interval)*1000)
Send("{Enter}")

For the Stop, you can search the forums for something like stop process. There are lots of examples posted.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You need to can get the message from button2, in your example you are catch in an infinte loop.

Global $input

$main = GUICreate("AutoTyper", 180, 100, -1, -1)
$interval = GUICtrlCreateSlider(40,10,100,30)
GUICtrlSetLimit($interval,100,1)
GUICtrlSetData($interval,10)
$button1 = GUICtrlCreateButton("Run", 5, 50, 50, 40)
$button2 = GUICtrlCreateButton("Stop", 65, 50, 50, 40)
$button3 = GUICtrlCreateButton("Input", 125, 50, 50, 40)
GUISetState(@SW_SHOW,$main)

While True
    Switch GUIGetMsg()
        Case $button1
            $stop = False
            $sleep = GUICtrlRead($interval)
            While $stop = False
                Send($input)
                Sleep($sleep)
                Send("{ENTER}")
                If GUIGetMsg() = $button2 Then $stop = True
            WEnd
        Case $button3
            $input=InputBox("Input", "Type the message here.", "", "", 500, 130, 10, 150)
        Case -3
            Exit
    EndSwitch
    Sleep(10)
WEnd

When the words fail... music speaks.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...