[Q] IF this BUT NOT that?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pteronaut
Posts: 8
Joined: 10 Feb 2018, 16:25

[Q] IF this BUT NOT that?

22 Oct 2018, 05:59

I am using a script to turn Caps Lock on for certain windows that I found in the old forums written by Oldman and adjusted by KraZe_EyE. Found here: https://autohotkey.com/board/topic/1179 ... -solution/

What I need it to do is to also ignore certain EXEs (predominantly Outlook) which contain certain words which are also qualifiers for the window titles.

Any help would gratefully appreciated.

Code: Select all

#Persistent
status := GetKeyState("Capslock", "T") ? "On" : "Off"		; save current caps lock state
OldTitle =											; set oldtitle to 'blank"
SetTimer, CheckWinTitle, 500						; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
return

CheckWinTitle:
WinGetTitle, Title, A				; retrieve current window title, store in variable 'title'
WinGetClass, Classic, A				; retrieve current window CLASStitle, store in variable 'classic'

if Title = 							; if the window title is blank use the classtitle instead
	Title .= " " Classic

if (Title = OldTitle)				; if the title still matches the oldtitle we got last scan then we don't need to change anything
	return

OldTitle := Title					; but if it doesn't match store the new title in oldtitle for next scan's comparison

if title contains WireTrac,Syteline,Form1,Report Manager,Harness Creation,PPAP,EMD,KRSC,EXCEL
{									; if title contains any of the above program names then turn on CAPSLOCK
									; If the title doesn't match set the caps lock back to what it was.
	;status := GetKeyState("Capslock", "T") ? "On" : "Off"
	SetCapsLockState, On									
}
else
	SetCapsLockState, %status%		; ...Put caps lock back to the state it was when we started.
return
pteronaut
Posts: 8
Joined: 10 Feb 2018, 16:25

Re: [Q] IF this BUT NOT that?

22 Oct 2018, 08:01

I have tried adding WinGet file, ProcessPath, A and if file contains outlook bypass then placing bypass: after SetCapsLockState, On, but the script doesn't set caps lock with that there. If add msgbox in front of bypass, I get the msgbox when applicable, and caps lock alters.

Code: Select all

#Persistent
status := GetKeyState("Capslock", "T") ? "On" : "Off"		; save current caps lock state
OldTitle =											; set oldtitle to 'blank"
SetTimer, CheckWinTitle, 500						; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
return

CheckWinTitle:
WinGetTitle, Title, A				; retrieve current window title, store in variable 'title'
WinGetClass, Classic, A				; retrieve current window CLASStitle, store in variable 'classic'

if Title = 							; if the window title is blank use the classtitle instead
	Title .= " " Classic

if (Title = OldTitle)				; if the title still matches the oldtitle we got last scan then we don't need to change anything
	return

OldTitle := Title					; but if it doesn't match store the new title in oldtitle for next scan's comparison

if title contains WireTrac,Syteline,Form1,Report Manager,Harness Creation,PPAP,EMD,KRSC,EXCEL
{									; if title contains any of the above program names then turn on CAPSLOCK
									; If the title doesn't match set the caps lock back to what it was.
	WinGet file, ProcessPath, A
	;msgbox % file
	if file contains outlook bypass
	;status := GetKeyState("Capslock", "T") ? "On" : "Off"
	SetCapsLockState, On
	bypass:									
}
else
	SetCapsLockState, %status%		; ...Put caps lock back to the state it was when we started.
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Ineedhelplz and 315 guests