Jump to content
Sign in to follow this  
Rishav

GUI Button presses with Select command, script stuck

Recommended Posts

Rishav

Sorry for the stupid topic name. Had no idea how to condense it in a few words.

I have created a simple UI for running a batch file (which further runs some sql commands).

Posted Image

the problem is with the code for button presses. I have two main buttons here; the browse button and the Proceed button. I expect the user to click the browse button, select the file, fill the rest of the fields and then click proceed.

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $DumpFileLocation_button
            $var = FileOpenDialog("Please Input the dump file path", "c:\" & "", "Dump (*.dmp)", 1 + 2)
            GUICtrlSetData($DumpFileLocation_field, $var)
        Case $msg = $GUI_EVENT_CLOSE
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            Exit
        Case $msg = $proceed_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            GUICtrlSetState ( $proceed_button, $GUI_DISABLE )
            
; Get the data in the UI fields
            $DumpFileLocation_data = ControlGetText(" Dump Importer", "XXX parameters", $DumpFileLocation_field)
            $XXXTNS_data = ControlGetText(" Dump Importer", "XXX parameters", $XXXTNS_field)
            $XXXSYS_data = ControlGetText(" Dump Importer", "XXX parameters", $XXXSYS_field)
            $XXXDB_data = ControlGetText(" Dump Importer", "XXX parameters", $XXXDB_field)
            
; Run the User Management batch file
            Run("User_Management.bat", @ScriptDir)  ; <---------  This is where @error=1
            WinWait("User Management")  
            WinActivate("User Management")  
                        
            Send($XXXTNS_data)
            Send("{ENTER}")
            Sleep(500)
            
            Send($XXXSYS_data)
            Send("{ENTER}")
            
            Send($XXXDB_data)
            Send("{ENTER}") 
            WinWaitClose("User Management")
            
            ExitLoop
        Case $msg = $close_button
            SoundPlay(@WindowsDir & "\media\Windows XP Pop-up Blocked.wav")
            Exit
    EndSelect
WEnd

MsgBox(64,"Operation Over","Importing of the  Dump is now finished.")

Problem is that when I run the GUI, if i don't touch the browse button, then the batch file runs properly. But if I open Browse and select qany file then the batch file refuses to open. I used the trace commands and found that the run command is giving erro code 1.

What am I doing wrong?

regards

Rishav

Edited by Rishav

Share this post


Link to post
Share on other sites
Authenticity

Hmm... and what if the user chose a file "C:\#{UP}{ENTER 2}.dmp"? use the second parameter of the Send function. Also, see if enclosing the file name in double quotes can solve the problem.

Share this post


Link to post
Share on other sites
Rishav

What I am doing here is that I am setting the browse path (from thw popup window) into the file path textfield.

$msg = $DumpFileLocation_button
            $var = FileOpenDialog("Please Input the dump file path", "c:\" & "", "Dump (*.dmp)", 1 + 2)
            GUICtrlSetData($DumpFileLocation_field, $var)

Then I am setting the text in the textfield into a variable.

$DumpFileLocation_data = ControlGetText(" Dump Importer", "XXX parameters", $DumpFileLocation_field)

I doubt that there is any issue with the file name part as nowhere I explicitly use the file name and instead use variables.

Share this post


Link to post
Share on other sites
Authenticity

Even though, you should use Send(*, 1) to avoid similar problems.

Share this post


Link to post
Share on other sites
Rishav

Thanks for the advice Auth. I have made the changes in my script.

But the main problem I am having is that the run command to initialize the batch file fails.

Share this post


Link to post
Share on other sites
Rishav

ok weird. I substitued

Run("User_Management.bat", @ScriptDir)

for ShellExecute and now it works.

ShellExecute("User_Management.bat", "",@ScriptDir, "")

how come? ^_^

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  

×