Advertisement
Guest User

Untitled

a guest
Feb 25th, 2013
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;-----------------------------------EXAMPLES-----------------------------------
  2.  
  3. ;____Usage___
  4. ;ProgressBar(Length, Current, Max, Unlock = 0)
  5. ;Unlock unlocks the length of the line
  6. ;it is optional - default to off (length is capped at 97 - optimised for Win7)
  7.  
  8. ;______________Example 1______________
  9. MaxValue := 50
  10. loop %MaxValue%
  11.     {
  12.         sleep 50
  13.         traytip, Progress - normal run, % ProgressBar(28, A_index, MaxValue) ;normal loop - no unlock
  14.     }
  15.    
  16. ;______________Example 2______________
  17. MaxValue := 50
  18. loop %MaxValue%
  19.     {
  20.         sleep 50
  21.         traytip, Progress - length set to 999999, % ProgressBar(999999, A_index, MaxValue) ;length set too high - fault is dealt with
  22.     }
  23.  
  24. ;______________Example 3______________
  25. MaxValue := 5
  26. loop %MaxValue%
  27.     {
  28.         sleep 200
  29.         traytip, Progress - short run time, % ProgressBar(28, A_index, MaxValue)
  30.     }
  31.  
  32. ;______________Example 4______________ 
  33. gui, font, s10, Letter Gothic ;monospace font - http://en.wikipedia.org/wiki/Samples_of_monospaced_typefaces
  34. Gui, Add, Button, x12 y70 w580 h40 gGo, Button
  35. Gui, Add, GroupBox, x12 y10 w570 h50 , Progress
  36. Gui, Add, Text, x22 y30 w550 h20 r1 vText, Press the button
  37. Gui, Show, x356 y521 h137 w607, Progress Demo - demonstrating length unlock
  38. Return
  39.  
  40. Go:
  41. MaxValue := 19
  42. loop %MaxValue%
  43.     {
  44.         sleep 40
  45.         GuiControl,, text, % ProgressBar(180, A_index, MaxValue, 1)
  46.     }
  47. GuiControl,, text, Complete. Press the button again :)
  48. return
  49.  
  50. GuiClose:
  51. ExitApp
  52.  
  53. ;------------------------------------------------------------------------------
  54. ;-----------------------------------Function-----------------------------------
  55. ;------------------------------------------------------------------------------
  56. ProgressBar(Length, Current, Max, Unlock = 0)
  57.     {
  58.         ;Made by Bugz000 with assistance from tidbit, Chalamius and Bigvent
  59.         Percent := (Current / Max) * 100
  60.         if (unlock = 0)
  61.             length := length > 97 ? 97 : length < 4 ? 4 : length
  62.         percent := percent > 100 ? 100 : percent < 0 ? 0 : percent
  63.         Loop % round(((percent / 100) * length), 0)
  64.             Progress .= "|"
  65.         loop % Length - round(((percent / 100) * length), 0)
  66.             Progress .= A_Space
  67.         return "[" progress "]" A_space round(percent, 2) "% Complete"
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement