Sign in to follow this  
Followers 0
Krikov

Do Until Help

7 posts in this topic

Hi

how can i create a loop with do and until button is pressed

and when the button is pressed the loop stop.

Do
  Some Action
  Sleep(1000)
Until $Button1

Krikov


[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $Button_2, $msg, $x = 0
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    $Button_1 = GUICtrlCreateButton("Button Test", 10, 30, 100)


    GUISetState() 
    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
        $x += 1
        ConsoleWrite($x & @CR)
    Until $msg = $Button_1
EndFunc   ;==>Example

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks but its wont work on my script

Anyone what is worng with the script

1. when i press the run its create the file

2 when i press the Stop it's wont working

please help

[code]
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>
$INIFile = @ScriptDir&"\Last.ini"
$ini_Directory = IniRead($INIFile,"Data","Directory","")
$ini_FileName = IniRead($INIFile,"Data","FileName","")
$ini_Sleep = IniRead($INIFile,"Data","Sleep","1")
$ini_RSH = IniRead($INIFile,"Data","RSH","RSH Command")

#Region ### START Koda GUI section ### Form=c:\documents and settings\admin\my documents\filecreate_form.kxf
$Form1_1 = GUICreate("File Creator V1.0", 633, 447, 193, 170)
$Label1 = GUICtrlCreateLabel("Directory Path :", 8, 18, 77, 17)
$Input1 = GUICtrlCreateInput($ini_Directory, 88, 16, 393, 21)
$Button1 = GUICtrlCreateButton("Browse...", 488, 16, 75, 25, 0)
$Label2 = GUICtrlCreateLabel("File Name:", 8, 48, 54, 17)
$Input2 = GUICtrlCreateInput($ini_FileName, 88, 48, 121, 21)
$Button2 = GUICtrlCreateButton("Run", 16, 408, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Stop", 104, 408, 75, 25, 0)
$Button4 = GUICtrlCreateButton("Exit", 544, 408, 75, 25, 0)
$Input3 = GUICtrlCreateInput($ini_Sleep, 152, 80, 41, 21)
GUICtrlCreateUpdown(-1)
$Label3 = GUICtrlCreateLabel(" Create New File Each (sec)", 8, 80, 136, 17)
$Group1 = GUICtrlCreateGroup("RSH Command Tool", 8, 136, 609, 57)
$Input4 = GUICtrlCreateInput($ini_RSH, 16, 160, 593, 21)
GUICtrlSetState($Input4,$GUI_DISABLE)
GUICtrlSetState($Button3,$GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Checkbox1 = GUICtrlCreateCheckbox("Send RSH Command", 8, 112, 200, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button4 ; Exit Button Command
        Exit
    Case $Button1 ; Set File Path
        $Folder_Dest = FileSelectFolder("Choose a folder.", "")
        GUICtrlSetData($Input1,$Folder_Dest&"\")
    Case $Checkbox1 ; RSH Commnad Tool
        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
            GUICtrlSetState($Input4,$GUI_ENABLE)
        Else
            GUICtrlSetState($Input4,$GUI_DISABLE)
        EndIf
    Case $Button2
        GUICtrlSetState($Button2,$GUI_DISABLE)
        GUICtrlSetState($Button3,$GUI_ENABLE)
        IniWrite($INIFile,"Data","Directory",GUICtrlRead($Input1))
        IniWrite($INIFile,"Data","FileName",GUICtrlRead($Input2))
        IniWrite($INIFile,"Data","Sleep",GUICtrlRead($Input3))
        Do
            FileWriteLine(GUICtrlRead($Input1)&GUICtrlRead($Input2)&"-"&@MDAY&"_"&@MON&"_"&@YEAR&"-"&@HOUR&"_"&@MIN&"_"&@SEC&"_"&@MSEC,"This File Was Update in "&_Now())
            Sleep(GUICtrlRead($Input3)*1000)
        Until 
        GUICtrlSetState($Button2,$GUI_ENABLE)
        GUICtrlSetState($Button3,$GUI_DISABLE)


EndSwitch
WEnd

Thanks Krikov

Edited by Krikov

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You never leave the $button2 case due to:

Do
            FileWriteLine(GUICtrlRead($Input1)&GUICtrlRead($Input2)&"-"&@MDAY&"_"&@MON&"_"&@YEAR&"-"&@HOUR&"_"&@MIN&"_"&@SEC&"_"&@MSEC,"This File Was Update in "&_Now())
            Sleep(GUICtrlRead($Input3)*1000)
        Until

What is it supposed to do?

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

This script is for my work,

i am try to write afile to some directory in a do...until some time i want to stop the loop and do some changes

so i wanted to loop the file create until i press the stop button which is $Button3

Krikov


[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Share this post


Link to post
Share on other sites

You mean this?

HotKeySet("{F5}", "_QuitApp") 
HotKeySet ("{F3}", "Print")

while 1
    Sleep(2000)
Wend

Func Print()
    Run("notepad.exe")
    Sleep(1000)
    Send("aaaaaaaa")
EndFunc

Func _QuitApp()    
    Exit
EndFunc

I was taught this by a forum user last night :( I was trying with if statements and _IsPressed function, but this one is much better.. whenever you press F3, it will open a notepad and type "aaaaaaa" and with F5 it will close the script.. Of course, this is a mere example only, you can change the functions to whatever you want

Hope it helps >_<

Share this post


Link to post
Share on other sites

This script is for my work,

i am try to write afile to some directory in a do...until some time i want to stop the loop and do some changes

so i wanted to loop the file create until i press the stop button which is $Button3

Krikov

You cannot expect to stay in a do...until and expect it to stop the loop with check if the button is pressed with a GetMsg().

You need to rethink your strategy here.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  
Followers 0