Page 1 of 1

Starting At the bottom

Posted: Tue May 19, 2009 7:05 am
by ilythor
Last thing i want to do is draw from our limited resources, but a point in the right direction would be handy

I have been interested in coding for a while, and haven't had any real experience or anything of the sorts, but I have an idea. I want to make a program that sits in your taskbar, or just hides and has universal hotkeys. So when you hit one of them (say F11 for example) it plays a sound. Having a cheery *Boing* and *kaboom* sounds at your finger tips during games of Crysis, Farcry, or anything with pretty explosions would lighten the mood. If anyone could perhaps point me in the direction of a beginner program/tutorial, that would be great!

Thanks again!

Re: Starting At the bottom

Posted: Tue May 19, 2009 10:16 am
by Zcoretri
Well the way I have learned is by going out and buying programming books on the language I am going to use. I also googled for sites that have programming examples, nut just like the books, some are better than others.
You might consider taking formal classes.

Putting stuff in taskbar is kinda an advanced topic, but it might be easier now in .NET

I first learned basic in the DOS days, then migrated to Visual Basic. I have started to teach myself C++ now that I have been involved with this project.

Re: Starting At the bottom

Posted: Tue May 19, 2009 10:35 am
by Bion
This can be done pretty easy with autoit it is a Windows automation language
I use it for things like this that i want to make quickly
here is an example of how you would do it.

Code: Select all

HotKeySet("{F4}", "ExitProg") ;;Sets F4 as a hotkey to exit program
HotKeySet("{F5}", "PlaySound1") ;;Sets F5 as a hotkey to play sound 1
HotKeySet("{F6}", "PlaySound2") ;;Sets F6 as a hotkey to play sound 2

;path where sound files are at
Dim $sPath = "C:\Sounds\"
;file name of sound files
Dim $sFileName = ""

While 1
	Sleep(100)   ;;;Waits for function call
Wend

Func PlaySound1()
;sets file name
$sFileName = "boing_x.wav"

;play sound file with our path and filename
SoundPlay($sPath & $sFileName,1)

EndFunc

Func PlaySound2()
$sFileName = "bomb droppng.mpg"

SoundPlay($sPath & $sFileName,1)
EndFunc

Func ExitProg()
	exit 0
EndFunc
you first download and install autoit v3 then you can copy that script to notepad or the autoit editor and save it with the .au3 extention like playsound.au3
you can then run it as a script or compile it as a exe
to use this as is copy the sound files to the dir C:\sounds and hit F4 to exit , F5 for sound 1,F6 for sound 2
example sound files can be found here

Re: Starting At the bottom

Posted: Tue May 19, 2009 9:24 pm
by ilythor
Awesome, Thanks!

If I wanted more sounds, I would add more hotkeys, and duplicate these sections? (following the same syntax and changing the sound names etc).

Code: Select all

Func PlaySound1()
;sets file name
$sFileName = "boing_x.wav"

;play sound file with our path and filename
SoundPlay($sPath & $sFileName,1)

EndFunc
I am at school now, I'm going to try it out when I get home!

Wow, thats awesome! Oh and loads of thanks for the comments in the script, makers a lot more sense now!

Re: Starting At the bottom

Posted: Wed May 20, 2009 1:54 am
by ilythor
I think i did something wrong here, I expanded on your code following syntax and changed a few file paths but i think i stuffed up somewhere, as I compiled and ran it as an exe, the icon in my task bar (after unpausing) flashes between the AutoIt icon and a red X. Here is my code. Its probably a simple problem. Thanks for any help!

Code: Select all

HotKeySet("{F4}", "ExitProg") ;;Sets F4 as a hotkey to exit program
HotKeySet("{F5}", "PlaySound1") ;;Sets F5 as a hotkey to play sound 1
HotKeySet("{F6}", "PlaySound2") ;;Sets F6 as a hotkey to play sound 2
HotKeySet("{F7}", "PlaySound3") ;;Sets F7 as a hotkey to play sound 3

;path where sound files are at
Dim $sPath = "D:\Gorcin\Announcements"
;file name of sound files
Dim $sFileName = ""

While 1
   Sleep(100)   ;;;Waits for function call
Wend

Func PlaySound1()
;sets file name
$sFileName = "headshot.wav"

;play sound file with our path and filename
SoundPlay($sPath & $sFileName,1)

EndFunc

Func PlaySound2()
$sFileName = "denied.wav"

SoundPlay($sPath & $sFileName,1)
EndFunc

Func PlaySound3()
$sFileName = "vehicularmansalughter.wav"

SoundPlay($sPath & $sFileName,1)
EndFunc

Func ExitProg()
   exit 0
EndFunc
File paths and file names are all correct and I can't see any errors. I will try to find a way to see whats wrong, if AutoIt has an error log.

Re: Starting At the bottom

Posted: Wed May 20, 2009 12:50 pm
by Bion
it sounds like it is still paused if it is flashing with the red x just by clicking the task tray icon pauses it. just run the exe and when you see the tasktray icon the program is loaded and waiting for you to hit the assigned hotkeys to do what it needs to do.

everything looks fine except for here

Code: Select all

;path where sound files are at
Dim $sPath = "D:\Gorcin\Announcements"
it is missing the last \ . should be Dim $sPath = "D:\Gorcin\Announcements\"
the goal here is to make it when the path and filename are joined it gives the exact location of the file if that last \ is missing then it will read like D:\Gorcin\Announcementsdenied.wav instead of D:\Gorcin\Announcements\denied.wav

Re: Starting At the bottom

Posted: Wed May 20, 2009 7:04 pm
by ilythor
Oh, thought it was something small, thanks again. I will try it when I get home (again).

Yeah, that was it. Thanks heaps! Now I am going to try and see if I can redistribute as a package. Plenty of credits to you! Thanks!