autoitquestion Posted April 10, 2011 Posted April 10, 2011 (edited) Hi, I have program doing something like that: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $scan_1, $scan_2, $btn, $res_1, $res_2 GUICreate("Trial",300,300) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Enter 1st input:", 30, 50, 120) GUICtrlCreateLabel("Enter 2nd input:", 30, 120, 120) $scan_1 = GUICtrlCreateInput("", 150, 50, 100, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $scan_2 = GUICtrlCreateInput("", 150, 120, 100, 20) $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $res_1=GUICtrlRead($scan_1) $res_2=GUICtrlRead($scan_2) Run("C:\Program Files\prog.exe") WinActivate("[CLASS:WindowsForms10.window.8.app.0.37873b]", "") Sleep(1000) Send($res_1) Send($res_2) Send("{ENTER}") GUIDelete() EndSelect WEnd The problem is that if there is any problem after line code: Case $msg = $btn, so it cause infinite loop, and it won't exit program. What should I do? Pls help... Noa Edited April 10, 2011 by autoitquestion
AdmiralAlkex Posted April 10, 2011 Posted April 10, 2011 Say what? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
autoitquestion Posted April 10, 2011 Author Posted April 10, 2011 Wrote above-I edited message Thx :-)
smartee Posted April 10, 2011 Posted April 10, 2011 try this#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $scan_1, $scan_2, $btn, $res_1, $res_2 GUICreate("Trial", 300, 300) GUICtrlCreateLabel("Enter 1st input:", 30, 50, 120) GUICtrlCreateLabel("Enter 2nd input:", 30, 120, 120) $scan_1 = GUICtrlCreateInput("", 150, 50, 100, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $scan_2 = GUICtrlCreateInput("", 150, 120, 100, 20) $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $res_1 = GUICtrlRead($scan_1) $res_2 = GUICtrlRead($scan_2) Run("C:\Program Files\prog.exe") WinActivate("[CLASS:WindowsForms10.window.8.app.0.37873b]", "") WinWaitActive("[CLASS:WindowsForms10.window.8.app.0.37873b]", "") Send($res_1) Send($res_2) Send("{ENTER}") GUIDelete() Exit EndSelect WEnd
autoitquestion Posted April 10, 2011 Author Posted April 10, 2011 (edited) Thanks-what should I do if in if loop condition does take place and I wish that GUI will not exit or delete For more details see code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $scan_1, $scan_2, $btn, $res_1, $res_2, $result, $flag, $file_1 GUICreate("MyProg",300,300) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Enter 1st input:", 30, 50, 120) GUICtrlCreateLabel("Enter 2nd input:", 30, 120, 120) $scan_1 = GUICtrlCreateInput("", 150, 50, 100, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $scan_2 = GUICtrlCreateInput("", 150, 120, 100, 20) $btn = GUICtrlCreateButton("Fix It!", 120, 200, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $res_1=GUICtrlRead($lot) $res_2=GUICtrlRead($lc) $file_1=FileExists("C:\temp\myTxt.txt") If $file_1==0 Then MsgBox(4096,"file not exist", "no file found") $flag=1 ExitLoop EndIf Run("C:\temp\myProg.exe") $result=MsgBox(4096, "Result", "Finish") If $result==1 Then GUIDelete() ExitLoop EndSelect WEnd if code line does take place: If $file_1==0 Then ,means, $file_1=0, means, file not exist, I wish that it won't continue in program, but will stay the GUI, means, will not delete it. What should I do? Thanks! Noa Edited April 10, 2011 by autoitquestion
autoitquestion Posted April 10, 2011 Author Posted April 10, 2011 Anyone know the answer? pls help me..
autoitquestion Posted April 10, 2011 Author Posted April 10, 2011 I edited my question appear 2 messages above
Developers Jos Posted April 10, 2011 Developers Posted April 10, 2011 Please do not bump your threads within 24 hours. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past.Â
autoitquestion Posted April 10, 2011 Author Posted April 10, 2011 Okay. and can you pls help me with my problem?
Developers Jos Posted April 10, 2011 Developers Posted April 10, 2011 Okay. and can you pls help me with my problem?Posting something that shows the problem and can be ran will probably help.Reading your last question leaves a lot to guess and the posted script is full of errors.Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past.Â
andrei0x309 Posted April 10, 2011 Posted April 10, 2011 Okay. and can you pls help me with my problem? First do not use == for comparing things , in basic like syntax = is used for comparing instead of == , also mostly in basic like syntax == is the equivalent to === in c like syntax . Secondly if you want a infinite loop you must use a infinite loop condition like while 1 ; code here wend Cause if you use a condition that at some point will be equal to 0 then you can not have a infinite loop .
smartee Posted April 10, 2011 Posted April 10, 2011 what about#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $scan_1, $scan_2, $btn, $res_1, $res_2, $result, $flag, $file_1 GUICreate("MyProg", 300, 300) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Enter 1st input:", 30, 50, 120) GUICtrlCreateLabel("Enter 2nd input:", 30, 120, 120) $scan_1 = GUICtrlCreateInput("", 150, 50, 100, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $scan_2 = GUICtrlCreateInput("", 150, 120, 100, 20) $btn = GUICtrlCreateButton("Fix It!", 120, 200, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $res_1 = GUICtrlRead($scan_1) $res_2 = GUICtrlRead($scan_2) $file_1 = FileExists("C:\temp\myTxt.txt") If $file_1 == 0 Then MsgBox(4096, "file not exist", "no file found") $flag = 1 Else Run("C:\temp\myProg.exe") $result = MsgBox(4096, "Result", "Finish") If $result == 1 Then GUIDelete() ExitLoop EndIf EndSelect WEnd
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