Jump to content
Sign in to follow this  
Douglasjbell

Simple Script Help

Recommended Posts

Douglasjbell

Hi All

Just new to AutoIT and programming in general.

I have the following script, basically what I want it to do is when the start button is pressed and the notepad is active to continually send text to the notepad. When the Stop button is pressed its stops the script, just cant seem to get it to stop the script, please see my script below.

#include <GUIConstantsEx.au3>
GUICreate("Type in Notepad", 200, 100)
GUICtrlCreateLabel("Type in Notepad?", 30, 10)
$Startbutton = GUICtrlCreateButton("Start", 20, 50, 60)
$Stopbutton = GUICtrlCreateButton("Stop", 100, 50, 60)
GUISetState(@SW_SHOW)

Dim $i
$i = 1


While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $Startbutton

    Do
;sleep(5000)     
Send("This is some text.")
winWaitActive("Untitled - Notepad")
Until $i = 10

Case $msg = $Stopbutton
$i = 10

    Case $msg = $GUI_EVENT_CLOSE
      
      ExitLoop
  EndSelect
WEnd

Cheers

Dougie

Share this post


Link to post
Share on other sites
Rawox

Hi All

Just new to AutoIT and programming in general.

I have the following script, basically what I want it to do is when the start button is pressed and the notepad is active to continually send text to the notepad. When the Stop button is pressed its stops the script, just cant seem to get it to stop the script, please see my script below.

#include <GUIConstantsEx.au3>
GUICreate("Type in Notepad", 200, 100)
GUICtrlCreateLabel("Type in Notepad?", 30, 10)
$Startbutton = GUICtrlCreateButton("Start", 20, 50, 60)
$Stopbutton = GUICtrlCreateButton("Stop", 100, 50, 60)
GUISetState(@SW_SHOW)

Dim $i
$i = 1


While 1
  $msg = GUIGetMsg()

  Select
    Case $msg = $Startbutton

    Do
;sleep(5000)     
Send("This is some text.")
winWaitActive("Untitled - Notepad")
Until $i = 10

Case $msg = $Stopbutton
$i = 10

    Case $msg = $GUI_EVENT_CLOSE
      
      ExitLoop
  EndSelect
WEnd

Cheers

Dougie

Maybe it would be a better idea to use hotkeys... Look in the help file for "HotKeySet" :)

Share this post


Link to post
Share on other sites
nekkutta

#include <GUIConstantsEx.au3>
GUICreate("Type in Notepad", 200, 100)
GUICtrlCreateLabel("Type in Notepad?", 30, 10)
$Startbutton = GUICtrlCreateButton("Start", 20, 50, 60)
$Stopbutton = GUICtrlCreateButton("Stop", 100, 50, 60)
GUISetState(@SW_SHOW)

Dim $i
$i = 1


While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $Startbutton

            Do
                Sleep(500)
                WinWaitActive("Untitled - Notepad")
                Send("This is some text.")
                $msg = GUIGetMsg()
                If $msg = $Stopbutton Then ExitLoop
            Until $i = 10

        Case $msg = $Stopbutton
            $i = 10

        Case $msg = $GUI_EVENT_CLOSE

            ExitLoop
    EndSelect
WEnd

it'll stop, but you have to push the stop button a couple times.


[size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size]

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.