home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / GUI / Advanced / dice.au3 < prev    next >
Encoding:
Text File  |  2007-09-08  |  2.8 KB  |  77 lines

  1. ; autoit version: 3.0
  2. ; language:       English
  3. ; author:         Larry Bailey
  4. ; email:          psichosis@tvn.net
  5. ; Date: November 15, 2004
  6. ;
  7. ; Script Function
  8. ; Creates a GUI based dice rolling program
  9. ; using the Random function
  10.  
  11. #include <GUIConstants.au3>
  12.  
  13. GUICreate("Dice Roller", 265, 150, -1, -1)
  14.  
  15. $button1= GUICtrlCreateButton("D2", 5, 25, 50, 30)
  16. $button2= GUICtrlCreateButton("D3", 65, 25, 50, 30)
  17. $button3= GUICtrlCreateButton("D4", 125, 25, 50, 30)
  18. $button4= GUICtrlCreateButton("D6", 5, 65, 50, 30)
  19. $button5= GUICtrlCreateButton("D8", 65, 65, 50, 30)
  20. $button6= GUICtrlCreateButton("D10", 125, 65, 50, 30)
  21. $button7= GUICtrlCreateButton("D12", 5, 105, 50, 30)
  22. $button8= GUICtrlCreateButton("D20", 65, 105, 50, 30)
  23. $button9= GUICtrlCreateButton("D100", 125, 105, 50, 30)
  24. $button10= GUICtrlCreateButton("Clear Dice", 185, 105, 65, 30) 
  25. $output = GUICtrlCreateLabel("", 185, 45, 70, 50, BitOR($BS_PUSHLIKE,$SS_CENTER))
  26. $die = GUICtrlCreateLabel("", 185, 25, 70, 20, 0x1000)
  27. GUICtrlSetFont($output, 24, 800, "", "Comic Sans MS")
  28.  
  29. GuiSetState ()
  30.  
  31. ; Run the GUI until the dialog is closed
  32. While 1
  33.     $msg = GUIGetMsg()
  34.        Select
  35.          Case $msg = $button1
  36.              $results = Random(1,2, 1)
  37.              GUICtrlSetData($output, $results)
  38.              GUICtrlSetData($die, "2 Sided Die")
  39.          Case $msg = $button2
  40.              $results = Random(1,3, 1)
  41.              GUICtrlSetData($output, $results)
  42.              GUICtrlSetData($die, "3 Sided Die")
  43.           Case $msg = $button3
  44.              $results = Random(1,4, 1)
  45.              GUICtrlSetData($output, $results)
  46.              GUICtrlSetData($die, "4 Sided Die")
  47.          Case $msg = $button4
  48.              $results = Random(1,6, 1)
  49.              GUICtrlSetData($output, $results)
  50.              GUICtrlSetData($die, "6 Sided Die")
  51.          Case $msg = $button5
  52.              $results = Random(1,8, 1)
  53.               GUICtrlSetData($output, $results)
  54.              GUICtrlSetData($die, "8 Sided Die")
  55.          Case $msg = $button6
  56.              $results = Random(1,10, 1)
  57.              GUICtrlSetData($output, $results)
  58.              GUICtrlSetData($die, "10 Sided Die")
  59.          Case $msg = $button7
  60.              $results = Random(1,12, 1)
  61.             GUICtrlSetData($output, $results)
  62.             GUICtrlSetData($die, "12 Sided Die")
  63.          Case $msg = $button8
  64.             $results = Random(1,20, 1)
  65.              GUICtrlSetData($output, $results)
  66.              GUICtrlSetData($die, "20 Sided Die")
  67.          Case $msg = $button9
  68.              $results = Random(1,100, 1)
  69.              GUICtrlSetData($output, $results)
  70.              GUICtrlSetData($die, "100 Sided Die")
  71.           Case $msg = $button10
  72.              GUICtrlSetData($output, "")
  73.              GUICtrlSetData($die, "")
  74.       EndSelect
  75.    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  76. Wend
  77.