ghost11996 Posted May 16, 2014 Posted May 16, 2014 (edited) Hello Im having a problem with Exit When the FileOpen FileOpenDialog was presenting I tried to Exit with the tray but I need to press Cancel/Close on FileOpen FileOpenDialog to make Autoit Exit #include <TrayConstants.au3> #NoTrayIcon Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) Global $iExit = TrayCreateItem("Exit") TraySetState(1) TrayItemSetOnEvent($iExit,"_exit") $checking = False While $checking = False $FileOpen = FileOpenDialog("Open Texts", @UserProfileDir , "Text (*.txt)") If Not @error Then MsgBox(0,"Text Opened","") $checking = True EndIf WEnd While 1 Sleep(1) WEnd Func _exit() Exit 0 EndFunc Sorry for my bad english ____________ Edit : Function Mistake Edited May 17, 2014 by ghost11996 [color=rgb(255,0,0);]C[/color][color=rgb(255,140,0);]a[/color][color=rgb(255,215,0);]n[/color] [color=rgb(255,255,0);]i[/color] [color=rgb(175,238,238);]e[/color][color=rgb(0,255,255);]a[/color][color=rgb(64,224,208);]t[/color] [color=rgb(0,0,205);]S[/color][color=rgb(0,0,255);]i[/color][color=rgb(0,0,128);]g[/color][color=rgb(75,0,130);]n[/color][color=rgb(128,0,128);]at[/color][color=rgb(238,130,238);]u[/color][color=rgb(221,160,221);]r[/color][color=rgb(230,230,250);]e[/color] [color=rgb(0,255,0);]?[/color] :ermm: [color=rgb(0,255,0);]Project: Mini Youtube BETA[/color]
JohnOne Posted May 16, 2014 Posted May 16, 2014 First of all there is no FileOpen function in your script, but if you mean FileOpenDialog then that is a blocking function and will act the same as MsgBox does. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted May 16, 2014 Posted May 16, 2014 You need to use something like this: $FileOpen = FileOpenDialog("Open Texts", @UserProfileDir , "Text (*.txt)") If @error <> 0 Then Exit My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Solution javiwhite Posted May 16, 2014 Solution Posted May 16, 2014 I believe the issue is due to the fact that AutoIT doesn't support multithreading. When the dialog box is open, The script will wait until the user has finished with the dialog box before processing any further requests. The easiest way to see what i mean is, Add a consoleWrite() to your exit function, and then try and see when exactly the exit code runs. (i believe it will run as soon as the FileOpenFolder is closed.) The way around this would be to have two separate scripts, The parent and child; With the child being the FileOpenFolder. the parent script would call the FileOpenFolder script, and then, when required, Kill the script and then exit itself... Here is your script that i modified and tested with, and it works for me: parent: #include <TrayConstants.au3> #NoTrayIcon Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) Global $iExit = TrayCreateItem("Exit") TraySetState(1) TrayItemSetOnEvent($iExit,"_exit") run(@workingDir & "\FileOpenTxt.exe") While 1 Sleep(1) WEnd Func _exit() ProcessClose("FileOpenTxt.exe") Exit 0 EndFunc Child $checking = False if $checking = False Then $FileOpen = FileOpenDialog("Open Texts", @UserProfileDir , "Text (*.txt)") If Not @error Then MsgBox(0,"Text Opened","") $checking = True EndIf EndIf In this example however, I did have to compile the script as an exe called FileOpenTxt.exe (this is so it would have its own process in task manager), But you could experiment with WinClose. As the saying goes; There's always more than one way to skin a cat. also, why do you have a while loop running around the folderopendialog? The dialog should pause the script until the user exits the command anyway. If you're looking too ensure they select a file, just set the options param to 1 and it should achieve the same result Link I hope this helps -Javi give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.
ghost11996 Posted May 17, 2014 Author Posted May 17, 2014 @JohnOne: Yea Sorry My mistake @water: I think you misunderstand my question... @Javiwhite: Nice resolution I guess I will put it in my code Thanks Ps: The code was just an example for asking [color=rgb(255,0,0);]C[/color][color=rgb(255,140,0);]a[/color][color=rgb(255,215,0);]n[/color] [color=rgb(255,255,0);]i[/color] [color=rgb(175,238,238);]e[/color][color=rgb(0,255,255);]a[/color][color=rgb(64,224,208);]t[/color] [color=rgb(0,0,205);]S[/color][color=rgb(0,0,255);]i[/color][color=rgb(0,0,128);]g[/color][color=rgb(75,0,130);]n[/color][color=rgb(128,0,128);]at[/color][color=rgb(238,130,238);]u[/color][color=rgb(221,160,221);]r[/color][color=rgb(230,230,250);]e[/color] [color=rgb(0,255,0);]?[/color] :ermm: [color=rgb(0,255,0);]Project: Mini Youtube BETA[/color]
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