Sign in to follow this  
Followers 0
TuMiM

Exit in middile of button press script

3 posts in this topic

I have a gui with a button which will basically do a send key request when the specific application is active but if after pressing the button you decide to close the application it won't close. The specific button is button2. I know i am missing an exit somewhere but not sure how and where it should go.

#include <GUIConstants.au3>
#include<file.au3>
#include<array.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Automatic Inventory Application", 456, 290, 241, 160)
$FileIn = GUICtrlCreateInput("", 128, 88, 177, 21, -1, $WS_EX_CLIENTEDGE)
$Button1 = GUICtrlCreateButton("Browse", 320, 88, 97, 25)
GUICtrlCreateLabel("Automatic Inventory Application", 48, 16, 342, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800080)
GUICtrlCreateLabel("Inventory Text File:", 24, 88, 94, 17)
GUICtrlCreateLabel('Click on the "Enter Inventory" button and then open the Scan tape update feature. Please do not touch the keyboard once the inventory update is in progress!!', 24, 136, 390, 108)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Button2 = GUICtrlCreateButton("Enter Inventory", 152, 256, 137, 25)
$Find_Loc = ""
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $Button1
            $find_loc = FileOpenDialog("Inventory.", "c:\","Text Files (*.txt)",1 + 2)
            If $find_loc = "" Then ContinueLoop
            GUICtrlSetData($FileIn, $find_loc)
    Case $msg = $Button2
            If $Find_loc = "" Then ContinueLoop
            Dim $filearray,$filestring
            _FileReadToArray($find_loc,$filearray)
            $filestring = _ArrayToString($filearray,@TAB)
            WinWaitActive("System 08.12", "Build Scan List")
            send($filestring)
            send("{TAB}")
            Exit
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



Problem is in this line:

WinWaitActive("System 08.12", "Build Scan List")

snippet of revised code--one possible idea

Case $msg = $Button2
            If $Find_loc = "" Then ContinueLoop
            Dim $filearray,$filestring
            _FileReadToArray($find_loc,$filearray)
            $filestring = _ArrayToString($filearray,@TAB)
    If WinExists("System 08.12") Then
            WinWaitActive("System 08.12", "Build Scan List")
            send($filestring)
            send("{TAB}")
   EndIf
            Exit
    Case $msg = $GUI_EVENT_CLOSE

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Problem is in this line:

WinWaitActive("System 08.12", "Build Scan List")

snippet of revised code--one possible idea

Case $msg = $Button2
            If $Find_loc = "" Then ContinueLoop
            Dim $filearray,$filestring
            _FileReadToArray($find_loc,$filearray)
            $filestring = _ArrayToString($filearray,@TAB)
    If WinExists("System 08.12") Then
            WinWaitActive("System 08.12", "Build Scan List")
            send($filestring)
            send("{TAB}")
   EndIf
            Exit
    Case $msg = $GUI_EVENT_CLOSE
That won't work because it will automatically close if the program if the window specified by winexists is not open. I want it to stay open until the specific window is open or close if someone click on the X button.

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