dcop Posted May 28, 2006 Share Posted May 28, 2006 While this is running the the GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") and the Exit button wont terminate the GUI. I haven't had this issue with other scripts while they're running. Anything obvious stand out? TIA, Dennis expandcollapse popup#include "GUIConstants.au3" FileDelete("C:\winnt\bfile.txt") FileDelete("C:\winnt\list.txt") If WinExists("Accessory Manager - [QA USERCODE ON MKEV01]") Then else MsgBox(0,"","Sorry, QA Session Must Be Running") Exit EndIf $passwd = InputBox("Doh!", "Enter Password And It's Duff Time", "", "*") $sendcap = 1 If $passwd = "1" Then go() if @error Then Exit go() Func go() ; == GUI generated with Koda == Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) $Form1 = GUICreate("B Mod", 325, 513, 192, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetBkColor(0x00FFFF) $Edit1 = GUICtrlCreateEdit("", 0, 0, 193, 512, -1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("", 216, 168, 73, 49, $BS_ICON) GUICtrlSetOnEvent(-1, "DoMod") GUICtrlSetImage($Button1, "C:\winnt\Homer.ico") $Button2 = GUICtrlCreateButton("Import", 216, 268, 73, 49) GUICtrlSetOnEvent(-1, "import") $Button2 = GUICtrlCreateButton("EXIT", 216, 368, 73, 49) GUICtrlSetOnEvent(-1, "CLOSEClicked") $prg1 = GUICtrlCreateLabel("", 200, 68, 120, 10) GUICtrlSetBkColor(-1, 0x00FFFF) GUISetState(@SW_SHOW) While 1 Sleep(100) WinMove ("B Mod", "", 1025, 0 , 250, 772) WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WEnd EndFunc Func DoMod() ;~ run("C:\winnt\prgss.exe", "", @SW_MAXIMIZE) $sum = 1 $one = ControlCommand("B Mod", "", "Edit1", "GetLine", $sum) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) $line = $one Sleep(1000) ClipPut($line) Sleep(1000) send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) send("{NUMPADADD}") $count = 1 $psum = 1 Do $pnext = $psum + "1" $pline = ControlCommand("B Mod", "", "Edit1", "GetLine", $pnext) $psum = $psum + 1 $ptot = $psum - "1" Until $pline = 1 Sleep(200) While 1 WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(500) $next = $sum + "1" $sum = $next $line = ControlCommand("B Mod", "", "Edit1", "GetLine", $next) If $line = 1 Then SplashImageOn ( "Let's Eat Boy's", "c:\winnt\chief.gif",300) Sleep(4000) Else EndIf If $line = 1 Then WinClose("B Mod") If $line = 1 Then Exit ClipPut($line) Sleep(1000) send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) send("{NUMPADADD}") Sleep(100) $count = $count + 1 GUICtrlSetData ( 7, $count & " of " & $ptot) Wend EndFunc Func CLOSEClicked() Exit EndFunc func import() If $sendcap = 1 Then WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(200) Send("/CAP-VIEW,B") Sleep(200) Send("{NUMPADADD}") Else EndIf $sendcap = $sendcap + 1 WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(100) Send("{ALT}") Sleep(200) Send("E") Sleep(200) Send("T") Sleep(200) send("^{INS}") Sleep(100) $list = ClipGet() FileOpen("c:\winnt\list.txt", 2) Sleep(500) FileWrite ("c:\winnt\list.txt", $list) FileOpen("c:\winnt\bfile.txt", 1) $fil = FileRead("c:\winnt\list.txt", 100000) $occur = 1 $searchb = 1 While $searchb <> 0 $searchb = StringInStr ( $fil, "b", 0, $occur) $par = StringMid ( $fil, $searchb, 6) $occur = $occur + 1 $par2 = StringTrimLeft ( $par, 1 ) $chkdig = StringIsDigit ( $par2) If $chkdig = 1 then FileWrite ("c:\winnt\bfile.txt", "B"&$par2&@CRLF) WEnd $theBs = FileRead("c:\winnt\bfile.txt", 3000) ClipPut($theBs) $putBs = ClipGet() GUICtrlSetData (3, $putBs) Sleep(200) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Send("{NUMPADADD}") EndFunc Link to comment Share on other sites More sharing options...
4gotn1 Posted May 28, 2006 Share Posted May 28, 2006 (edited) try stripping the function tags from Go().... like just let the script run the Go() function like so expandcollapse popup#include "GUIConstants.au3" FileDelete("C:\winnt\bfile.txt") FileDelete("C:\winnt\list.txt") If WinExists("Accessory Manager - [QA USERCODE ON MKEV01]") Then Else MsgBox(0, "", "Sorry, QA Session Must Be Running") Exit EndIf $passwd = InputBox("Doh!", "Enter Password And It's Duff Time", "", "*") $sendcap = 1 If $passwd = "1" Then $msg = GUIGetMsg() ; == GUI generated with Koda == Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) $Form1 = GUICreate("B Mod", 325, 513, 192, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetBkColor(0x00FFFF) $Edit1 = GUICtrlCreateEdit("", 0, 0, 193, 512, -1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("", 216, 168, 73, 49, $BS_ICON) GUICtrlSetOnEvent(-1, "DoMod") GUICtrlSetImage($Button1, "C:\winnt\Homer.ico") $Button2 = GUICtrlCreateButton("Import", 216, 268, 73, 49) GUICtrlSetOnEvent(-1, "import") $Button2 = GUICtrlCreateButton("EXIT", 216, 368, 73, 49) GUICtrlSetOnEvent(-1, "CLOSEClicked") $prg1 = GUICtrlCreateLabel("", 200, 68, 120, 10) GUICtrlSetBkColor(-1, 0x00FFFF) GUISetState(@SW_SHOW) Do While 1 Sleep(100) WinMove("B Mod", "", 1025, 0, 250, 772) WinMove("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") WEnd Until $msg = $GUI_EVENT_CLOSE ElseIf @error Then Exit EndIf Func DoMod() ;~ run("C:\winnt\prgss.exe", "", @SW_MAXIMIZE) $sum = 1 $one = ControlCommand("B Mod", "", "Edit1", "GetLine", $sum) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") WinMove("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) $line = $one Sleep(1000) ClipPut($line) Sleep(1000) Send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) Send("{NUMPADADD}") $count = 1 $psum = 1 Do $pnext = $psum + "1" $pline = ControlCommand("B Mod", "", "Edit1", "GetLine", $pnext) $psum = $psum + 1 $ptot = $psum - "1" Until $pline = 1 Sleep(200) While 1 WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(500) $next = $sum + "1" $sum = $next $line = ControlCommand("B Mod", "", "Edit1", "GetLine", $next) If $line = 1 Then SplashImageOn("Let's Eat Boy's", "c:\winnt\chief.gif", 300) Sleep(4000) Else EndIf If $line = 1 Then WinClose("B Mod") If $line = 1 Then Exit ClipPut($line) Sleep(1000) Send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) Send("{NUMPADADD}") Sleep(100) $count = $count + 1 GUICtrlSetData(7, $count & " of " & $ptot) WEnd EndFunc Func CLOSEClicked() Exit EndFunc Func import() If $sendcap = 1 Then WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(200) Send("/CAP-VIEW,B") Sleep(200) Send("{NUMPADADD}") Else EndIf $sendcap = $sendcap + 1 WinMove("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(100) Send("{ALT}") Sleep(200) Send("E") Sleep(200) Send("T") Sleep(200) Send("^{INS}") Sleep(100) $list = ClipGet() FileOpen("c:\winnt\list.txt", 2) Sleep(500) FileWrite("c:\winnt\list.txt", $list) FileOpen("c:\winnt\bfile.txt", 1) $fil = FileRead("c:\winnt\list.txt", 100000) $occur = 1 $searchb = 1 While $searchb <> 0 $searchb = StringInStr($fil, "b", 0, $occur) $par = StringMid($fil, $searchb, 6) $occur = $occur + 1 $par2 = StringTrimLeft($par, 1) $chkdig = StringIsDigit($par2) If $chkdig = 1 Then FileWrite("c:\winnt\bfile.txt", "B" & $par2 & @CRLF) WEnd $theBs = FileRead("c:\winnt\bfile.txt", 3000) ClipPut($theBs) $putBs = ClipGet() GUICtrlSetData(3, $putBs) Sleep(200) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Send("{NUMPADADD}") EndFunc dunno if it will work or not though tells me Sorry QA ....... since i don't have it running Edited May 28, 2006 by 4gotn1 Link to comment Share on other sites More sharing options...
Zedna Posted May 28, 2006 Share Posted May 28, 2006 GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") needn't to be called in your main "While 1" cycle it's just sufficient to call it once after GUICreate at begining Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
dcop Posted May 28, 2006 Author Share Posted May 28, 2006 Still no luck. I removed the func tags for go() and removed the close statement form the While. I commented out some stuff so u can try it. put about 10 lines of text in the edit box and hit the homer button then try to close while running. Thanx....Dennis expandcollapse popup#include "GUIConstants.au3" FileDelete("C:\winnt\bfile.txt") FileDelete("C:\winnt\list.txt") ;~ If WinExists("Accessory Manager - [QA USERCODE ON MKEV01]") Then ;~ else ;~ MsgBox(0,"","Sorry, QA Session Must Be Running") ;~ Exit ;~ EndIf $passwd = InputBox("Doh!", "Enter Password And It's Duff Time", "", "*") $sendcap = 1 If $passwd = "1" Then;go() Else Exit EndIf If @error Then Exit ;~ go() ;~ Func go() ; == GUI generated with Koda == Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) $Form1 = GUICreate("B Mod", 325, 513, 192, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetBkColor(0x00FFFF) $Edit1 = GUICtrlCreateEdit("", 0, 0, 193, 512, -1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("", 216, 168, 73, 49, $BS_ICON) GUICtrlSetOnEvent(-1, "DoMod") GUICtrlSetImage($Button1, "C:\winnt\Homer.ico") $Button2 = GUICtrlCreateButton("Import", 216, 268, 73, 49) GUICtrlSetOnEvent(-1, "import") $Button2 = GUICtrlCreateButton("EXIT", 216, 368, 73, 49) GUICtrlSetOnEvent(-1, "CLOSEClicked") $prg1 = GUICtrlCreateLabel("", 200, 68, 120, 10) GUICtrlSetBkColor(-1, 0x00FFFF) GUISetState(@SW_SHOW) While 1 Sleep(100) WinMove ("B Mod", "", 1025, 0 , 250, 772) WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) WEnd ;~ EndFunc Func DoMod() ;~ run("C:\winnt\prgss.exe", "", @SW_MAXIMIZE) $sum = 1 $one = ControlCommand("B Mod", "", "Edit1", "GetLine", $sum) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) $line = $one Sleep(1000) ClipPut($line) Sleep(1000) send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) send("{NUMPADADD}") $count = 1 $psum = 1 Do $pnext = $psum + "1" $pline = ControlCommand("B Mod", "", "Edit1", "GetLine", $pnext) $psum = $psum + 1 $ptot = $psum - "1" Until $pline = 1 Sleep(200) While 1 WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(500) $next = $sum + "1" $sum = $next $line = ControlCommand("B Mod", "", "Edit1", "GetLine", $next) If $line = 1 Then SplashImageOn ( "Let's Eat Boy's", "c:\winnt\chief.gif",300) Sleep(4000) Else EndIf If $line = 1 Then WinClose("B Mod") If $line = 1 Then Exit ClipPut($line) Sleep(1000) send("/CAP-MOD,SENT,") Send(ClipGet()) Sleep(1000) send("{NUMPADADD}") Sleep(100) $count = $count + 1 GUICtrlSetData ( 7, $count & " of " & $ptot) Wend EndFunc Func CLOSEClicked() Exit EndFunc func import() If $sendcap = 1 Then WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(200) Send("/CAP-VIEW,B") Sleep(200) Send("{NUMPADADD}") Else EndIf $sendcap = $sendcap + 1 WinMove ("Accessory Manager - [QA USERCODE ON MKEV01]", "", 0, 1, 1026, 772) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Sleep(100) Send("{ALT}") Sleep(200) Send("E") Sleep(200) Send("T") Sleep(200) send("^{INS}") Sleep(100) $list = ClipGet() FileOpen("c:\winnt\list.txt", 2) Sleep(500) FileWrite ("c:\winnt\list.txt", $list) FileOpen("c:\winnt\bfile.txt", 1) $fil = FileRead("c:\winnt\list.txt", 100000) $occur = 1 $searchb = 1 While $searchb <> 0 $searchb = StringInStr ( $fil, "b", 0, $occur) $par = StringMid ( $fil, $searchb, 6) $occur = $occur + 1 $par2 = StringTrimLeft ( $par, 1 ) $chkdig = StringIsDigit ( $par2) If $chkdig = 1 then FileWrite ("c:\winnt\bfile.txt", "B"&$par2&@CRLF) WEnd $theBs = FileRead("c:\winnt\bfile.txt", 3000) ClipPut($theBs) $putBs = ClipGet() GUICtrlSetData (3, $putBs) Sleep(200) WinActivate("Accessory Manager - [QA USERCODE ON MKEV01]", "") Send("{NUMPADADD}") EndFunc Link to comment Share on other sites More sharing options...
dcop Posted May 29, 2006 Author Share Posted May 29, 2006 Man, i dont get it. Even the Opt("GUICloseOnESC", 1) wont close it down when ESC is hit while domod() running. Somewhow this function is making all events uresponsive othet the the Windows minimize (-). Link to comment Share on other sites More sharing options...
4gotn1 Posted May 29, 2006 Share Posted May 29, 2006 (edited) as a last resort you could put in domod(): If $msg = $GUI_EVENT_CLOSE Then Exit EndIf but yeah that is wierd =S Edited May 29, 2006 by 4gotn1 Link to comment Share on other sites More sharing options...
dcop Posted May 29, 2006 Author Share Posted May 29, 2006 I've tried both modes, onevent and messageloop and the only way I've been able to stop it is thru the tray icon. I dont get it. as a last resort you could put in domod(): If $msg = $GUI_EVENT_CLOSE Then Exit EndIf but yeah that is wierd =S Link to comment Share on other sites More sharing options...
dcop Posted June 1, 2006 Author Share Posted June 1, 2006 Maybe I'm expecting something that can't happen with AutoIT but being new could someone please verify. With this running and the Test Function button hit isn't there a way to Exit the script with the windows 'x' or my UDF thru my Exit button while the Func test() is running? .....Dennis #include <GUIConstants.au3> ; == GUI generated with Koda == Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 1) $Form1 = GUICreate("Test", 433, 200, 192, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Button1 = GUICtrlCreateButton("Exit", 112, 40, 97, 49) GUICtrlSetOnEvent(-1, "CLOSEClicked") $Button2 = GUICtrlCreateButton("Test Function", 120, 112, 89, 49) GUICtrlSetOnEvent(-1, "test") $lab1 = GUICtrlCreateLabel("", 20, 10, 50, 50) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Exit Func CLOSEClicked() Exit EndFunc Func test() $c = 0 While ($c <> 30) GUICtrlSetData ( 5, $c) sleep(300) $c = $c + 1 WEnd EndFunc Link to comment Share on other sites More sharing options...
Uten Posted June 1, 2006 Share Posted June 1, 2006 The linear nature of AutoIt prevents the "msg loop" to get updated before you return from the Test() call. The code is not reentrant safe. This code is a work around: expandcollapse popup#include <GUIConstants.au3> ; == GUI generated with Koda == ;Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 1) $Form1 = GUICreate("Test", 433, 200, 192, 125) ;GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Button1 = GUICtrlCreateButton("Exit", 112, 40, 97, 49) ;GUICtrlSetOnEvent(-1, "CLOSEClicked") $Button2 = GUICtrlCreateButton("Test Function", 120, 112, 89, 49) ;GUICtrlSetOnEvent(-1, "Test") $lab1 = GUICtrlCreateLabel("", 20, 10, 50, 50) GUISetState(@SW_SHOW) While 1 If MsgCracker( GuiGetMsg()) = -3 Then ExitLoop WEnd Exit Func MsgCracker($msg) Switch $msg case 0 ; Case -3, $Button1 $msg=-3 CLOSEClicked() Case $Button2 Test() EndSwitch Return $msg EndFunc Func CLOSEClicked() ConsoleWrite("CLOSEClicked" & @LF) Exit EndFunc Func test() $c = 0 While ($c <> 30) GUICtrlSetData ( 5, $c) GUISetState() ;NOTE: It will take a few iteration before GuiGetMsg() passes on -3 or $button1 If MsgCracker( GuiGetMsg()) = -3 Then ExitLoop sleep(300) $c = $c + 1 WEnd EndFunc Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
dcop Posted June 1, 2006 Author Share Posted June 1, 2006 Cool! It looks like Select `'"Case" statement with no matching "Select" statement.: ' might still be needed as I'm getting a syntax error. I tried placing one in a few different positions but no luck. Where would it go in your work around? ....Dennis The linear nature of AutoIt prevents the "msg loop" to get updated before you return from the Test() call. The code is not reentrant safe. This code is a work around: expandcollapse popup#include <GUIConstants.au3> ; == GUI generated with Koda == ;Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 1) $Form1 = GUICreate("Test", 433, 200, 192, 125) ;GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Button1 = GUICtrlCreateButton("Exit", 112, 40, 97, 49) ;GUICtrlSetOnEvent(-1, "CLOSEClicked") $Button2 = GUICtrlCreateButton("Test Function", 120, 112, 89, 49) ;GUICtrlSetOnEvent(-1, "Test") $lab1 = GUICtrlCreateLabel("", 20, 10, 50, 50) GUISetState(@SW_SHOW) While 1 If MsgCracker( GuiGetMsg()) = -3 Then ExitLoop WEnd Exit Func MsgCracker($msg) Switch $msg case 0 ; Case -3, $Button1 $msg=-3 CLOSEClicked() Case $Button2 Test() EndSwitch Return $msg EndFunc Func CLOSEClicked() ConsoleWrite("CLOSEClicked" & @LF) Exit EndFunc Func test() $c = 0 While ($c <> 30) GUICtrlSetData ( 5, $c) GUISetState() ;NOTE: It will take a few iteration before GuiGetMsg() passes on -3 or $button1 If MsgCracker( GuiGetMsg()) = -3 Then ExitLoop sleep(300) $c = $c + 1 WEnd EndFunc Link to comment Share on other sites More sharing options...
Uten Posted June 1, 2006 Share Posted June 1, 2006 Cool! It looks like Select `'"Case" statement with no matching "Select" statement.: ' might still be needed as I'm getting a syntax error. I tried placing one in a few different positions but no luck. Where would it go in your work around? ....DennisWhat kinde of error do you get? The Switch ... Case .. EndSwitch probably needs a beta version of AutoIt. I use it because I find it easier to read. You should find it in the Help File The only diffrence between this code and the sample you providede is that i have moved the structure that handels the result from GuiGetMsg() out in a function. Now I can call that function several times before the first call ends (like a recursive call). You could get errors/conflicts if the rest of your code is not "independent" thought so take care. New message handlers would go in the MsgCracker($msg) function as in Func MsgCracker($msg) Switch $msg case 0 ; Case -3, $Button1 $msg=-3 CLOSEClicked() Case $Button2 Test() Case $GUI_EVENT_MOUSEMOVE;Needs #include <GUIConstants.au3> TraceMouse() Case Else ConsoleWrite("Unhandeled $msg:=" & $msg & @LF);Msg appeares in SciTe or when running from cmd.exe EndSwitch Return $msg EndFunc NOTE: If you need to do time consuming calckulations (like your test()) you shoud consider to weed that job out to another process. @neogia's coroutine.au3 udf could be one solution. Or you could take a look in my signature. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
dcop Posted June 2, 2006 Author Share Posted June 2, 2006 NOTE: If you need to do time consuming calckulations (like your test()) you shoud consider to weed that job out to another process. @neogia's coroutine.au3 udf could be one solution. Or you could take a look in my signature. Thanx Uten...I went with your suggestion of a seperate process and works like I want it to. I appreciate your time and assistance...Dennis 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