yoinkster Posted January 26, 2009 Share Posted January 26, 2009 Hey guys, I'm totally new to AutoIt but I think it's going to be what I'm looking for, I guess I'll be here asking many more lame questions this week! Anyway, just for now, all I'm trying to do is adapt the SampleControls.au3 script that comes with the latest version and I basically want to add some children options to the main menu items. I have as my code at the mo :: expandcollapse popup#include <GuiConstantsEx.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #Include <Array.au3> Local $menu, $fileexit, $fileopen, $msg, $chosen, $files, $path, $wholething, $realpath, $i ; GUI GuiCreate("My test toy", 400, 400) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; MENU $menu = GuiCtrlCreateMenu("&File") $fileopen = GUICtrlCreateMenuItem("Open ...", $menu) $fileexit = GuiCtrlCreateMenuItem("E&xit", $menu) GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE $msg = GuiGetMsg() If $msg = $fileopen then $chosen = FileOpenDialog("Choose file...", "q:\TOCs", "(*.TOC)", 1+2+4) If @error Then MsgBox(4096, "Whoops", "No files chosen") Else $path = StringSplit($chosen, "|") $realpath = $path[1] $i = 1 while $i < UBound($path) - 1 $wholething = $realpath & "\" & $path[$i + 1] MsgBox(4096, "You win!", "You chose " & $wholething) $i = $i + 1 WEnd EndIf EndIf if $msg = $fileexit then ExitLoop WEnd The open box works fine and at the mo, I'm just playing with the selection so I'm not worried about how I'm handling selections as I'm sure that'll all change/be removed. Anyway, my problem is that sometimes the Exit option works and sometimes it doesn't and like, if I select two TOC files, I then have to push the Exit option three times for it to actually exit, like there is something still hanging around from making the selection. Also, the normal red X close button in XP doesn't work either and has the same issues as the Exit option, you sometimes have to push it three or four times for it to take it. Sometimes even more randomly, I have to click on Open two or three times, you click it and it does nothing then for some reason it then goes ahead and brings up the file open dialog. Not making much sense to me at all! Is my loop structure fundamentally wrong or ... ? Link to comment Share on other sites More sharing options...
Zedna Posted January 26, 2009 Share Posted January 26, 2009 Try this: While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop if $msg = $fileexit then ExitLoop If $msg = $fileopen then $chosen = FileOpenDialog("Choose file...", "q:\TOCs", "(*.TOC)", 1+2+4) If @error Then MsgBox(4096, "Whoops", "No files chosen") Else $path = StringSplit($chosen, "|") $realpath = $path[1] $i = 1 while $i < UBound($path) - 1 $wholething = $realpath & "\" & $path[$i + 1] MsgBox(4096, "You win!", "You chose " & $wholething) $i = $i + 1 WEnd EndIf EndIf WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
yoinkster Posted January 27, 2009 Author Share Posted January 27, 2009 that's the badger thank you very much. 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