;****************************************************************************** ;* Script : DieRoller.au3 ;* ;* Description : Die Roller ;* ;* Language : Auto-It v3 - http://www.autoitscript.com/autoit3/ ;****************************************************************************** ;* Program History: ;* ;* Version : 1.0.3 ;* Author : Craig H. Rettig ;* Date : 01 Oct 2007 ;* Notes : Recompiled with AutoIt 3.2.6.0 in ANSI format for ;* 9x/NT compatability ;* ;* Version : 1.0.2 ;* Author : Craig H. Rettig ;* Date : 04 May 2007 ;* Notes : Recompiled with AutoIt 3.2.2.0 ;* ;* Version : 1.0.1 ;* Author : Craig H. Rettig ;* Date : 28 Nov 2006 ;* Notes : Duh... forgot to add d12 support ;* ;* Version : 1.0.0 ;* Author : Craig H. Rettig ;* Date : 14 Sep 2006 ;* Notes : Initial release ;****************************************************************************** ;* This program is free software. It comes without any warranty, to ;* the extent permitted by applicable law. You can redistribute it ;* and/or modify it under the terms of the Do What The F*** You Want ;* To Public License, Version 2, as published by Sam Hocevar. See ;* http://sam.zoy.org/wtfpl/COPYING for more details. ;****************************************************************************** #include ; Global variable declarations ; Global customization variables Global $AppName = "Craig's Die Roller" Global $AppCo = "Craig H. Rettig" Global $AppSite = "http://www.bitbucketheaven.com/software/craigs-die-roller/" Global $AppEmail = "support@bitbucketheaven.com" Global $AppVersion = "1.0.3" ; Other globals Global $hlpFile = "" Func RollDie($intMax, $intNumDie) Local $x, $strOut, $intResult, $intTotal $intTotal = 0 $strOut = "" For $x = 1 to $intNumDie $intResult = Random(1, $intMax, 1) $strOut = $strOut & " " & String($intResult) $intTotal = $intTotal + $intResult Next GUICtrlSetData($txtResult, StringStripWS($strOut, 3)) GUICtrlSetData($txtTotal, "Sum: " & String($intTotal)) EndFunc ;****************************************************************************** ;****************************** CREATE THE GUI ****************************** ;****************************************************************************** ; Window GuiCreate($AppName, 400, 170, -1, -1) GuiSetIcon("Z:\Code\Auto-It3\dice.ico", 0) ; Set path to Help file If @compiled = 1 Then $hlpFile = StringReplace(@AutoItExe, ".exe", ".txt") Else $hlpFile = StringReplace(@ScriptFullPath, ".au3", ".txt") EndIf ; File Menu $mnuFile = GuiCtrlCreateMenu("&File") $mnuFileExit = GUICtrlCreateMenuitem("E&xit", $mnuFile) ; Help Menu $mnuHelp = GuiCtrlCreateMenu("&Help") $mnuHelpReadme = GUICtrlCreateMenuitem("&Read Me", $mnuHelp) $mnuHelpWebSite = GUICtrlCreateMenuitem("Application &Home Page", $mnuHelp) $mnuHelpLine = GUICtrlCreateMenuitem("", $mnuHelp) $mnuHelpAbout = GUICtrlCreateMenuitem("&About " & $AppName & "...", $mnuHelp) ; Die Interface $cmbTlDie = GUICtrlCreateCombo("2", 160, 7, 55, -1, $CBS_DROPDOWNLIST + $CBS_AUTOHSCROLL + $WS_VSCROLL) GUICtrlSetData($cmbTlDie,"3|4|6|8|10|12|20|100", "6") GUICtrlSetFont($cmbTlDie, 10, 400, 1, "Arial") $cmbNumDie = GUICtrlCreateCombo("1", 85, 7, 45, -1, $CBS_DROPDOWNLIST + $CBS_AUTOHSCROLL + $WS_VSCROLL) GUICtrlSetData($cmbNumDie,"2|3|4|5|6|7|8|9|10|11|12|13|14|15") GUICtrlSetFont($cmbNumDie, 10, 400, 1, "Arial") $lblDee = GUICtrlCreateLabel("d", 135, 8, 20, 25, $SS_CENTER) GUICtrlSetFont($lblDee, 14, 400, 1, "Arial") $cmdRoll = GUICtrlCreateButton("&Roll 'Em!", 220, 5, 100, 27, $BS_CENTER) GUICtrlSetFont($cmdRoll, 10, 400, 1, "Arial") ; Result $lblResult = GUICtrlCreateLabel("Results:", 5, 60, 100, 27) GUICtrlSetFont($lblResult, 10, 600, 1, "Arial") $txtResult = GuiCtrlCreateEdit("", 5, 80, 390, 27, $ES_CENTER) GUICtrlSetFont($txtResult, 10, 400, 1, "Arial") $txtTotal = GuiCtrlCreateEdit("", 125, 110, 150, 27, $ES_CENTER) GUICtrlSetFont($txtTotal, 10, 600, 1, "Arial") GUICtrlSetState($cmbNumDie, $GUI_FOCUS) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $mnuHelpReadme ; Help->Read Me Run(@COMSPEC & " /c Start " & $hlpFile, @SystemDir, @SW_MINIMIZE) If @error = 1 Then MsgBox(48, "ReadMe File Missing", "Cannot find " & $hlpFile) EndIf Case $msg = $mnuHelpWebSite ; Help->Author's Home Page Run(@COMSPEC & " /c Start " & $AppSite, @SystemDir, @SW_MINIMIZE) Case $msg = $mnuHelpAbout ; Help->About (App name)... MsgBox(64, "About " & $AppName, $AppName & " " & $AppVersion & @CRLF & @CRLF & $AppSite & @CRLF & @CRLF & "This program is free software. It comes without any warranty, to" & @CRLF & "the extent permitted by applicable law. You can redistribute it" & @CRLF & "and/or modify it under the terms of the Do What The F*** You Want" & @CRLF & "To Public License, Version 2, as published by Sam Hocevar. See" & @CRLF & "http://sam.zoy.org/wtfpl/COPYING for more details.") Case $msg = $cmdRoll ; Roll 'Em button RollDie(Int(GUICtrlRead($cmbTlDie)), Int(GUICtrlRead($cmbNumDie))) Case $msg = $GUI_EVENT_CLOSE ; Closed through Windows icon or keystroke ExitLoop Case $msg = $mnuFileExit ; File->Exit ExitLoop EndSelect WEnd ; Closes the GUI and terminates the app. GUIDelete() Exit