Sign in to follow this  
Followers 0
haloshadow

100 Bottles of beer on the wall...

23 posts in this topic

#1 ·  Posted (edited)

I need help making a start hotkey, I'm rather new to this. Bear with me.

I just want to be able to tell the person to press say, F5 to start, and F6 to pause.

The ending of the script is fine.

; Script Function:
;   BEER SONG!


; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Beer Song", "This will sing 100 beer bottles song. Execute?")
MsgBox(0, "WARNING","At any time, if you wish to end the autotyping.  Press Ctrl+Q.")

hotkeyset("^q", "Kill")

func Kill()
    $count = 0
    Sleep(3000)
    Send("Script aborted{!}{ENTER}")
EndFunc

; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "Awww.....................", "OK.  Bye!")
    Exit
EndIf


; Set the counter
$count = 500

While $count > 0
Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
Sleep(2200)
Send("" & $count & " bottles of beer{!}{!}{!}{ENTER}")
Sleep(2200)
Send("Take one down, pass it around.{ENTER}")
Sleep(2200)
    $count = $count - 1 

WEnd 
        
; Finished!
Sleep(2000)
MsgBox(0, "BeerSong By Haloshadow", "Script ended.")

P.S. This is great on runescape... I counted down from 10,000 and had it going FOREVER. It's sad when you get muted because people hate music though. I had all the people dancing.

Edited by haloshadow

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Havn't messed with autoit in a while but something like

CODE
MsgBox(0, "B.O.B.", "If at any time you would like to end this simply press F6")

Not really sure if this is what you want. Don't really understand your question.

P.S. Great idea.

EDIT: well, since I felt this was missing something, I added something :)

Now the user can put the number of bottles of beer.

Hotkeyset("{F7}", "StartSong")
HotKeySet("{F8}", "EndSong")
Global $count, $inputA, $delay
$count=1
$delay=1

MsgBox(0, "B.O.B.", "This is B.O.B." & @CRLF & "A script that will sing Bottles Of Beer")

$inputA=InputBox("B.O.B.", "How many Bottles of beer?")

$count = $inputA

while $delay=1
    sleep(1000)
    WEnd

While $count > 0
Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
Sleep(2200)
Send("" & $count & " bottles of beer!!! {ENTER}")
Sleep(2200)
Send("Take one down, pass it around.{ENTER}")
Sleep(2200)
    $count = $count - 1
    WEnd

Func StartSong()
$delay=0
EndFunc

Func EndSong()
    $count=0
EndFunc
Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You need to change ! to {!} since ! = ALT key

Hotkeyset("{F7}", "StartSong")
HotKeySet("{F8}", "EndSong")
Global $count, $inputA, $delay
$count=1
$delay=1

MsgBox(0, "B.O.B.", "This is B.O.B." & @CRLF & "A script that will sing Bottles Of Beer")

$inputA=InputBox("B.O.B.", "How many Bottles of beer?")

$count = $inputA

while $delay=1
    sleep(1000)
    WEnd

While $count > 0
Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
Sleep(2200)
Send("" & $count & " bottles of beer[b]{!}{!}{!}[/b] {ENTER}")
Sleep(2200)
Send("Take one down, pass it around.{ENTER}")
Sleep(2200)
    $count = $count - 1
    WEnd

Func StartSong()
$delay=0
EndFunc

Func EndSong()
    $count=0
EndFunc
Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

uhhh, I did.


The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yeah, the "!" symbol has to be closed in brackets.

Otherwise it doesn't type it.

Edited by haloshadow

Share this post


Link to post
Share on other sites

One more quick question, If I were to put delay back to 1, would it pause it?

That's mainly what i'm looking for, is something to pause.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

One more quick question, If I were to put delay back to 1, would it pause it?

That's mainly what i'm looking for, is something to pause.

It will stop if count is equal to or less than zero.

It will start if delay is equal to zero. So I guess yes.

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Logic seems corrent, but test results lead otherwise.

After the While function is passed you cant go back to it, so changing the value to 1 dosn't work.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Oh that's because the "While delay = 1" loop needs to go after the "While count > 0" loop

Really the code needs to be more like this:

Hotkeyset("{F7}", "StartSong")
HotKeySet("{F8}", "EndSong")
Global $count, $inputA, $delay
$count=1
$delay=1

MsgBox(0, "B.O.B.", "This is B.O.B." & @CRLF & "A script that will sing Bottles Of Beer")

$inputA=InputBox("B.O.B.", "How many Bottles of beer?")

$count = $inputA

While 1 ; Main While-Loop to keep program alive
    while $delay=1
        sleep(1000)
    WEnd

    While $count > 0
        Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
        Sleep(2200)
        Send("" & $count & " bottles of beer{!}{!}{!} {ENTER}")
        Sleep(2200)
        Send("Take one down, pass it around.{ENTER}")
        Sleep(2200)
        $count = $count - 1
    WEnd
WEnd

Func StartSong()
$delay=0
EndFunc

Func EndSong()
    $count=0
EndFunc
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Yeah, that's a good idea!

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Wait, hold on...

Now the script NEVER ends...

Should I add gui box? That just has a quit button, and maybe says Script Running/Paused.

This is what i've got

Hotkeyset("{F8}", "StartSong")
HotKeySet("{F10}", "EndSong")
HotKeySet("{F9}", "PauseSong")
Global $count, $inputA, $delay
$count=1
$delay=1

MsgBox(0, "B.O.B.", "This is BOB." & @CRLF & "A script that will sing Bottles Of Beer on the wall" & @CRLF & "Scripted by §haÐoW - Runescape Version")

$inputA=InputBox("B.O.B.", "How many Bottles of beer?")

$count = $inputA

$wait=InputBox("TimeDelay","Enter the delay time in seconds." & @CRLF & "Recomended Time is 2.2")

MsgBox(0, "B.O.B","HotKey Instructions:" & @CRLF & "F8: Start-Song" & @CRLF & "F9: Pause-Song" & @CRLF & "F10: End-Program" & @CRLF & "Don't start the script until you select the window you want.")

$wait = $wait * 1000

While 1 ; Main While-Loop to keep program alive
    while $delay=1
        sleep(1000)
    WEnd

    While $count > 0
        Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
        Sleep(2200)
        Send("" & $count & " bottles of beer{!}{!}{!} {ENTER}")
        Sleep(2200)
        Send("Take one down, pass it around.{ENTER}")
        Sleep(2200)
        $count = $count - 1
    WEnd
WEnd

Func StartSong()
    $delay=0
EndFunc

Func PauseSong()
    $delay=1
EndFunc

Func EndSong()
    $count=0
    MsgBox(0, "B.O.B","You pressed F10, program ended.")
EndFunc
Edited by haloshadow

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Wait, hold on...

Now the script NEVER ends...

Just have an Func with an Exit inside.

Example:

Hotkeyset("{F7}", "StartSong")
HotKeySet("{F8}", "EndSong")
HotKeySet("{F9}","ExitScript") ; New Hot Key
Global $count, $inputA, $delay
$count=1
$delay=1

MsgBox(0, "B.O.B.", "This is B.O.B." & @CRLF & "A script that will sing Bottles Of Beer")

$inputA=InputBox("B.O.B.", "How many Bottles of beer?")

$count = $inputA

While 1
    while $delay=1
        sleep(1000)
    WEnd

    While $count > 0
        Send("Theres " & $count & " bottles of beer on the wall.{ENTER}")
        Sleep(2200)
        Send("" & $count & " bottles of beer{!}{!}{!} {ENTER}")
        Sleep(2200)
        Send("Take one down, pass it around.{ENTER}")
        Sleep(2200)
        $count = $count - 1
    WEnd
WEnd

Func StartSong()
    $delay=0
EndFunc

Func EndSong()
    $count=0
EndFunc

Func ExitScript()
    Exit ;Exits script
EndFunc
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

........................or click the tray icon.


The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

Ok, I see, so exit kills the script.

Do you guys have a wikipedia listing the functions or something?

That would be nice.

Share this post


Link to post
Share on other sites

........................or click the tray icon.

Some people are stupid :).

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ok, I see, so exit kills the script.

Do you guys have a wikipedia listing the functions or something?

That would be nice.

Functions are in the help file :)

You can search for them by clicking the Index tab.

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

pretty sure the helpfile comes with the download, just check Start>All Programs>AutoIt3>Helpfile

Some people are stupid biggrin.gif.

are you callin me stupid or saying that people are to stupid to use the tray icon? Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

Get used to that image BECAUSE YOU WILL SEE IT MORE THAN ANYTHING ON YOUR COMPUTER.


The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0