Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto CapsLock


  • Please log in to reply
18 replies to this topic
sihgneg
  • New members
  • 2 posts
  • Last active: Jul 17 2015 07:28 PM
  • Joined: 15 Jul 2015

Not sure if anyone is still looking at this post but hopefully I can resurrect it. I've taken the code above to use for a different application and it works quite well except that when I'm in one of the CapsLock on applications and I try to use alt-tab to change applications it seems to trigger turning off CapsLock which in turn causes the alt-tab window to disappear which in turn returns me to the CapsLock application and then re-enables CapsLock and then prevents me from actually switching applications using alt-tab.

 

I'm pretty new to AutoHotKey and am hoping someone can recommend a tweak for this code that might correct that. Any pointers would be appreciated.



sihgneg
  • New members
  • 2 posts
  • Last active: Jul 17 2015 07:28 PM
  • Joined: 15 Jul 2015

I did some additional digging and I think I've found a solution which is to use window focus changes to trigger the CapsLock state change instead of monitoring it over and over. Here's the code I'm now using which seems to be working well:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force
#Persistent

Gui +LastFound
hwnd := WinExist()
DllCall("RegisterShellHookWindow", UInt, Hwnd)
MsgNum := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
return

ShellMessage(wParam, lParam)
{
	WinGetTitle, title, ahk_id %lParam%
	WinGet, WID1, ID, A
	
	;IsCapsOn := GetKeyState(CapsLock,T)
	GetKeyState, IsCapsOn, CapsLock, T
	
	If(isEageRelated(WID1))
	{
		If(IsCapsOn == "U")
		{
			SetCapsLockState, On
		}
	}
	else
	{
		If(IsCapsOn == "D")
		{
			SetCapsLockState, Off
		}
	}
	
	
}

isEageRelated(WinID)
{
	RetVal = 0
	WinGet ProcessName,ProcessName, ahk_id %WinID%
	If (ProcessName = "ebrowser.exe" or ProcessName = "3network.exe")
	{
		RetVal := 1
	}
	Return %RetVal%
}


corbel
  • New members
  • 1 posts
  • Last active: Aug 24 2015 02:41 PM
  • Joined: 24 Aug 2015

 

I did some additional digging and I think I've found a solution which is to use window focus changes to trigger the CapsLock state change instead of monitoring it over and over. Here's the code I'm now using which seems to be working well:

...

 

sihgneg, this bit of code works fantastic for enabling/disabling of caps lock based on windows focus.  Thank you.



wolverineblaine
  • Members
  • 1 posts
  • Last active: Dec 23 2015 02:50 PM
  • Joined: 11 Dec 2015

sihgneg,

 

This code works great. Thank you. 

 

One thing I have a question on... Is there a way to remove the feature that requires CTRL+CAPS for programs not controlled by this bit of code.  I would like the CAPS lock to work normally on the other programs not specified by the code.

 

Thanks!