Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language AutoIt

(version 3.x)

Date:05/17/05
Author:Mike Gogulski
URL:n/a
Comments:8
Info:n/a
Score: (2.95 in 131 votes)
; AutoIt 3.x version of 99 Bottles
; By Mike Gogulski <mike@gogulski.com> 21 March 2005
; AutoIt is a scripting language for Windows application automation
; http://www.hiddensoft.com/
 
AutoItSetOption("SendKeyDelay", 0)
Run("notepad")
WinWaitActive("Untitled - Notepad")
$bottles = 99
while $bottles > 0
 Send($bottles & " bottle(s) of beer on the wall,{ENTER}")
 Send($bottles & " bottle(s) of beer{!}{ENTER}")
 Send("Take one down, pass it around,{ENTER}")
 $bottles = $bottles - 1
 Send($bottles & " bottle(s) of beer on the wall{!}{ENTER}")
WEnd

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
version 2.xMike Gogulski05/18/052

Comments

>>  Michael Heath said on 06/03/06 19:05:55

Michael Heath AutoItSetOption("SendKeyDelay", 0)
Run("notepad";)
WinWait("Untitled - Notepad";)
For $bottles = 99 To 0 Step -1
$string = $bottles & " bottle(s) of beer on the wall," & _
@LF & $bottles & " bottle(s) of beer!" & _
@LF & "Take one down, pass it around," & _
@LF & $bottles & " bottle(s) of beer on the wall!" & @LF
ControlSend('Untitled - Notepad', "", "Edit1", $string, 1)
Next

>>  Evilertoaster said on 08/03/06 04:11:09

Evilertoaster GUI Version:
^_^

#NoTrayIcon
Opt("GUIOneventMode",1)
#include <GuiConstants.au3>
GuiSetState(@SW_SHOW,GuiCreate("Beer Counter", 288, 265,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)))
GUISetOnEvent($GUI_EVENT_CLOSE,"MyExit";)
GUICtrlSetOnEvent(GuiCtrlCreateButton("Start Counting", 5, 210, 80, 30),"GO";)
$Edit_2 = GuiCtrlCreateInput("", 10, 10, 270, 170,BitOr($ES_MULTILINE,$ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$sleeptime=GUICtrlCreateInput("Seconds Per Beer",90,210,200,30)
While 1
Sleep(100)
WEnd
func go()
GUICtrlSetData($Edit_2,"";)
$bot=" bottles "
For $a=100 to 1 step -1
if $a=1 then $bot=" bottle "
GUICtrlSetData($Edit_2,$a&$bot&"of beer on the wall"&@CRLF&$a&$bot&"of beer!"&@CRLF & "Take one down, pass it around,"&@CRLF &$a&$bot&"of beer on the wall"&@CRLF&GUICtrlRead($Edit_2))
Sleep(Number(GUICtrlRead($sleeptime))*1000)
Next
GUICtrlSetData($Edit_2,"0 bottles of beer on the wall..."&@CRLF&"Wait...no beer....Awe, sad..."&@CRLF&GUICtrlRead($Edit_2))
EndFunc
func MyExit()
Exit
EndFunc

>>  Daniel Meyer said on 10/30/06 08:25:40

Daniel Meyer ; MsgBox version

$a = ' bottle'
$b = ' of beer'
$c = ' on the wall'
$d = '. Take one down and pass it around - '
$e = 'no more'

For $n = 99 To 1 Step -1
$text = $n & $a & 's' & $b & $c & ', ' & $n & $a & 's' & $b & $d & $n - 1 & $a & 's' & $b & $c & '.'
Select
Case $n=2
$text = $n & $a & 's' & $b & $c & ', ' & $n & $a & 's' & $b & $d & $n - 1 & $a & $b & $c & '.'
Case $n=1
$text = $n & $a & $b & $c & ', ' & $n & $a & $b & $d & $e & $a & 's' & $b & $c & '.'
EndSelect
MsgBox(0, '99 bottles of beer', $text)
Next

>>  Xantios said on 12/01/06 23:12:55

Xantios $bottles = 99
do
Send($bottles & " bottle(s) of beer on the wall,{ENTER}";)
Send($bottles & " bottle(s) of beer{!}{ENTER}";)
Send("Take one down, pass it around,{ENTER}";)
$bottles = $bottles - 1
Send($bottles & " bottle(s) of beer on the wall{!}{ENTER}";)
until $bottles = 0
send("No more beer :(";)

>>  Karl said on 12/27/06 21:57:05

Karl Hey what about adding a finishing part about heading down the shop to buy more beer at the end!! Nice work!

>>  Przemek said on 03/21/08 10:32:52

Przemek The one sktypt is active only in an system in the English version.

>>  Justin Reno said on 05/15/08 19:47:26

Justin Reno Here's one that talks:

;Written by Justin Reno.
#NoTrayIcon

If @OSVersion <> "WIN_VISTA" Then
If @OSVersion <> "WIN_XP" Then
MsgBox(16, "Song", "You need Windows XP or above for this to work!" & @CRLF & "Sorry.";)
Exit
EndIf
EndIf

Global $Speach = ObjCreate("Sapi.SPVoice";)

For $Pop = 99 To 1 Step - 1
$Speach.Speak($Pop & " bottles of pop on the wall, " & $Pop & " bottles of pop, take one round, pass it around, " & $Pop - 1 & " bottles of pop on the wall";)
Next

>>  ptrex said on 02/15/10 13:55:13

ptrex This version 2.0 is dead for a long time.

I have submitted a new sample code for version 3.2

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: