dwell Posted December 29, 2009 Share Posted December 29, 2009 Hi all.... Thanks in advance for reading my post! The problem is I have some code running a loop statement and it only seems to work correctly the first time through. Here is the code: #include <Process.au3> $WinTitle = 'Untitled - Notepad' $num = 0 While 1 If WinExists( $WinTitle ) And $num = 0 Then $rc = _RunDos("c:\blah -a 10.1.10.30 -c XNET -k blahblah -l 88.43.102.76:3882") $num = 1 MsgBox(0, "", "yes") Else If WinWaitClose("Untitled") = 1 And $num = 1 Then $PID = ProcessExists("blah.exe") If $PID Then ProcessClose($PID) $num = 0 MsgBox(0, "", "no") EndIf EndIf WEnd The reason I am using the $num is to eliminate processor load as the CPU creeps way up without it. When I run the script for the first time I get the MsgBox(s) and all as expected. The second time through it seems to only run the first part of the loop but does not fire the WinWaitClose. Am I missing something here? Thanks, dwell Link to comment Share on other sites More sharing options...
ViVoxity Posted December 29, 2009 Share Posted December 29, 2009 Hi all.... Thanks in advance for reading my post! The problem is I have some code running a loop statement and it only seems to work correctly the first time through. Here is the code: #include <Process.au3> $WinTitle = 'Untitled - Notepad' $num = 0 While 1 If WinExists( $WinTitle ) And $num = 0 Then $rc = _RunDos("c:\blah -a 10.1.10.30 -c XNET -k blahblah -l 88.43.102.76:3882") $num = 1 MsgBox(0, "", "yes") Else If WinWaitClose("Untitled") = 1 And $num = 1 Then $PID = ProcessExists("blah.exe") If $PID Then ProcessClose($PID) $num = 0 MsgBox(0, "", "no") EndIf EndIf WEnd The reason I am using the $num is to eliminate processor load as the CPU creeps way up without it. When I run the script for the first time I get the MsgBox(s) and all as expected. The second time through it seems to only run the first part of the loop but does not fire the WinWaitClose. Am I missing something here? Thanks, dwell I wish I could see the issue, but I don't. Don't you wish creating loops in autoit was as easy as it is in C++? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 29, 2009 Share Posted December 29, 2009 The WinWaitClose function waits for the specified process to be closed, it doesn't close it itself. That may be the issue here. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
dwell Posted December 29, 2009 Author Share Posted December 29, 2009 Hey guys.....thanks for the responses! Just to clarify....what I am really trying to accomplish with this is basically triggering a program to run off of the status of the Notepad window. If it is open then run BLAH.....and when it closes kill BLAH. It works the first time I open and close Notepad....after that the loop gets moody. Thanks, dwell Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 29, 2009 Moderators Share Posted December 29, 2009 dwell,Try splitting the 2 elements of the If statement:#include <Process.au3> $WinTitle = 'Untitled - Notepad' $num = 0 While 1 If WinExists( $WinTitle ) Then If $num = 0 Then $rc = _RunDos("c:\blah -a 10.1.10.30 -c XNET -k blahblah -l 88.43.102.76:3882") $num = 1 MsgBox(0, "", "yes") EndIf Else If $num = 1 Then $PID = ProcessExists("blah.exe") If ProcessExists("blah.exe") Then ProcessClose($PID) $num = 0 MsgBox(0, "", "no") EndIf EndIf WEndIt works for me! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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