Jump to content

Simple Script Help


Recommended Posts

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

Link to comment
Share on other sites

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" :)
Link to comment
Share on other sites

#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]

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...