AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Power Hour - The Game (Input needed please)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Bigrob55



Joined: 24 Sep 2007
Posts: 37

PostPosted: Mon Sep 15, 2008 9:19 pm    Post subject: Power Hour - The Game (Input needed please) Reply with quote

Hey all!!

Long story short, I have recently made a lil script that makes playin the game "Power Hour" a bit easier.

In case you don't know... Power Hour is a drinking game where a group of people listen to a sound, watch TV, or just do what ever... And for every minute they take a shot of beer.. this is 60 shots of beer in an hour.

So i made a lil script that counts to 60 seconds, then sounds a horn to let everyone know to drink. it does that 60 times, and on the last horn it sounds an indicator to let everyone know that power hour is over.

Its ALOT easier then using a wristwatch... or using One Minute tracks burnt on a audio CD.

Here is that code: (We can call this Version 1)
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
#SingleInstance Force

;===========================================================
TrayTip,Power Hour,Right Click Icon To Begin!,30,17

;Right Click Menu ===================================
Menu, tray, NoStandard
Menu, tray, add, Start, start
Menu, tray, add  ; Creates a separator line.
Menu, tray, add, Test Horn, soundtest
Menu, tray, add  ; Creates a separator line.
Menu, tray, add, Pause, pausebtn
Menu, tray, add, Close, END
;===========================================================

sleep, 2147483647
start:
TrayTip Power Hour, Power Hour Started!, 0, 1

loop 60
{
Sleep, 60000
SoundPlay C:\BATCH FILES\power hour\sound.mp3
TrayTip Power Hour, Drink Drink Drink!!, 0, 1
}
sleep, 1
SoundPlay C:\BATCH FILES\power hour\done.mp3
TrayTip Power Hour, Power Hour Over, 0, 1
exitapp

pausebtn:
pause, toggle
return

soundtest:
SoundPlay C:\BATCH FILES\power hour\sound.mp3
TrayTip Power Hour, Horn Sound Test!!, 0, 1
return

END:
ExitApp

As you can see it is mainly a menu, and Traytips.

--------------------------------------------------------

Here is Version 2, that i am working on now:
I am trying to figure out how to add:

-A countdown display

-An indicator to let you know how many minutes/shots have gone by.

-A button that lets you test the horn, so everyone knows the sound and to make sure its working fine.

-And also a Start/Stop button that can be used if you want to pause the game mid-way through.
Code:
#SingleInstance Force
#NoTrayIcon

Menu, Tray, Icon, icon.ico ;Replace default icon with custom

DetectHiddenWindows, on
SoundPlay open.mp3 ;Opening Sound

Gui Font, s30 c00FF00,Bookman Old Style
Gui Add, Text, x70 y17 w120 h40, 00:00 ; Countdown Clock

Gui Font, s10, arial
Gui Add, Button, x150 y175 w80 h22 ,Test-Horn ;Test Horn Button

Gui Font, Bold
Gui Add, Button, x30 y200 w200 h30 , START ; Start Countdown Button

Gui, Show, Hide h250 w260, Power Hour ;Creates Window, then hides it
WinSet, Transparent, 0, Power Hour
Gui, Show
sleep, 10

trans = 0
loop, 255
{
sleep 0
trans := trans + 1
winset, transparent, %trans%, Power Hour
}
return

ButtonTest-Horn: 
  SoundPlay horn.mp3
Return

ButtonSTART:
msgbox,timer started
return

;======================== Exit Program Fuction =======================
GUIClose:
Esc::
MsgBox, 4, Close Power Hour?,
IfMsgBox No
    return
SoundPlay close.mp3
sleep, 300
trans = 255
loop, 255
{
sleep 0
trans := trans - 1
winset, transparent, %trans%, Power Hour
}
ExitApp
;======================== /Exit Program Fuction =======================


So far i have more bells and whistles in here, then actualy functionality that will make the game work.

Here is the files for the sounds and the icon if u want to use them:http://www.fileden.com/files/2007/10/11/1503533/Power_Hour_Files.zip

Any input would be greatly appreiciated!! Very Happy
_________________
Bigrob

L337 Speak - A Ventrilo Client Side program

Winamp Sound Changer - Change Audio Output on the Fly!


Last edited by Bigrob55 on Tue Sep 16, 2008 1:17 am; edited 2 times in total
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Mon Sep 15, 2008 11:28 pm    Post subject: Reply with quote

Code:
#SingleInstance Force
#NoTrayIcon

Menu, Tray, Icon, icon.ico ;Replace default icon with custom

DetectHiddenWindows, on
SoundPlay open.mp3 ;Opening Sound

Gui Font, s30 c00FF00,Bookman Old Style
Gui Add, Text, x70 y17 w120 h40 vClock, 00 ; Countdown Clock
Gui, Add, Text, Coords? vHorn, 0

Gui Font, s10, arial
Gui Add, Button, x150 y175 w80 h22 ,Test-Horn ;Test Horn Button

Gui Font, Bold
Gui Add, Button, x30 y200 w200 h30 , START ; Start Countdown Button

Gui, Show, Hide h250 w260, Power Hour ;Creates Window, then hides it
Loop, 256
  WinSet, Transparent, % A_Index - 1, Power Hour
Gui, Show
return

ButtonTest-Horn: 
  SoundPlay horn.mp3
Return

ButtonSTART:
Sec := 60, Shots := 0
SetTimer, UpdateClock, 1000
SetTimer, Horn, 60000
msgbox,timer started
return

Horn:
Shots++
If (Shots = 60) {
  SoundPlay, done.mp3
  SetTimer, Horn, Off
  MsgBox, Power Hour is over!
}
Else
  SoundPlay horn.mp3
GuiControl, , Horn, %Shots%
Return

UpdateClock:
Sec--
If (Sec = -1)
  Sec := 60
GuiControl, , Clock, %Secs%
Return

;======================== Exit Program Fuction =======================
GUIClose:
Esc::
MsgBox, 4, Close Power Hour?,
IfMsgBox No
    return
SoundPlay close.mp3
sleep, 300
loop, 255
  winset, transparent, % 255 - A_Index, Power Hour
ExitApp
;======================== /Exit Program Fuction =======================


Does some stuff, although it still doesn't have a pause button. Also cleaned up your transparency loops a bit.

Not tested..
_________________
PlayAHK! Try it out Very Happy
Back to top
View user's profile Send private message AIM Address
[VxE]



Joined: 07 Oct 2006
Posts: 1496

PostPosted: Tue Sep 16, 2008 12:11 am    Post subject: Reply with quote

Here's another segment that you can incorporate into the script however you want.

Code:
ButtonSTART:
Loop 50
   spc .= A_Space
mintimer := sectimer := 0 ; initialize variables
SetTimer, OnceASecond, 1000
Gui 2:default
Gui +ToolWindow +LastFound ; +Owner1
Gui Font, s14 w500, Arial

Gui Add, Progress, range0-60 vProgress x10 w480 h24 c0x3040FF
Gui Add, Text, r3 w450 center vtex,
( LTrim
   00 shots of beer drunk! And only " 60 " more to go!
   You have 60 seconds until your next shot of beer!
)
GuiControl, 2:Font, tex
Gui Show, w500 h130, %spc%Power Hour !!!
Gui 1:default
return

OnceASecond:
mintimer += tick := !sectimer := Mod(++sectimer, 60) ; count seconds and minutes
IfEqual, tick, 1
{
   GuiControl, 2:, Progress, +1
   Gosub ButtonTest-Horn
}
newtext := mintimer " shot" pls(mintimer) " of beer drunk"
. "! And only " 60-mintimer " more to go!`n`nYou have "
. 60-sectimer " seconds until your next shot of beer!"
GuiControl, 2:, Tex, %newtext%
GuiControl, 2:Font, Tex
IfEqual, mintimer, 60
{
   SetTimer, onceasecond, off
   SetTimer, Done, -1
}
return

pls(amt)
{
   return amt=1 ? "" : "s"
}

_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Sep 16, 2008 12:49 am    Post subject: Reply with quote

I would love too see all the loose code segments together into one powerfull hour Cool

Could be hell of fun this weekend
Twisted Evil
Back to top
Bigrob55



Joined: 24 Sep 2007
Posts: 37

PostPosted: Tue Sep 16, 2008 1:07 am    Post subject: Reply with quote

This is a reply to Krogdor's code that he did up for me Very Happy

So far this is what i made of it so far, sadly the GUI Window Fade-In wasn't working so i changed it back to the older code, cause i had no idea how to fix it, as much as i tried to compare it with the fade out code.

Code:

#SingleInstance Force
#NoTrayIcon

Menu, Tray, Icon, icon.ico ;Replace default icon with custom

DetectHiddenWindows, on
SoundPlay open.mp3 ;Opening Sound

Gui Font, s20 ,Bookman Old Style
Gui, Add, Text, x30 y17 w138 h40, Next Shot:

Gui Font, s25 c000000 ,Bookman Old Style
Gui, Add, Text, x190 y13 w110 h40 vClock, 00 ; Countdown Clock

Gui Font, s20 c000000 ,Bookman Old Style
Gui, Add, Text, x30 y60 w174 h40, Shots Taken:

Gui Font, s25 c000000,Bookman Old Style
Gui, Add, Text, x210 y55 vHorn, 0 ; Shots Taken

Gui Font, s10, arial
Gui Add, Button, x150 y190 w80 h22 ,Test-Horn ;Test Horn Button

Gui Font, Bold
Gui Add, Button, x30 y215 w200 h30 , START ; Start Countdown Button

Gui, Show, Hide h250 w260, Power Hour ;Creates Window, then hides it
WinSet, Transparent, 0, Power Hour
Gui, Show
sleep, 10

trans = 0
loop, 255
{
sleep 0
trans := trans + 1
winset, transparent, %trans%, Power Hour
}
return

ButtonTest-Horn:
SoundPlay horn.mp3
Return

ButtonSTART:
Sec := 60, Shots := 0
SetTimer, UpdateClock, 1000
SetTimer, Horn, 60000
return

Horn:
Shots++
If (Shots = 60) {
  SoundPlay, done.mp3
  SetTimer, Horn, Off
  MsgBox, Power Hour is over!
}
Else
  SoundPlay horn.mp3
GuiControl, , Horn, %Shots%
Loop 10
{
    Gui Flash
    Sleep 500
}
Return

UpdateClock:
Sec--
If (Sec = -1)
  Sec := 60
GuiControl, , Clock, %Secs%
Return

;======================== Exit Program Fuction =======================
GUIClose:
MsgBox, 4, Close Power Hour?,
IfMsgBox No
    return
SoundPlay close.mp3
sleep, 300
loop, 255
  winset, transparent, % 255 - A_Index, Power Hour
ExitApp
;======================== /Exit Program Fuction =======================[quote][/quote]

_________________
Bigrob

L337 Speak - A Ventrilo Client Side program

Winamp Sound Changer - Change Audio Output on the Fly!
Back to top
View user's profile Send private message
Bigrob55



Joined: 24 Sep 2007
Posts: 37

PostPosted: Tue Sep 16, 2008 1:24 am    Post subject: Reply with quote

Hey [VxE],

I will admit its prob me. But when i try to add that to the script.

I get an error on line
Code:
071: SetTimer,Done,-1


Could you please add your code to the whole script.

I think alls that is left now is to have the countdown timer work, and after that to add some bells and whistles to make the program look as cool as it is. Exclamation
_________________
Bigrob

L337 Speak - A Ventrilo Client Side program

Winamp Sound Changer - Change Audio Output on the Fly!
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1496

PostPosted: Tue Sep 16, 2008 2:13 am    Post subject: Reply with quote

Bigrob55 wrote:
I get an error on line
Code:
071: SetTimer,Done,-1

oops, that was just a label in the middle of the 'guiclose' subroutine, after the msgbox to confirm the close. You can safely comment that line out Wink
_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
Bigrob55



Joined: 24 Sep 2007
Posts: 37

PostPosted: Tue Sep 16, 2008 4:28 am    Post subject: Reply with quote

[VxE] wrote:
Bigrob55 wrote:
I get an error on line
Code:
071: SetTimer,Done,-1

oops, that was just a label in the middle of the 'guiclose' subroutine, after the msgbox to confirm the close. You can safely comment that line out Wink


VxE, you and I are seeing eye to eye on this one!

That looks perfect, and i love the progress meter also!!!!

Now ive got to see if i can't just put the two GUI's together and make it a single window.

This is as far as i've gotten so far:
I'm just trying to figure out how i can get the Start/Stop fuction of the clock to work. "Man i'm a noob lol"

And any other ideas anyone has for this script would be awesome!
Code:
 
#SingleInstance Force
#NoTrayIcon

Menu, Tray, Icon, icon.ico ;Replace default icon with custom
DetectHiddenWindows, on
SoundPlay open.mp3 ;Opening Sound

Gui +ToolWindow +LastFound ; +Owner1
Gui Font, s14 w500, Arial

Gui Add, Progress, range0-60 vProgress x10 w480 h24 c0x3040FF
Gui Add, Text, r3 w450 center vtex,
( LTrim
   0 shots of beer drunk! And only " 60 " more to go!
   You have 60 seconds until your next shot of beer!
)
GuiControl, Font, tex

Gui Font, Bold
Gui Add, Button, x150 y110 w200 h25 vButtonText, START ; Start Button

Gui Font, s10
Gui Add, Button, x150 y137 w200 h22 ,Test-Horn ;Test Horn Button

Gui, Show, Hide w500 h160, Power Hour!!! ;Creates Window, then hides it
WinSet, Transparent, 0, Power Hour
Gui, Show
sleep, 10

trans = 0
loop, 255
{
sleep 0
trans := trans + 1
winset, transparent, %trans%, Power Hour
}
return

ButtonTest-Horn:
SoundPlay horn.mp3
Return

ButtonSTART:
GuiControlGet, ButtonText
If ( ButtonText = "START" )
   {
   SetTimer, OnceASecond, 1000
     GuiControl,, ButtonText, STOP
        }
Else
If ( ButtonText = "STOP" )
   {
   SetTimer, onceasecond, off
     GuiControl,, ButtonText, START
         return
    }

Loop 50
   spc .= A_Space
mintimer := sectimer := 0 ; initialize variables
SetTimer, OnceASecond, 1000
return

OnceASecond:
mintimer += tick := !sectimer := Mod(++sectimer, 60) ; count seconds and minutes
IfEqual, tick, 1
{
   GuiControl, , Progress, +1
   Gosub ButtonTest-Horn
}
newtext := mintimer " shot" pls(mintimer) " of beer drunk"
. "! And only " 60-mintimer " more to go!`n`nYou have "
. 60-sectimer " seconds until your next shot of beer!"
GuiControl, , Tex, %newtext%
GuiControl, Font, Tex
IfEqual, mintimer, 60
{
   SetTimer, onceasecond, off
   ;SetTimer, Done, -1
   SoundPlay done.mp3 ;Ending Sound
   GoSub GUIClose
}
return

pls(amt)
{
   return amt=1 ? "" : "s"
}

;======================== Exit Program Fuction =======================
GUIClose:
MsgBox, 4, Close Power Hour?,
IfMsgBox No
    return
SoundPlay close.mp3
sleep, 300
loop, 255
  winset, transparent, % 255 - A_Index, Power Hour
ExitApp
;======================== /Exit Program Fuction =======================

_________________
Bigrob

L337 Speak - A Ventrilo Client Side program

Winamp Sound Changer - Change Audio Output on the Fly!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group