A simple keyboard volume control

If you are currently developing portable freeware or planning to do so, use this forum to discuss technical implementation, seek out like-minded developers for partnership, or solicit interested users for beta testing.
Message
Author
User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

A simple keyboard volume control

#1 Post by dmg »

Greetings

I was hoping someone may be interested in beta testing this for me.

Outdated link removed

It is a very simple keyboard and mouse master volume control written in AutoHotkey. It is portable and should run on Win 2000 XP and Vista, though in Vista you will need to run it in XP compatibility mode. It will not run on Win7 due to issues with AHk and the Win7 sound API.

I wrote this in about three hours yesterday, so nothing about it is final, including the name. :) I would appreciate any ideas for improvement. Please contact me with ideas via the private messaging system. My goal is simply to get this to the point that it can be considered good enough to list here at TPFC. I am doing this mostly as a programming exorcise, and this is my first polished application so please be kind in your criticism. The source script is included. Thanks 8)
Last edited by dmg on Thu Oct 07, 2010 3:14 am, edited 4 times in total.

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: A simple keyboard volume control

#2 Post by webfork »

If you change your mind about releasing the code, I'd be glad to help test.

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#3 Post by dmg »

The zip file now includes the source.

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#4 Post by dmg »

For anyone who had trouble downloading the file, it is now fixed. I have never used file hosting before and I accidentally had the file set to private. My apologies.

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: A simple keyboard volume control

#5 Post by webfork »

No problems, no crash, no loss of functionality. Buttons very responsive. No delay and no confusion if I press mute on and off repeatedly. I couldn't get it to work with my mouse wheel, but that may be my unusual setup: tested on WinXP SP3 on a Mac under VMware.

The only negative I can see is that the program takes up 4.3 megs of RAM, which really isn't a big negative: HotKeys (http://www.portablefreeware.com/index.php?id=254) takes up over 7. I'm not sure how much Volumouse (http://www.portablefreeware.com/index.php?id=1340) takes up, but yours is much simpler, has simple and obvious mute functionality, as well as being open and in AHK.

Nice work and thanks for posting.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: A simple keyboard volume control

#6 Post by guinness »

Seems you AutoHotKey studying has improved tenfold! Also with reference to the RAM issue there might be a function floating around the AutoHotKey to "Reduce RAM," I know there is in AutoIt!

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#7 Post by dmg »

Thanks guys. I will look into the ram issue and let you know.

Does anyone have an opinion on which hotkeys I chose to use? Any reasons, conflicts etc. why it would be better to use a different set? Thanks.

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#8 Post by dmg »

Try this version.

Outdated link removed

Now it empties all variables at the end of each operation set. This may not help ram usage by much but it is all I could think of at this point.

What method are you using to check ram usage?
Last edited by dmg on Thu Oct 07, 2010 3:15 am, edited 1 time in total.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: A simple keyboard volume control

#9 Post by guinness »

Some Ideas >> http://www.autohotkey.com/forum/topic53543.html Or http://www.sevenforums.com/customizatio ... ift-2.html. As I have mentioned before I have no expertise in AutoHotKey, but I did some research (searched for AutoHotKey - EmptyWorkingSet) and I think the example in AutoHotKey will help you to reduce the Memory usage of the running application! And it's safe as it's using the Windows API :)

AutoHotKey

Code: Select all

_EmptyWorkingSet() ; http://www.sevenforums.com/customization/40297-can-copy-path-enabled-permanently-without-shift-2.html
{
  Return DllCall("psapi.dll\EmptyWorkingSet", "UInt", -1)
}
My Example taken and modified from the AutoIt Forums.
_ReduceMemory() ; Call the Function to reduce the Memory usage of the current Process. Or ...
_ReduceMemory("Opera.exe") To reduce the Memory usage of Opera! (if running)

Code: Select all

Func _ReduceMemory($rm_PID = -1)
	If $rm_PID <> -1 Then
		Local $rm_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $rm_PID)
		Local $rm_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $rm_Handle[0])
		DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $rm_Handle[0])
	Else
		$rm_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
	EndIf
	Return $rm_Return[0]
EndFunc   ;==>_ReduceMemory

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#10 Post by dmg »

Thanks guinness. I tried this a few different ways in my script but it did not seem to help. When placed in the auto execute section it DOES reduce the initial ram used by a lot, but the effect is temporary. And I could not tell it did anything when placed in other areas of the script. I will keep playing around with it, but for now it looks like the volume control may just be a bit of a ram hog. :D

Can anyone tell me if emptying the variables helped at all?

User avatar
webfork
Posts: 10836
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: A simple keyboard volume control

#11 Post by webfork »

dmg wrote:Does anyone have an opinion on which hotkeys I chose to use? Any reasons, conflicts etc. why it would be better to use a different set? Thanks.
I like what you have set now and think you could stick with that without too many problems. However, if you're hoping to put this program on a lot of people's computers, its hard to find a key combo that won't run into conflicts. Some specialized programs out there used 8 hours a day by people have 200 different key combinations to speed up the process. For others, a mute button may be really important to you, so you'll want it to be super easy to do (win+tab or something). If possible some kind of customization would be helpful, even if its physically editing an INI file.

But to your question, here's some possible defaults:
  • "win" + "=" and "win" + "-" (The = sign because most people see the + symbol.)
  • "ctrl+shift+up" , "ctrl+shift+down" and "ctrl+shift+z" for mute (I know that sounds odd but that's my actual setup with Foobar)
dmg wrote:What method are you using to check ram usage?
Just the Task Manager. ctrl+shift+escape :)

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: A simple keyboard volume control

#12 Post by guinness »

You have to keep calling the Function, so if I am using a While...WEnd loop then I just call the Function everytime. But for your script I think its best if you put the Function call at the start of all your functions! Also to note clearing the Variables doesn't reduce any RAM, especially the amount of data your Variables are holding. If it was an Array with 100,000,000 items then it would a good idea to consider resetting if useless.

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#13 Post by dmg »

@webfork
I have a loose idea for customizing hotkeys. I will work on it. The design of AHk does not really consider the concept of using anything other than hard code to determine an input method, ie choosing a hotkey.

@guinness
I tried placing the function in each of my script's operations but all I got was an error message saying I had duplicated a function. There is a section at the end of my script to remove the tray tip, which is activated at the end of each script operation. I tried placing your function there but it did not seem to do anything. As I said, I will keep trying it. And thanks again.

Edit:
Success! It works wonderfully. Apparently you have to place the function itself in one place in the script, then place the name of the function at the point in the script where you want the function to activate. Who knew?! Now the ram hovers between 500kb and 900kb. Thank you for the solution guinness!

I will work on making the hotkeys customizable, and post a new version if and when I figure that out. Thanks again guys for your help. 8)

User avatar
dmg
Posts: 325
Joined: Fri Jun 04, 2010 2:11 am
Contact:

Re: A simple keyboard volume control

#14 Post by dmg »

Here is a link to the new version, beta 5.
Outdated link removed

Changes:
Hotkeys are customizable
Icons are customizable
Tooltip and icon changes to represent current status, ie muted or suspended
Custom tray menu
Generates keys.ini if not found on start
Generates readme.txt if opened from the tray and not found
Generates keys.ini if not found when Edit is chosen from the tray menu
Calls EmptyWorkingSet once 30 seconds after application start, and at the end of each operation

Please play around with it and let me know what you think. All comments and suggestions are welcome.

Including ideas for a more imaginative name. 8)
Last edited by dmg on Thu Oct 14, 2010 8:50 pm, edited 1 time in total.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: A simple keyboard volume control

#15 Post by guinness »

OK, so had a play around with it this time and it doesn't work!, like the popup bubble!

So I think the problem is with Vista and later...http://www.autohotkey.com/docs/commands/SoundSet.htm, if you see the remarks it's best to use

Code: Select all

Send {Volume_Up}  ; Raise the master volume by 1 interval (typically 5%).
Send {Volume_Down 3}  ; Lower the master volume by 3 intervals.
Send {Volume_Mute}  ; Mute/unmute the master volume.
Sorry about this :(
Potential name(s): Volume Key, VKey, Pushey, Vlick (Volume Click!)

Post Reply