; ---------------------------------------------------------------------------- ; ; Title: Invertor ; Version: 1.0 ; Author: © 2006 James Bench ; AutoIt Version: 3.1.0 ; ; Script Function: ; Interactive logical game for one player. ; ; ---------------------------------------------------------------------------- ; Import constants for GUI #include ; Hide tray icon #NoTrayIcon ; Some constants const $TITLE="Invertor" ; application name const $VERSION="1.0" ; software version const $AUTHOR="© 2006 James Bench" ; copyrite const $REGS = "HKEY_CURRENT_USER\Software\" ; key in registry const $size=400 ; size of main window const $min="05041528334025" ; Pack these files into application and unpack them in TEMP directory ;FileInstall ("InvertorHelp.exe", @TempDir&"\") ; also help file can be packed ; Setting some parameters Opt ("GUIOnEventMode", 1) ; we are running in event mode (it much more faster) Opt ("TrayIconHide", 1) ; hide tray icon (we've done it, but ...) ; Global variables ; we need to access them from inside the functions global $endofgame=0, $fields=5, $butt[9][9], $but[9][9], $moves, $move, $stack="" global $undobutt, $undomenu, $fld[7], $mainwindow, $helpwindow, $names[7], $scores[7] global $lastname="", $mute=0, $muteitem, $compact=0, $dir="resources\", $helpdir="" ; !!! NOTE THIS !!! ; If you want to create compact application (with all resources, except help), ; uncomment line '#include "Compact.au3"' ; If you want to create full compact application (with help, too), ; uncomment line '#include "FullCompact.au3"' ;#include "Compact.au3" ;#include "FullCompact.au3" ; Init highscores - names and scores for $i = 0 to 6 $names[$i] = "---" $scores[$i] = 999 next ; Create main window $mainwindow = GUICreate ($TITLE & " " & $VERSION, $size, $size+80) ; MENUS ; Create file menu, two menu items (with separator) and set functions on events $filemenu = GUICtrlCreateMenu ("&Game") ; Create menu item and set function on event ; This item will start new game GUICtrlCreateMenuItem ("&New Game (Ctrl-N)", $filemenu) GUICtrlSetOnEvent (-1, "NextGame") ; Create separator GUICtrlCreateMenuItem ("", $filemenu) ; Create menu item and set function on event ; This item will exit game GUICtrlCreateMenuItem ("E&xit Game (Ctrl-X)", $filemenu) GUICtrlSetOnEvent (-1, "ExitGame") ; Create options menu $optionmenu = GUICtrlCreateMenu ("&Options") ; Create menu item, set function on event and disable it ; we use variable, because we'll need later to change state of this menu ; This item will undo last move $undomenu = GUICtrlCreateMenuItem ("Undo Move (Ctrl-Z)", $optionmenu) GUICtrlSetOnEvent (-1, "Pop") GUICtrlSetState (-1, $GUI_DISABLE) ; Create separator GUICtrlCreateMenuItem ("", $optionmenu) ; Create submenu $fieldmenu = GUICtrlCreateMenu ("&Field Size", $optionmenu) ; Create menu items and set function on events ; we use array, because there is just one function on all these items and in this ; function we need to decide, which menu item was selected ; These items will select size of game field $fld[0] = GUICtrlCreatemenuItem ("&3x3", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[1] = GUICtrlCreatemenuItem ("&4x4", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[2] = GUICtrlCreatemenuItem ("&5x5", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[3] = GUICtrlCreatemenuItem ("&6x6", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[4] = GUICtrlCreatemenuItem ("&7x7", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[5] = GUICtrlCreatemenuItem ("&8x8", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") $fld[6] = GUICtrlCreatemenuItem ("&9x9", $fieldmenu) GUICtrlSetOnEvent (-1, "Field") ; Create menu item and set function on event ; This item will show high scores GUICtrlCreateMenuItem ("High &Scores (Ctrl-S)", $optionmenu) GUICtrlSetOnEvent (-1, "ShowHighScores") ; Create separator GUICtrlCreateMenuItem ("", $optionmenu) ; Create sound mute menu item ; This item will control muting sound $muteitem = GUICtrlCreateMenuItem ("&Mute sound (Ctrl-M)", $optionmenu) GUICtrlSetOnEvent (-1, "Mute") ; Create help menu $helpmenu = GUICtrlCreateMenu ("&Help") ; Create menu item and set function on event GUICtrlCreateMenuItem ("&Help (F1)", $helpmenu) GUICtrlSetOnEvent (-1, "Help") ; Create separator GUICtrlCreateMenuItem ("", $helpmenu); ; Create menu item and set function on event GUICtrlCreateMenuItem ("&About "&$TITLE&" ... (Ctrl-A)", $helpmenu) GUICtrlSetOnEvent (-1, "About") ; MENUS END ; BOTTOM PART OF WINDOW ; Create group GUICtrlCreateGroup ("", 5, 400, 390, 50) ; Create button and set function on event ; This button will start new game GUICtrlCreateButton ("New Game", 20, 413, 80, 30) GUICtrlSetOnEvent (-1, "NextGame") ; Create button, set function on event and disable it ; This button will undo last move GUICtrlCreateButton ("Undo", 300, 413, 80, 30) GUICtrlSetOnEvent (-1, "Pop") GUICtrlSetState (-1, $GUI_DISABLE) ; Create static label and set font GUICtrlCreateLabel ("Moves:", 150, 420, 50) GUICtrlSetFont (-1, 10, 800) ; Create static label and set font ; To this static field we'll write actual number of moves $moves = GUICtrlCreateLabel ("0", 210, 420, 35) GUICtrlSetFont (-1, 10, 800) ; BOTTOM PART OF WINDOW END ; INIT GAME ; Try to read register with game title $x = RegRead ($REGS & "Invertor", "Title") ; Register not found, so this is first run ever on this machine if $x = "" then ; Write title, version and author into registers (other will be written at the end of game) RegWrite ($REGS & "Invertor", "Title", "REG_SZ", $TITLE); RegWrite ($REGS & "Invertor", "Version", "REG_SZ", $VERSION); RegWrite ($REGS & "Invertor", "Author", "REG_SZ", $AUTHOR); ; Creating text splash - set message and clear displayed part of message $msg = $TITLE & " " & $VERSION & @LF & $AUTHOR & @LF & "This game was created with" & @LF & "AutoIt v3" $tmp = "" ; Wait some time (500 ms) sleep (500) ; Show text splash window SplashTextOn ("Splash", "", 200, 82, -1, -1, 1) ; For all characters in the message do next ... for $i = 1 to StringLen ($msg) ; Add next character to displayed message, show it and wait 100ms $tmp = $tmp & StringMid ($msg, $i, 1) ControlSetText("Splash", "", "Static1", $tmp) sleep (100) next ; Wait 3s sleep (3000) ; End of first time ever run endif ; Show splash window, wait 3s and remove splash window SplashImageOn ("Splash", $dir&"splash.jpg", 600, 400, -1, -1, 1) sleep (3000) SplashOff () ; Create new game NewGame () ; If it is not first run ever, load settings from registers and show them if $x <> "" then Load () ; Set function on window close button GUISetOnEvent ($GUI_EVENT_CLOSE, "ExitGame") ; Set hot keys for menus HotKeySet ("{F1}", "Help") HotKeySet ("^x", "ExitGame") HotKeySet ("^n", "NextGame") HotKeySet ("^a", "About") HotKeySet ("^s", "ShowHighScores") ; Show created window GUISetState () ; INIT END ; LOOP ; While not end of game, repeat 100ms sleeping ; When something will happen in the window, there will be called automatically appropriate function while $endofgame = 0 sleep (100) wend ; LOOP END ; Game ended, delete temporary files if $compact > 0 then FileDelete ($dir&"splash.jpg") FileDelete ($dir&"red.bmp") FileDelete ($dir&"white.bmp") FileDelete ($dir&"Cup.ico") FileDelete ($dir&"Trophy.ico") FileDelete ($dir&"Invertor.ico") FileDelete ($dir&"AutoIt.bmp") FileDelete ($dir&"victory.wav") FileDelete ($dir&"winner.wav") FileDelete ($dir&"highscores.wav") FileDelete ($dir&"about.wav") FileDelete ($dir&"click.wav") endif if $compact > 1 then FileDelete ($dir&"InvertorHelp.exe") endif ; END OF MAIN SCRIPT ; FUNCTIONS ; Function NewGame ; Creates all the buttons on canvas and sets appropriate function on events ; We need to use array to select, which button was pressed func NewGame() ; Compute size of button and left indentation $siz = int(($size-($fields-1)*1-10)/$fields) $left = int(($size-$fields*$siz-($fields-1)*1)/2) ; For all field do next ... for $i = 1 to $fields for $j = 1 to $fields ; Create button, set function on event, set button color and set indicator of his filed $butt[$i-1][$j-1]=GUICtrlCreateButton ("", ($j-1)*($siz+1)+$left, ($i-1)*($siz+1)+$left, $siz, $siz, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP), $WS_EX_CLIENTEDGE) GUICtrlSetOnEvent (-1, "ProcessButton") GUICtrlSetImage (-1, $dir&"white.bmp") $but[$i-1][$j-1] = 0 next next ; Number of moves is 0 and there are no undoable moves $move = 0 $stack = "" ; Show number of moves GUICtrlSetData ($moves, $move) ; Disable undo menu item and undo button GUICtrlSetState ($undobutt, $GUI_DISABLE) GUICtrlSetState ($undomenu, $GUI_DISABLE) ; Clear hot key for undo HotKeySet ("^z") ; Show window GUISetState () endfunc ; Function NextGame ; Clears actual game and start new func NextGame() ; Destroy buttons and start new game DestroyButtons () NewGame () endfunc ; Function ExitGame ; Exits game func ExitGame() ; Save actual game into registers, wait 100ms and set indicator for ending loop Save () sleep (100) $endofgame = 1 endfunc ; Function DestroyButtons func DestroyButtons () ; For all fields delete buttons for $i = 0 to $fields-1 for $j = 0 to $fields-1 GUICtrlDelete ($butt[$i][$j]) next next endfunc ; Function ProcessButton ; Called with click on field button, does all needed actions func ProcessButton () ; For all field button do next ... for $i = 0 to $fields-1 for $j = 0 to $fields-1 ; If it is correct button, do move, save this move for undoing, ; increment number of moves and exit from loop if @GUI_CtrlId = $butt[$i][$j] then DoMove ($i, $j) Push (10*$i+$j) $move = $move + 1 exitloop 2 endif next next ; Show new number of moves GUICtrlSetData ($moves, $move) ; Play click sound PlaySound ("click.wav") ; Test if there is all red ; White is 0, red is one, so we sum all values $s = 0 for $i = 0 to $fields-1 for $j = 0 to $fields-1 $s = $s + $but[$i][$j] next next ; If sum is same as number of field buttons, all is red, ; so show winner window if $s = $fields*$fields then ShowVictory () endif endfunc ; Function DoMove ; Does all actions on selected button func DoMove($i, $j) ; Flip actual button FlipButton ($i, $j) ; If it's not the most left button, flip next left button if $i > 0 then FlipButton ($i-1, $j) endif ; If it's not the most upper button, flip next upper button if $j > 0 then FlipButton ($i, $j-1) endif ; If it's not the most right button, flip next right button if $i < $fields-1 then FlipButton ($i+1, $j) endif ; If it's not the most lower button, flip next lower button if $j < $fields-1 then FlipButton ($i, $j+1) endif endfunc ; Function FlipButton ; Flips one button func FlipButton ($x, $y) ; Change state of the button (from 0 to 1 or otherwise) $but[$x][$y] = 1 - $but[$x][$y] ; If it should be white, set button color to white, else set button color to red if $but[$x][$y] = 0 then GUICtrlSetImage ($butt[$x][$y], $dir&"white.bmp") else GUICtrlSetImage ($butt[$x][$y], $dir&"red.bmp") endif endfunc ; Function Push ; Saves actual move to the array of moves func Push($val) ; If there are some moves, increase array and save actual move to last element if IsArray($stack) then redim $stack[UBound($stack)+1] $stack[UBound($stack)-1] = $val else ; There are no moves before, so it is first move of the game ; Create new array (just one element) and set value dim $stack[1] $stack[0] = $val ; This is first move, so now we can undo moves ; Enable both undo menu item and undo button and set hot key to menu item GUICtrlSetState ($undobutt, $GUI_ENABLE) GUICtrlSetState ($undomenu, $GUI_ENABLE) HotKeySet ("^z", "Pop") endif endfunc ; Function Pop ; Undoes last move func Pop() ; Get last move and split it into coordinates in game field $y = $stack[UBound($stack)-1] $x = int($y/10) $y = $y - 10*$x ; If no undoable moves left, clear array, disable undo menu item and button and ; clear hot key if UBound($stack) = 1 then $stack = "" GUICtrlSetState ($undobutt, $GUI_DISABLE) GUICtrlSetState ($undomenu, $GUI_DISABLE) HotKeySet ("^z") else ; Some undoable moves left, so decrease size of the array redim $stack[UBound($stack)-1] endif ; Do last move again (it is the same as undo last move) DoMove ($x, $y) ; Decrease number of moves and show it $move = $move - 1 GUICtrlSetData ($moves, $move) endfunc ; Function Field ; It is called, when user want to change field size func Field() ; For all menu items from submenu, test if it is selected menu item ; If so, exit loop for $i = 0 to 6 if @GUI_CtrlId = $fld[$i] then exitloop next ; Clear canvas, set new size and make new game DestroyButtons () $fields = $i+3 NewGame () endfunc ; Function Save ; Saves actual game and high scores to registry func Save() ; Create string, which describes actual game ; Clear value $val="" ; For all buttons add value (0 or 1) to the string for $i = 0 to $fields-1 for $j = 0 to $fields-1 $val=$val & $but[$i][$j] next next ; Create string, in which are all undoable moves ; Clear moves and temporary variables $mov="" $tmp="" ; For all undoable moves from the array copy value to temporary value for $i = 0 to UBound($stack)-1 $tmp=$stack[$i] ; If it is just one character, add "0" before it if $stack[$i] < 10 then $tmp="0"&$tmp ; Add temporary value to the end of moves value $mov=$mov & $tmp next ; Write size of game field, state of game, number of moves, all undoable moves, ; last used name in winner dialog to registry and mute sound indicator RegWrite ($REGS & "Invertor\SavedGame", "FieldSize", "REG_SZ", $fields) RegWrite ($REGS & "Invertor\SavedGame", "Fields", "REG_SZ", $val) RegWrite ($REGS & "Invertor\SavedGame", "Moves", "REG_SZ", $move) RegWrite ($REGS & "Invertor\SavedGame", "Stack", "REG_SZ", $mov) RegWrite ($REGS & "Invertor\Scores", "LastName", "REG_SZ", $lastname) RegWrite ($REGS & "Invertor\SavedGame", "Mute", "REG_SZ", $mute) ; Create list of high scores (names and scores) ; Clear string $hs = "" ; For all array elements do next ... for $i = 0 to 6 ; If it's not start of list, add LF (delimiter) if $i > 0 then $hs = $hs & @LF ; Add name, delimiter and score $hs = $hs & $names[$i] & @LF & $scores[$i] next ; Write list to registry RegWrite ($REGS & "Invertor\Scores", "HighScores", "REG_MULTI_SZ", $hs) endfunc ; Function Load ; Load actual game and high scores from registry func Load() ; Clear canvas DestroyButtons () ; Load last name, used in winner dialog and high scores list from registry $lastname = RegRead ($REGS & "Invertor\Scores", "LastName") $hs = RegRead ($REGS & "Invertor\Scores", "HighScores") ; Split list into array with LF as delimiter $arr = StringSplit ($hs, @LF) ; For all array copy elements to name and score for $i = 0 to 6 $names[$i] = $arr[2*$i+1] $scores[$i] = $arr[2*$i+2] next ; Load size of the game field and start new game $fields = RegRead ($REGS & "Invertor\SavedGame", "FieldSize") NewGame () ; Load nomber of moves, game state, last moves and mute sound indicator $move = RegRead ($REGS & "Invertor\SavedGame", "Moves") $val = RegRead ($REGS & "Invertor\SavedGame", "Fields") $mov = RegRead ($REGS & "Invertor\SavedGame", "Stack") $mute = RegRead ($REGS & "Invertor\SavedGame", "Mute") ; Sets check on mute menu item if $mute = 1 then GUICtrlSetState ($muteitem, $GUI_CHECKED) ; Set appropriate button colors ; Clear index to string $l=0 ; For all game buttons do next ... for $i = 0 to $fields-1 for $j = 0 to $fields-1 ; Increment index to string, get color (one character: "1" or "0") and ; set it to indicator array element $l = $l + 1 $but[$i][$j] = StringMid ($val, $l, 1) ; If color must be red, set button color to red, else set button color to white if $but[$i][$j] = 1 then GUICtrlSetImage ($butt[$i][$j], $dir&"red.bmp") else GUICtrlSetImage ($butt[$i][$j], $dir&"white.bmp") endif next next ; Show number of moves GUICtrlSetData ($moves, $move) ; Set all undoable moves ; Get length of string divided by two (every element is two characters wide) $l = StringLen ($mov) / 2 ; If there are some undoable moves, set size of array and copy 2-chars value into each field if $l > 0 then dim $stack[$l] for $i = 0 to $l-1 $stack[$i] = StringMid ($mov, 2*$i+1, 2) next else ; There are no undoable moves, so clear array $stack = "" endif ; If there are undoable moves, enable undo button and menu item and set hot key if $move > 0 then GUICtrlSetState ($undobutt, $GUI_ENABLE) GUICtrlSetState ($undomenu, $GUI_ENABLE) HotKeySet ("^z", "Pop") endif endfunc ; Function PlaySound ; Plays sound and wait for it func PlaySound($file) if $mute = 0 then SoundPlay ($dir&$file, 1) endfunc ; Function Mute ; Enables or disables sound func Mute() $mute = 1 - $mute if $mute = 0 then GUICtrlSetState ($muteitem, $GUI_UNCHECKED) else GUICtrlSetState ($muteitem, $GUI_CHECKED) endif endfunc ; Function ShowVictory ; Shows winner dialog and if it is high score, asks for users name func ShowVictory() ; If it is new high score set indicator, height of dialog and position of OK button fro top if $move < $scores[$fields-3] then $ind = 1 $hght = 240 $dwn = 150 $snd = "\victory.wav" else $ind = 0 $hght = 190 $dwn = 100 $snd = "\winner.wav" endif ; Set all parameters for dialog window (see AutoIt help) $flg = BitOr($GUI_SS_DEFAULT_GUI, $WS_DLGFRAME, $DS_MODALFRAME, $DS_SETFOREGROUND) $flg = BitAnd ($flg, not $WS_MAXIMIZEBOX, not $WS_MINIMIZEBOX) ; Create winner dialog, icon, label and set font and color to label GUICreate ("Winner!", 310, $hght, -1, -1, $flg, $WS_EX_TOPMOST) GUICtrlCreateIcon ($dir&"Cup.ico", -1, 50, 10, 48, 48) GUICtrlCreateLabel ("You win !!!", 100, 15, 200, 50) GUICtrlSetFont (-1, 20, 1000) GUICtrlSetColor (-1, 0xebb60d) ; If it is new high score, create labels (with font and colors) and input field if $ind = 1 then GUICtrlCreateLabel ("And you reached highest score.", 45, 60, 250) GUICtrlSetFont (-1, 10, 600, 2) GUICtrlSetColor (-1, 0x0000ff) GUICtrlCreateLabel ("Enter your name:", 60, 90, 150) GUICtrlSetFont (-1, -1, 600) $input = GUICtrlCreateInput ($lastname, 60, 105, 180, -1, $ES_NOHIDESEL) GUISetState (-1, $GUI_FOCUS) else ; If it is not new high score, create label (with font and color) GUICtrlCreateLabel ("But you didn't reach high score.", 50, 60, 250) GUICtrlSetFont (-1, 10, 600, 2) GUICtrlSetColor (-1, 0x0000ff) endif ; Create OK button $ok = GUICtrlCreateButton ("OK", 110, $dwn, 80, -1, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) ; Disable event mode (just one active control, we'll test it in the loop) Opt ("GUIOnEventMode", 0) ; Disable ok button GUICtrlSetState ($ok, $GUI_DISABLE) ; Show dialog GUISetState () ; Play sound and enable ok button PlaySound ($snd) GUICtrlSetState ($ok, $GUI_ENABLE) ; Wait for OK button press while 1 $msg = GUIGetMsg() if $msg = $ok then exitloop wend ; If it is new high score, read input and if it is not empty, set name and score ; to high score array if $ind = 1 then $lastname = GUICtrlRead ($input) if $lastname <> "" then $names[$fields-3] = $lastname $scores[$fields-3] = $move endif endif ; Delete dialog GUIDelete () ; Set again event mode Opt ("GUIOnEventMode", 1) ; Switch back to the main window GUISwitch ($mainwindow) ; Start new game NextGame () endfunc ; Function ShowHighScores ; Show high scores table func ShowHighScores() ; Local array - IDs of static labels local $scr[7][2] ; Default of clear button is diabled $enbl = 0 ; Set all parameters for dialog window (see AutoIt help) $flg = BitOr($GUI_SS_DEFAULT_GUI, $WS_DLGFRAME, $DS_MODALFRAME, $DS_SETFOREGROUND) $flg = BitAnd ($flg, not $WS_MAXIMIZEBOX, not $WS_MINIMIZEBOX) ; Create high score dialog, icon, main label and set font and color to label GUICreate ("High Scores", 420, 270, -1, -1, $flg, $WS_EX_TOPMOST) GUICtrlCreateIcon ($dir&"Trophy.ico", -1, 100, 10, 48, 48) GUICtrlCreateLabel ("High Scores", 150, 15, 200, 50) GUICtrlSetFont (-1, 20, 1000) GUICtrlSetColor (-1, 0xebb60d) ; For all element of high score table do next ... for $i = 3 to 9 ; Create field size label and its font and color $lbl = ""&$i&" x "&$i GUICtrlCreateLabel ($lbl, 40, 18*$i, 40) GUICtrlSetFont (-1, 12, 800) GUICtrlSetColor (-1, 0x0000ff) ; Create score element and set its font $m = StringMid ($min, 2*$i-5, 2) + 0 $m = ""&$scores[$i-3]&" moves (min: "&$m&")" $scr[$i-3][0] = GUICtrlCreateLabel ($m, 90, 18*$i+1, 130) GUICtrlSetFont (-1, 10) ; Create name element and set its font $scr[$i-3][1] = GUICtrlCreateLabel ($names[$i-3], 230, 18*$i+1, 150) GUICtrlSetFont (-1, 10, 800) ; If score is better then 999, enable clear button if $scores[$i-3] <> 999 then $enbl = 1 next ; Create ok and clear buttons $ok = GUICtrlCreateButton ("OK", 80, 195, 80, -1, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) $clr = GUICtrlCreateButton ("Clear", 260, 195, 80) ; Disable event mode (just two active controls, we'll test it in the loop) Opt ("GUIOnEventMode", 0) ; Disable buttons GUICtrlSetState ($ok, $GUI_DISABLE) GUICtrlSetState ($clr, $GUI_DISABLE) ; Show dialog GUISetState () ; Play sound PlaySound ("highscores.wav") ; Enable buttons, clear button is enabled conditionaly GUICtrlSetState ($ok, $GUI_ENABLE) if $enbl = 1 then GUICtrlSetState ($clr, $GUI_ENABLE) ; Start loop while 1 ; Get event $msg = GUIGetMsg() ; If it is ok button then exit loop if $msg = $ok then exitloop ; if it is clear button, clear all scores, set new labels and disable clear button if $msg = $clr then for $i = 0 to 6 $names[$i] = "---" $scores[$i] = 999 GUICtrlSetData ($scr[$i][0], "999 moves") GUICtrlSetData ($scr[$i][1], "---") GUICtrlSetState ($clr, $GUI_DISABLE) next endif wend ; Set again event mode GUIDelete () ; Switch back to the main window Opt ("GUIOnEventMode", 1) ; Switch back to the main window GUISwitch ($mainwindow) endfunc ; Function About ; Shows About dialog func About() ; Set all parameters for dialog window (see AutoIt help) $flg = BitOr($GUI_SS_DEFAULT_GUI, $WS_DLGFRAME, $DS_MODALFRAME, $DS_SETFOREGROUND) $flg = BitAnd ($flg, not $WS_MAXIMIZEBOX, not $WS_MINIMIZEBOX) ; Create dialog, icon, and labels (with fonts and colors) GUICreate ("About "&$TITLE, 310, 310, -1, -1, $flg, $WS_EX_TOPMOST) GUICtrlCreateIcon ($dir&"Invertor.ico", -1, 70, 20, 32, 32) GUICtrlCreateLabel ($TITLE&" v"&$VERSION, 120, 15, 110, 50) GUICtrlSetFont (-1, 14, 1000) GUICtrlSetColor (-1, 0x0000ff) GUICtrlCreateLabel ($AUTHOR, 120, 40, 200, 50) GUICtrlSetFont (-1, 11, 1000) GUICtrlSetColor (-1, 0x0000ff) GUICtrlCreateLabel ("Distributed under GNU GPL.", 50, 60, 210) GUICtrlSetFont (-1, -1, 600, 2) GUICtrlCreateLabel ("You can use, copy, distribute and modify it as you like.", 25, 80, 260) GUICtrlCreateLabel ("Created with", 110, 110, 90) GUICtrlSetFont (-1, 10, 600) ; Create picture GUICtrlCreatePic ($dir&"AutoIt.bmp", 35, 125, 240, 100) ; Create OK button $ok = GUICtrlCreateButton ("OK", 115, 240, 80, -1, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) ; Disable event mode (just one active control, we'll test it in the loop) Opt ("GUIOnEventMode", 0) ; Disable ok button GUICtrlSetState ($ok, $GUI_DISABLE) ; Show dialog GUISetState () ; Play sound and enable ok button PlaySound ("about.wav") GUICtrlSetState ($ok, $GUI_ENABLE) ; Wait for OK button press while 1 $msg = GUIGetMsg() if $msg = $ok then exitloop wend ; Delete dialog GUIDelete () ; Set again event mode Opt ("GUIOnEventMode", 1) ; Switch back to the main window GUISwitch ($mainwindow) endfunc ; Function Help ; Shows help - independent application, created with eBook Maestro func Help() ; Run InvertorHelp application and wait for end of it RunWait ($helpdir&"InvertorHelp.exe") ; If there was accidental click to close main window, ignore it $endofgame = 0 endfunc ; END OF SCRIPT