Gui "splash image" for Caps Lock state toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
montyLalor
Posts: 8
Joined: 10 Dec 2017, 06:28

Gui "splash image" for Caps Lock state toggle

18 Dec 2017, 09:20

I need some help. Okay I need a lot, but I'll just stick to the ahk question for now:

Below is the code I've gleened / grafted from the awesome people around these parts.

I have two things I can't work out.

1) How do you make this Gui so that it does not take any focus from any window, anywhere, at any time?

2) How do I get these subscripts to activate upon a caps lock state toggle? The second code window is a script I use to totally surrender control of caps lock. (Currently enjoying telling anyone who'll listen that I'm too lazy to hit the Caps Lock Key!) Do I somehow have to combine the two scripts? Or can I make the top one detect a caps lock state toggle and apply the images I've created?

Code: Select all

SetWorkingDir %A_ScriptDir%
CapsSplash:

CapsState := GetKeyState("CapsLock", "T")
IfEqual, CapsState, 0
	{
		Gui, add, picture, , caps-off.png
		gosub, SplashCaps
	}
CapsState := GetKeyState("CapsLock", "T")
IfEqual, CapsState, 1
	{
		Gui, add, picture, , CAPS-ON.png
		gosub, SplashCaps
	}
return

SplashCaps:
Gui, Color, FFFFFF
Gui, -LastFound 
Winset, Transcolor,FFFFFF
Gui, -Caption +Alwaysontop
Gui, Show
Sleep, 475
Gui, Destroy
return

Code: Select all

#Persistent

SetTimer, WinActive, 500
return

WinActive:
WinGet, ActiveProcess, ProcessName, A
If ActiveProcess Contains acad,excel,notepad
{
	GetKeyState, CapsOnOff, CapsLock, T
	IfEqual, CapsOnOff, On
	{
	return
	}
	else
		{
		SetCapsLockState, On
		return
		}
}
	WinGet, ActiveProcess, ProcessName, A
	If ActiveProcess Contains Inventor
	{
		WinGetTitle, ActiveTitle, A
		If ActiveTitle = Format%A_Space%Text
		{
			GetKeyState, CapsOnOff, CapsLock, T
			IfEqual, CapsOnOff, On
			{
			return
			}
			else
				{
				SetCapsLockState, On
				return
				}
		}	
			WinGetTitle, ActiveTitle, A
			If ActiveTitle = Edit%A_Space%Dimension
			{
				GetKeyState, CapsOnOff, CapsLock, T
				IfEqual, CapsOnOff, On
				{
				return
				}
				else
					{
					SetCapsLockState, On
					return
					}
			}
	}
	GetKeyState, CapsOnOff, CapsLock, T
	IfEqual, CapsOnOff, Off
	{
	return
	}
	else
		{
		SetCapsLockState, Off
		return
		}
return
My AHK knowledge currently manoeuvres with the eloquence of a fiery wall of disintegrating fuselage...
geekgarage
Posts: 22
Joined: 17 Dec 2017, 11:03
Contact:

Re: Gui "splash image" for Caps Lock state toggle

18 Dec 2017, 15:08

the part where it doesn't change focus can only be done as far as i know if you create the gui and then update to show the image, then update it again to not show or show a transparent image. Never destroy the gui and you should be fine. The focus changes every time you create it, by just updating it you won't change focus and that can be done in background.

I've added everything that has to do with the GUI part, and if you have any questions let me know if you can't figure it out by looking up the base command to see how it works

if you run into the issue that where the box is you can't click what's under it. just update its position to be outside screen when not showing the image, like x 10000 y 10000 (far far away)

Here is an example from a little helper program i wrote for the game holdfast:

Code: Select all

leftToRightMS = 0
downToUpMS = 0
savedValueLR = 0
savedValueUD = 0

canonAdjAct := 0 ;Holdfast
canonAdjTxt = Off ;Holdfast

autoPressAct := 0 ;Holdfast
autoPressTxt = Off ;Holdfast

autoVOIPAct := 0 ;Holdfast
autoVOIPTxt = Off ;Holdfast

titleOnHelp = +Caption ;HELP
removeTitleTxt = Off ;HELP
updateMenu:
textInfo = ;HELP GUI Text
(
---------Holdfast Arty Helper----------

Cannon Adjust Mode - ( CTRL + Z )

-- Save Adjustment - ( CTRL + X )

-- Clear Adjustment - ( CTRL + C )

-- Reload Adjustment - ( CTRL + R )

Run Saved - ( CTRL + Q )

Auto Press Banter - ( CTRL + B )

Keep VOIP Open - ( AltGr + P )

Exit via task kill - ( AltGr + ESC )

Current LR: %leftToRightMS%
Current UD: %downToUpMS%

Saved LR: %savedValueLR%
Saved UD: %savedValueUD%
)
return

...

removeTitle: ;if I want to remove the title bar (including close and minimize)
	titleOnHelp := titleOnHelp="-Caption" ? "+Caption" : "-Caption"
	removeTitleTxt := removeTitleTxt="Off" ? "On" : "Off"
	Gui, guiHelp: %titleOnHelp%
	GuiControl, guiHelp:, OnOffRemoveTitle, %removeTitleTxt%.png
	if (removeTitleTxt = "On"){ ;Compensate X 3 pixel and Y 13 or 26 pixel
		GuiControl, guiHelp: MoveDraw, Status, x43 y32
		GuiControl, guiHelp: MoveDraw, OnOffCanonAdj, x13 y60
		GuiControl, guiHelp: MoveDraw, OnOffAutoPress, x13 y190
		GuiControl, guiHelp: MoveDraw, OnOffAutoVOIP, x13 y216
		GuiControl, guiHelp: MoveDraw, OnOffRemoveTitle, x95 y356
	} else {
		GuiControl, guiHelp: MoveDraw, Status, x40 y6
		GuiControl, guiHelp: MoveDraw, OnOffCanonAdj, x10 y34
		GuiControl, guiHelp: MoveDraw, OnOffAutoPress, x10 y164
		GuiControl, guiHelp: MoveDraw, OnOffAutoVOIP, x10 y190
		GuiControl, guiHelp: MoveDraw, OnOffRemoveTitle, x92 y330
	}
Return

...

updateGui(){ ;Function to update gui
	global canonAdjTxt
	global autoPressTxt
	global autoVOIPTxt
	
	Gosub, updateMenu
	GuiControl, guiHelp:,Status,%textInfo%
    	GuiControl, guiHelp:,OnOffCanonAdj, %canonAdjTxt%.png
	GuiControl, guiHelp:,OnOffAutoPress, %autoPressTxt%.png
	GuiControl, guiHelp:,OnOffAutoVOIP, %autoVOIPTxt%.png
	return
}

...

guiclose: ;close the GUI
closeGui:
	Gui guiHelp: Destroy
return

...

<^>!h:: ;Open the GUI
	Gosub, updateMenu
	global textInfo

	Gui, guiHelp: New
	Gui, guiHelp: font, ca6a6a6
	Gui, guiHelp: Color, black
	Gui, guiHelp: +AlwaysOnTop  %titleOnHelp% +ToolWindow
	Gui, guiHelp: Add, Text, x40 y6 vStatus, %textInfo%	
	Gui, guiHelp: Add, Picture, x10 y34 w23 h9 vOnOffCanonAdj, %canonAdjTxt%.png 
	Gui, guiHelp: Add, Picture, x10 y164 w23 h9 vOnOffAutoPress, %autoPressTxt%.png
	Gui, guiHelp: Add, Picture, x10 y190 w23 h9 vOnOffAutoVOIP, %autoVOIPTxt%.png
	Gui, guiHelp: Add, Picture, x92 y330 w50 h20 gremoveTitle vOnOffRemoveTitle, %removeTitleTxt%.png ;this will make the picture act like a button because of the 'gremoveTitle'. It will go to the 'removeTitle' sob function and run the code and then return to this point (if the sub function end in return). this acts like 'goto' hence the 'g' in front.
	
	;Gui, guiHelp: Add, Button, Default gcloseGui, EXIT (not in use)
	
	Gui, guiHelp: Show, x2400 y27
return

User avatar
montyLalor
Posts: 8
Joined: 10 Dec 2017, 06:28

Re: Gui "splash image" for Caps Lock state toggle

21 Dec 2017, 16:56

Hey geekgarage,

I managed to get my image "splash" to work using a gui function and setting a transparency colour, incorporating it into the caps on/off script and correcting the detection codes. A copy of the script is here (19th Dec post: update to original script): https://autohotkey.com/boards/viewtopic.php?f=6&t=41219

Enjoy your Festive Season!
My AHK knowledge currently manoeuvres with the eloquence of a fiery wall of disintegrating fuselage...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 303 guests