AutoHotkey apps for testing

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
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: AutoHotkey apps for testing

#16 Post by guinness »

OK, so if you want to learn AutoIt I took Lock State and made a very quick version in AutoIt. I didn't do an individual freeze option for the keys, but instead opted for a global freeze. You can learn about DLL calling, Arrays and much more from this quick script. Thanks dmg for the icons & original idea.

Code: Select all

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#cs
	Lock State Created By:					AutoHotKey - dmg & AutoIt - guinness
	Last Textual Changes In This Script:	3rd June 2011
	The Program Can Be Run By Selecting: 	<Lock State.exe>

	Thanks To The Following...

	Icon -->
	Help --> Thanks to dmg for the original idea.
#ce
#AutoIt3Wrapper_Icon=Lock State.ico
#AutoIt3Wrapper_Outfile=LockState.exe
#AutoIt3Wrapper_UseUpx=Y
#AutoIt3Wrapper_Res_Description=Check the state of CapsLock, NumLock & ScrollLock.
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#AutoIt3Wrapper_Res_LegalCopyright=nocopyright (C) 2011
#AutoIt3Wrapper_Res_Language=2057
#AutoIt3Wrapper_Res_Field=Website|
#AutoIt3Wrapper_Res_Field=E-Mail|comment at the website
#AutoIt3Wrapper_UseX64=N
#AutoIt3Wrapper_Run_Obfuscator=Y
#Obfuscator_Parameters=/SF /SV /OM /CS=0 /CN=0
 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_OutFile_Type=exe

#include <Constants.au3>

Opt("TrayMenuMode", 3)

Global $iExit, $iFreeze, $iIsFrozen = 0, $sFilePrevious

$iFreeze = TrayCreateItem("Freeze")
TrayCreateItem("")
$iExit = TrayCreateItem("Exit")

While 1
	If $iIsFrozen = 0 Then
		_Monitor($sFilePrevious)
	EndIf
	_ReduceMemory()

	Switch TrayGetMsg()
		Case $iExit
			Exit

		Case $iFreeze
			If $iIsFrozen Then
				$iIsFrozen = 0
				TrayItemSetState($iFreeze, $TRAY_UNCHECKED)
			Else
				$iIsFrozen = 1
				TrayItemSetState($iFreeze, $TRAY_CHECKED)
			EndIf
	EndSwitch
WEnd

Func _GetKeyState($vKey)
	Local $aReturn = DllCall('user32.dll', 'int', 'GetKeyState', 'int', $vKey)
	If @error Then
		Return SetError(1, 0, 0)
	EndIf
	Return BitAND($aReturn[0], 1)
EndFunc   ;==>_GetKeyState

Func _Monitor(ByRef $sFilePrevious)
	Local $aArray[4][2] = [[3, 2],[0x90, 1],[0x14, 2],[0x91, 3]]
	Local $sFile = ""
	For $A = 1 To $aArray[0][0]
		If _GetKeyState($aArray[$A][0]) Then
			$sFile &= $aArray[$A][1]
		EndIf
	Next
	If $sFile = "" Then
		$sFile = 0
	EndIf
	If $sFile <> $sFilePrevious Then
		$sFilePrevious = $sFile
		TraySetIcon(@ScriptDir & "\icons\" & $sFile & ".ico")
	EndIf
EndFunc   ;==>_Monitor

Func _ReduceMemory()
	Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
	If @error = 1 Then
		Return SetError(1, 0, 0)
	EndIf
	Return $aReturn[0]
EndFunc   ;==>_ReduceMemory

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

Re: AutoHotkey apps for testing

#17 Post by dmg »

Wow! This is is very cool. I can begin to see some correlation between parts of my original code and parts of yours. thanks guinness. :D

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

Re: AutoHotkey apps for testing

#18 Post by guinness »

If you want me to add something else or make it a bit like yours then let me know, it will take me 2 minutes :D I will PM you the code if you do.

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

Re: AutoHotkey apps for testing

#19 Post by guinness »

So I decided to have a little go at adding new features to show the possibilities of AutoIt! Now if you open 2 versions of Lock State the second Version will Close immediately, as you don't need more than 1 running (am I right?!) If you left click on the TrayIcon it will show a small GUI with the "Key States" & left/right click again to hide. I have also added a TrayTip about the States as well, just hover over the TrayIcon (this is Old School.) I also added a nice looking About GUI instead of using a boring MsgBox(). You will notice the icon in the GUI will change to match the TrayIcon.

And now for the BIG NEWS! The icons are embedded in the application so the "icons folder" is only needed for compiling. :D Thus making it a truly Portable & Stealth application. Any problems let me know.

I could also make it MultiLanguage (would take me no time at all!) :D

Download: Keyndicate.zip
Last edited by guinness on Thu Mar 29, 2012 11:54 pm, edited 1 time in total.

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

Re: AutoHotkey apps for testing

#20 Post by dmg »

OK. Now you're just showing off. :lol:

I like the GUI. I am trying to learn GUIs in AHk but I am having some trouble. The syntax is a little clumsy and the documentation is not very helpful.

I agree that embedding the icons is nicer but now you can't choose a different icon set. I don't even know if it is possible to embed files in AHk. The FileInstall command requires the file be extracted before it can be used.

And just for the record, My version already prevents multiple instances. It is the #singleinstance, ignore line near the top of the script. :)

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

Re: AutoHotkey apps for testing

#21 Post by guinness »

I like the GUI. I am trying to learn GUIs in AHk but I am having some trouble. The syntax is a little clumsy and the documentation is not very helpful.
This is why AutoIt V3 was created as AHK is AutoIt V2, hence why I think AutoIt is easier for GUI creation.
I agree that embedding the icons is nicer but now you can't choose a different icon set. I don't even know if it is possible to embed files in AHk. The FileInstall command requires the file be extracted before it can be used.
It's possible in AutoIt and I wouldn't need to use FileInstall() which I haven't used in a long time. Do you want me to add it so I can show you?
And just for the record, My version already prevents multiple instances. It is the #singleinstance, ignore line near the top of the script.
Now I saw it! :D

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

Re: AutoHotkey apps for testing

#22 Post by dmg »

guinness wrote:It's possible in AutoIt and I wouldn't need to use FileInstall() which I haven't used in a long time. Do you want me to add it so I can show you?
Is this what you mean?

Code: Select all

#AutoIt3Wrapper_Res_Icon_Add=icons\0.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\1.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\2.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\3.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\12.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\13.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\23.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\123.ico

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

Re: AutoHotkey apps for testing

#23 Post by guinness »

Yeh thats it, I just reference the index number of the Icon in the EXE! :D I am creating it now to show you how to have multiple icon sets.

Edit: I've had real problems with having more than 8 .ico files embedded into an EXE. So I will probably come back to this someday using PNG files like we do in DropIt.

Also I have re-uploaded a new version with a little bug fix, it's not so much of a bug fix but previously when started the icon would only show if a key was pressed as I wasn't analysing the state of keys before, it was as simple as $iIconPrevious to $iIconPrevious = -1 :P

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

Re: AutoHotkey apps for testing

#24 Post by guinness »

So I felt a little bad that I for some reason I couldn't get more icons in the application so I decided to update the application again. Before when you left clicked on the Icon it showed a small GUI about the state of the Keys which was static, now when you change the state of the Key(s) it will automatically update the GUI on the fly (and the Icon too :D) The Key states can also be clicked in the small GUI, if you want to change the state of the Key.
Last edited by guinness on Thu Mar 29, 2012 11:55 pm, edited 1 time in total.

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

Re: AutoHotkey apps for testing

#25 Post by guinness »

I've updated Lock State again with some code tweaks. Download in the previous post. The release is just code fixes for easier understanding of AutoIt!

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

Re: AutoHotkey apps for testing

#26 Post by guinness »

I've updated the source code for Lock State and compiled with the latest version of AutoIt.

I rarely ask for help but on this occasion if someone would be able to create some nice looking icons then I would really appreciate this. :)

Download: http://www.portablefreeware.com/forums/ ... 388#p36388

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

Re: AutoHotkey apps for testing

#27 Post by webfork »

guinness wrote:I've updated the source code for Lock State and compiled with the latest version of AutoIt.

I rarely ask for help but on this occasion if someone would be able to create some nice looking icons then I would really appreciate this.
It would be ideal to go with that whole yellow sign theme you've been working with but obviously not critical.

Can you post something about it on your page?

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

Re: AutoHotkey apps for testing

#28 Post by guinness »

The yellow icons I get from here, but I was wondering if someone could create some nice look tray icons as I don't feel it's fair to abuse dmg's hardwork.
Can you post something about it on your page?
I could of course.

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

Re: AutoHotkey apps for testing

#29 Post by guinness »

Thanks to dmg an official release (of Lock State) will be coming on 1st January 2012 called... <insert suggestion> :mrgreen:

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

Re: AutoHotkey apps for testing

#30 Post by dmg »

Oh ho! Now if I ever want to try adding my version to the DB I will have to up my game, so to speak. I relish the challenge! 8)
guinness wrote:<insert suggestion>
Good luck with this. It took me a week to come up with "Lock State". I admit that, while descriptive, it rather lacks imagination. :D

Post Reply