elkgod Posted December 22, 2008 Share Posted December 22, 2008 I am trying to get a loop that types into notepad and keeps retypeing the text based off the number of times you want through entered number. But the program will not stop unless it finishes. I am trying to ad a stop button that will end the loop but have be unsuccessful any advice an/or help. CODE#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $Text, $Times, $c, $txt Local $Stop, $Exit, $Start, $Msg, $sText Local $filemenu, $runmenu, $startitem, $stopitem, $creditsitem Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton Local $file GUICreate("AutoTalker", 300, 190) GUICtrlCreateGroup("Text:", 5, 15, 290, 100) $Text = GUICtrlCreateEdit("Please Read the Read Me file before use", 15,35,270,70, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Repeat Time:", 5, 115, 120, 50) $Times = GUICtrlCreateInput("", 15, 135, 100, 20, $ES_NUMBER) GUICtrlCreateGroup("", -99, -99, 1, 1) $Start = GUICtrlCreateButton("&Start", 130, 135, 50, 20) $Stop = GUICtrlCreateButton("&Stop", 185, 135, 50, 20) $Exit = GUICtrlCreateButton("&Exit", 240, 135, 50, 20) $filemenu = GUICtrlCreateMenu("File") $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $runmenu = GUICtrlCreateMenu("Run") $startitem = GUICtrlCreateMenuItem("Start", $runmenu) $stopitem = GUICtrlCreateMenuItem("Stop", $runmenu) $helpmenu = GUICtrlCreateMenu("About") $creditsitem = GUICtrlCreateMenuItem("Credits", $helpmenu) $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu) GUISetState() While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit Exit Case $Msg = $Start $txt=GUICtrlRead($Text) $c=GUICtrlRead($Times) Do $c = $c - 1 WinWaitActive("Untitled - Notepad") Send("{ENTER}") Send($txt) Send("{ENTER}") Sleep(7000) Until $c = 0 Case $Msg = $Stop case $Msg = $startitem case $Msg = $stopitem Case $Msg = $exititem Exit Case $Msg = $creditsitem MsgBox(0, "Credits", "") case $Msg = $aboutitem msgbox(0, "About", "") EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
Tomb Posted December 22, 2008 Share Posted December 22, 2008 ExitLoop() Link to comment Share on other sites More sharing options...
elkgod Posted December 22, 2008 Author Share Posted December 22, 2008 What do i put in ExitLoop() though Link to comment Share on other sites More sharing options...
Uten Posted December 22, 2008 Share Posted December 22, 2008 Structure your code a bit to make it more readable.. This part: Do $c = $c - 1 WinWaitActive("Untitled - Notepad") Send("{ENTER}") Send($txt) Send("{ENTER}") Sleep(7000) Until $c = 0oÝ÷ ÙÚ²z-+ÞÊ«±Êâ¦Öæ¤# .ØZ½éuæºw-è}ªZ®ÚÖ®¶sdgVæ2æ÷FWE6VæBb33c·GB¢bvåvD7FfRgV÷CµVçFFÆVBÒæ÷FWBgV÷C²Â3FVâ¶FFVBFÖV÷W@¢6VæBgV÷C·´TåDU'ÒgV÷C²¢6VæBb33c·GB¢6VæBgV÷C·´TåDU'ÒgV÷C²¢6ÆVWs¢VæD`¤VæDgVæoÝ÷ Ù8^·°®+^Ê«¨§)jëh×6While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit Exit Case $Msg = $Start $txt=GUICtrlRead($Text) $c=GUICtrlRead($Times) Case $Msg = $Stop case $Msg = $startitem case $Msg = $stopitem Case $Msg = $exititem Exit Case $Msg = $creditsitem MsgBox(0, "Credits", "") case $Msg = $aboutitem msgbox(0, "About", "") Case else If $c > 0 then $c = $c - 1 NotepadSend($txt) EndIf EndSelect WEnd Note: I have not tested the code. But I hope you get the point and figure out the rest.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now