IFWinActrive stop keyboard key from working out of the focused window
Posted: 14 Apr 2024, 17:18
So I may not look hard enough but I m stuck. The script Is not important I think but I general this is the idea. I have a script who use let say F4 for do a task like search something in "window explorer" (.fbx) and change sorting view from name and bla bla. I put windows in focus I want to use F4 only in Window but normal in other program let say Photoshot (test in chrome and other program same). But AHK just disable the F4 and mean don't even fire the F4 in other program if Window E is not in focus. I remove the IFWinAcrtice but this play the script in other program. Now I try to change the script, read have something to do with privileges user so I put AHK in run as admin so PS to and nothing. Still as long the script is on and "If WinActive" is on the script the F4 don't work.
Here the script or at last part just to test
[Mod edit: Fixed misplaced bracket character in code tags. Code goes between the two tags, not inside the second tag.]
[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]
Here the script or at last part just to test
Code: Select all
#Persistent
#NoEnv
F4:: ; F4 Hotkey
If WinActive("ahk_class CabinetWClass")
{
; Active window is Windows Explorer
Send, ^f ; Send Ctrl+F to focus on the search bar
Sleep, 500 ; Wait for search bar to focus
Send, .fbx{Enter} ; Search for .fbx files
Sleep, 2000 ; Wait for search results
}
Else
{
; Active window is not Windows Explorer
Send, {Blind}{F4} ; Pass through the F4 key press as normal
}
return
[Mod edit: Fixed misplaced bracket character in code tags. Code goes between the two tags, not inside the second tag.]
[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]