dexxa 0 Posted September 16, 2007 i have this script containing FileOpenDialog, for some reason FileOpenDialog keeps poping up even if i pick a file. add a game button launches fileopendialog. main loop expandcollapse popupWhile 1 $msg = GUIGetMsg() $i = 0 While $i < UBound($Button_list) If $msg = $Button_list[$i] Then Select Case $Program_list[$i] = "Exit" Exit Case $program_list[$i] = "Add a Game" SelectFile() resize_windows() case $program_list[$i] = "Change Row" ChangeRow() case $program_list[$i] = "Launch a Game" $program_list[$i] = "Remove a Game" GUICtrlSetData($Button_list[$i],"Remove a Game") $remove_flag = True Case $program_list[$i] = "Remove a Game" $program_list[$i] = "Launch a Game" GUICtrlSetData($Button_list[$i],"Launch a Game") $remove_flag = False Case Else If $remove_flag = True Then If $program_list[$i] <> "Launch a Game" Then If $program_list[$i] <> "Remove a Game" Then If $program_list[$i] <> "Change row" Then If $program_list[$i] <> "Add a Game" Then If $program_list[$i] <> "Exit" Then removebutton($i) resize_windows() EndIf EndIf EndIf EndIf EndIf Else Run($Address_list[$i]) Exit EndIf EndSelect ElseIf $msg = $GUI_EVENT_CLOSE Then Exit EndIf $i += 1 WEnd WEnd selectfile definition Func SelectFile() $file = FileOpen($file_dir,1) $directory = FileOpenDialog("Select a Executable", "..Desktop","Executable (*.exe)", 1+2) If $directory <> "" Then FileWriteLine($file,"game="&get_game_name($directory)) FileWriteLine($file,"exe="&$directory) Local $temp = IconButton(get_game_name($directory),0,0,100,100,-1,$directory,1) _ArrayInsert($Button_list,0,$temp) _ArrayInsert($program_list,0,get_game_name($directory)) _ArrayInsert($Address_list,0,$directory) $count += 1 EndIf FileClose($file) EndFunc Share this post Link to post Share on other sites
MadBoy 3 Posted September 18, 2007 bump First of all i am not sure if you need to check on (Case Else) if somebutton is "something". "Select" goes from top to bottom so it already knows that it's not "Add a game" or "exit" etc so i kinda commented the line out. If you realy need it check how i have put it all in one line. May be usefull for some other projects of yours. As for endless loop you don't give much information about $button_list value. How much is it? Maybe you should do "ExitLoop". If you realy want help post code that ppl can run and see what happens. To be able to reproduce it. Too much guessing with your code. expandcollapse popupWhile 1 $msg = GUIGetMsg() $i = 0 While $i < UBound($Button_list) If $msg = $Button_list[$i] Then Select Case $Program_list[$i] = "Exit" Exit Case $Program_list[$i] = "Add a Game" SelectFile() resize_windows () ; maybe put ExitLoop here? Case $Program_list[$i] = "Change Row" ChangeRow () Case $Program_list[$i] = "Launch a Game" $Program_list[$i] = "Remove a Game" GUICtrlSetData($Button_list[$i], "Remove a Game") $remove_flag = True Case $Program_list[$i] = "Remove a Game" $Program_list[$i] = "Launch a Game" GUICtrlSetData($Button_list[$i], "Launch a Game") $remove_flag = False Case Else If $remove_flag = True Then ;If $Program_list[$i] <> "Add a Game" And $Program_list[$i] <> "Exit" And $Program_list[$i] <> "Launch a Game" And $Program_list[$i] <> "Remove a Game" And $Program_list[$i] <> "Change row" And $Program_list[$i] <> "Add a Game" Then removebutton ($i) resize_windows () ;EndIf Else Run($Address_list[$i]) Exit EndIf EndSelect ElseIf $msg = $GUI_EVENT_CLOSE Then Exit EndIf $i += 1 WEnd WEnd Func SelectFile() $file = FileOpen($file_dir, 1) $directory = FileOpenDialog("Select a Executable", "..Desktop", "Executable (*.exe)", 1 + 2) If $directory <> "" Then FileWriteLine($file, "game=" & get_game_name ($directory)) FileWriteLine($file, "exe=" & $directory) Local $temp = IconButton (get_game_name ($directory), 0, 0, 100, 100, -1, $directory, 1) _ArrayInsert($Button_list, 0, $temp) _ArrayInsert($Program_list, 0, get_game_name ($directory)) _ArrayInsert($Address_list, 0, $directory) $count += 1 EndIf FileClose($file) EndFunc ;==>SelectFile My little company: Evotec (PL version: Evotec) Share this post Link to post Share on other sites
dexxa 0 Posted September 19, 2007 the whole thingyou will need GUIEnchance.au3 to run ithere: http://www.autoitscript.com/forum/index.ph...p;hl=guienhancescripted in vista, so you may need to change $file_dir for it to workexpandcollapse popup;~ #NoTrayIcon #include <GUIconstants.au3> #include <Array.au3> #include <File.au3> #include <GUIEnhance.au3> Opt("WinTitleMatchMode",3) ;~ Opt("GUICoordMode", 0) Global $width = 100,$height = 100 Global $button_height = 100,$button_width = 100 Global $Program_list[1],$Address_list[1],$Icon_list[1] Global $first_flag = True Global $EXE,$address, $count = 0,$command = "" Global $j = 0,$column = 0,$col Global $MAX_ROW,$MR_backup Global $parent Global $File_List Global $file_dir = "C:\Users\Dexxa\Documents\Game_Console.txt" Global $remove_flag = False, $changed = False Global $next_loc_x,$next_loc_y If FileExists($file_dir) = False Then _FileCreate($file_dir) FileWriteLine($file_dir,"MAX_ROW=2") FileWriteLine($file_dir,"game=Exit") FileWriteLine($file_dir,"exe=") EndIf _FileReadToArray($file_dir,$File_List) $MAX_ROW = $File_List[1] $MR_backup = $MAX_ROW $MAX_ROW = StringSplit($MAX_ROW,"=") $MAX_ROW = Int($MAX_ROW[$MAX_ROW[0]]) $MAX_ROW = Int($MAX_ROW) If IsNumber($MAX_ROW) = True Then If $MAX_ROW < 1 Or $MAX_ROW > 9 Then $MAX_ROW = 2 EndIf Else $MAX_ROW = 2 EndIf ;~;redo files For $i=2 To $File_List[0] If $File_List[$i] <> "" Then $temp = StringSplit($File_List[$i],"=") Switch $temp[1] Case "game" _ArrayAdd($Program_list,$temp[$temp[0]]) $count+=1 Case "exe" _ArrayAdd($Address_list,$temp[$temp[0]]) EndSwitch EndIf Next _ArrayDelete($Program_list,0) _ArrayDelete($Address_list,0) addbutton("Launch a Game","") addbutton("Add a Game","") addbutton("Change Row","") addbutton("Exit","") ;GUI Creation $col = Int($count/$MAX_ROW+.9) Global $Button_list[$count] $parent = GUICreate("",$width*$col,$height*$MAX_ROW,Default,Default) GUISetState() _GUIEnhanceAnimateTitle($parent,"GAME CONSOLE") Dim $P_grid[$MAX_ROW][$col] Global $win_size = WinGetPos("GAME CONSOLE") For $i = 0 To $count-1 If $j >= $MAX_ROW Then $j = 0 $column += $button_width EndIf $Button_list[$i] = IconButton($Program_list[$i],$column,$j*$button_height,$button_width,$button_height,-1,$Address_list[$i]) If $program_list[$i] = "Launch a Game" Then $remove = $Button_list[$i] $j += 1 Next _ArrayDelete($Icon_list,0) While 1 $msg = GUIGetMsg() $i = 0 While $i < UBound($Button_list) If $msg = $Button_list[$i] Then ;~ MsgBox(0,"",$msg&" , "&GUICtrlRead($msg));debug Select Case $Program_list[$i] = "Winamp" If $remove_flag = True Then removebutton($i) resize_windows() Else Run($Address_list[$i]) EndIf Case $Program_list[$i] = "Exit" Exit Case $program_list[$i] = "Add a Game" SelectFile() resize_windows() ;$msg = 0 case $program_list[$i] = "Change Row" ChangeRow() case $program_list[$i] = "Launch a Game" $program_list[$i] = "Remove a Game" GUICtrlSetData($Button_list[$i],"Remove a Game") $remove_flag = True Case $program_list[$i] = "Remove a Game" $program_list[$i] = "Launch a Game" GUICtrlSetData($Button_list[$i],"Launch a Game") $remove_flag = False Case Else If $remove_flag = True Then If $program_list[$i] <> "Launch a Game" Then If $program_list[$i] <> "Remove a Game" Then If $program_list[$i] <> "Change row" Then If $program_list[$i] <> "Add a Game" Then If $program_list[$i] <> "Exit" Then removebutton($i) resize_windows() EndIf EndIf EndIf EndIf EndIf Else Run($Address_list[$i]) Exit EndIf EndSelect ElseIf $msg = $GUI_EVENT_CLOSE Then Exit EndIf $i += 1 WEnd WEnd Func SelectFile() $directory = FileOpenDialog("Select a Executable", "C:\Documents and Settings\dexxa\Desktop","Executable (*.exe)");, 1+2) If $directory <> "" Then $file = FileOpen($file_dir,1) FileWriteLine($file,"game="&get_game_name($directory)) FileWriteLine($file,"exe="&$directory) Local $temp = IconButton(get_game_name($directory),0,0,100,100,-1,$directory,1) _ArrayInsert($Button_list,0,$temp) _ArrayInsert($program_list,0,get_game_name($directory)) _ArrayInsert($Address_list,0,$directory) $count += 1 FileClose($file) EndIf EndFunc Func ChangeRow() Local $row Local $offset = 30 $oldsize = WinGetPos("GAME CONSOLE") $child = GUICreate("Change Maximum Rows 1 - 10 only", 300,60,$oldsize[0],$oldsize[1]) GUISetState(@SW_SHOW,$child) $ok = GUICtrlCreateButton("OK",140,15,70,30) $cancel = GUICtrlCreateButton("Cancel",220,15,70,30) $input = GUICtrlCreateInput("",10,18,120,20,BitOR($ES_NUMBER,$ES_RIGHT)) GUICtrlSetState ( $input, $GUI_FOCUS ) While 1 $child_msg = GUIGetMsg() If $child_msg = $GUI_EVENT_CLOSE Or $child_msg = $cancel Then GUIDelete($child) ExitLoop ElseIf $child_msg = $ok Or _IsPressed('0d') = True Then $input = GUICtrlRead($input) If $input <> "" Then If $input < 1 Or $input > 9 Then $input = 3 EndIf Else $input = 3 EndIf $row = $input $input = "MAX_ROW="&$input _ReplaceStringInFile($file_dir,$MR_backup,$input,Default,0) GUIDelete($child) $new_height = $row * $height $old_height = $MAX_ROW * $height If $old_height <= $new_height Then $stepping = 10 Else $stepping = -10 EndIf $oldsize = WinGetPos("GAME CONSOLE") If $old_height <> $new_height Then For $i = $old_height To $new_height + $offset Step $stepping WinMove("GAME CONSOLE","",$oldsize[0],$oldsize[1],$oldsize[2],$i) Next EndIf $MAX_ROW = $row resize_windows() ExitLoop EndIf WEnd EndFunc Func resize_windows() Local $offset $oldsize = WinGetPos("GAME CONSOLE") $oldwidth = $oldsize[2] $col = Int($count/$MAX_ROW+.9) $newwidth = $col * $width Local $stepping If $newwidth < $oldwidth Then $stepping = -5 $offset = 5 Else $stepping = 5 $offset = 10 EndIf If $oldwidth <> $newwidth Then ;~ WinMove("GAME CONSOLE","",$oldsize[0],$oldsize[1],$oldsize[2]+$offset,$oldsize[3]) For $i = $oldsize[2] To $newwidth + $offset Step $stepping WinMove("GAME CONSOLE","",$oldsize[0],$oldsize[1],$i,$oldsize[3]) Next EndIf rearrange_butt() EndFunc Func rearrange_butt() $j = 0 $column = 0 For $i = 0 To $count-1 If $j >= $MAX_ROW Then $j = 0 $column += $button_width EndIf GUICtrlSetPos($Button_list[$i],$column,$j*$button_height) GUICtrlSetPos($Icon_list[$i],$column+25,$j*$button_height+25) $j += 1 Next EndFunc Func get_game_name($directory) If $directory <> "" Then $temp = StringSplit($directory,"\") $temp = $temp[$temp[0]] $temp = StringSplit($temp,".") Return $temp[1] EndIf EndFunc Func addbutton($name,$addr) _ArrayAdd($program_list,$name) _ArrayAdd($Address_list,$addr) $count += 1 EndFunc Func removebutton($index) Local $filearray[1] Local $target _FileReadToArray ($file_dir,$filearray) GUICtrlSetState($Button_list[$index],$GUI_HIDE) GUICtrlSetState($Icon_list[$index],$GUI_HIDE) $pos = ControlGetPos("GAME CONSOLE","",$Button_list[$index]) Local $Previous_x = $pos[0] Local $Previous_y = $pos[1] For $i = $index+1 To UBound($Button_list) - 1 $pos = ControlGetPos("GAME CONSOLE","",$Button_list[$i]) _GUIEnhanceCtrlDrift($parent,$Button_list[$i],$Previous_x,$Previous_y,30) _GUIEnhanceCtrlDrift($parent,$Icon_list[$i],$Previous_x+25,$Previous_y+25,30) $Previous_x = $pos[0] $Previous_y = $pos[1] Next $target = $program_list[$index] If $target <> "" Then For $i = 1 To $filearray[0] $loc = StringInStr($filearray[$i],$target) If $loc <> 0 Then _ArrayDelete($filearray,$i) _ArrayDelete($filearray,$i) $filearray[0] = $filearray[0] - 2 ;update the file _FileWriteFromArray($file_dir,$filearray,1) ExitLoop EndIf Next EndIf GUICtrlDelete($Button_list[$index]) GUICtrlDelete($Icon_list[$index]) _ArrayDelete($Button_list,$index) _ArrayDelete($Icon_list,$index) _ArrayDelete($program_list,$index) $count = $count - 1 EndFunc ;IMAGE BUTTON FUNCTIONS Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum ,$BIDLL = "",$mode = 0) Local $x = Random(0,$win_size[2],1),$y = Random(0,$win_size[3],1) Local $speed = 70 $temp = GUICtrlCreateIcon($BIDLL, $BIconNum, $x,$y, 50, 50) If $mode = 1 Then _ArrayInsert($Icon_list,0,$temp) Else _ArrayAdd($Icon_list,$temp) EndIf GUICtrlSetState( -1, $GUI_DISABLE) If $BIDLL = "" Then $style = 0 Else $style = $BS_BOTTOM EndIf $XS_btnx = GUICtrlCreateButton($BItext,$x,$y, $BIwidth, $BIheight, BitOR($WS_CLIPSIBLINGS,$style)) _GUIEnhanceCtrlDrift($parent,$XS_btnx,$BIleft,$BItop,$speed) _GUIEnhanceCtrlDrift($parent,$temp,$BIleft + 25, $BItop + (($BIheight - 50 ) / 2),$speed) Return $XS_btnx EndFunc Share this post Link to post Share on other sites