control sending all keyboard keys Topic is solved
control sending all keyboard keys
is there a shortcut to control send all the keyboard keys to a window without having to key out each and every key? i want to set a hotkey that toggles this on n off just so i can type on another window (my browser) even with another window in the foreground
Re: control sending all keyboard keys
Ideas are below, but I cannot say that this works perfectly.
Code: Select all
#Requires AutoHotkey v1.1.33
#MaxThreadsPerHotkey 2
SetBatchLines -1
winTitle := "ahk_exe notepad.exe"
control := "Edit1"
ih := InputHook()
ih.KeyOpt("{All}", "E")
ih.KeyOpt("{LCtrl}{RCtrl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}", "-E")
#If WinExist(winTitle)
F3::
If on := !on {
SoundBeep 1500
While on {
ih.Start(), ih.Wait()
If on
ControlSend % control, % "{Blind}{" ih.EndKey "}"
}
SoundBeep 1000
} Else ih.Stop()
Return
#If
Re: control sending all keyboard keys
thank you for the reply, i've been toying around with it and it works well, but it is still sending inputs simultaneously to the window I am on as well as the browser. is there any way to make the keys send only to the browser?mikeyww wrote: ↑24 May 2023, 23:19Ideas are below, but I cannot say that this works perfectly.
Code: Select all
#Requires AutoHotkey v1.1.33 #MaxThreadsPerHotkey 2 SetBatchLines -1 winTitle := "ahk_exe notepad.exe" control := "Edit1" ih := InputHook() ih.KeyOpt("{All}", "E") ih.KeyOpt("{LCtrl}{RCtrl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}", "-E") #If WinExist(winTitle) F3:: If on := !on { SoundBeep 1500 While on { ih.Start(), ih.Wait() If on ControlSend % control, % "{Blind}{" ih.EndKey "}" } SoundBeep 1000 } Else ih.Stop() Return #If
edit: i should be more specific, mainly I use the arrow keys alot. i kinda have it working on a script i made before but only for the arrow buttons for like controlling videos im watching on firefox, like to skip forward or back, play pause etc, using the following format
Code: Select all
numpad0::
{
SetControlDelay -1
ControlSend, , {space}, ahk_exe firefox.exe
}
numpad2::
{
SetControlDelay -1
ControlSend, , {down}, ahk_exe firefox.exe
}
Re: control sending all keyboard keys Topic is solved
An alternative is below.
Code: Select all
#Requires AutoHotkey v1.1.33
Global winTitle := "ahk_exe notepad.exe"
, control := "Edit1"
#If on && WinExist(winTitle)
Hotkey If, on && WinExist(winTitle)
Loop 0xFF {
key := GetKeyName(Format("VK{:02X}", 256 - A_Index))
If !InStr(key, "Button") && key != ""
Hotkey % "*" key, press, On
}
Loop Parse, % "!@#$%^&*()_+<>?{}|:"""
Hotkey % "*" A_LoopField, press, On
Loop Parse, % "Del,Down,End,PgUp,PgDn,Left,Right,Home,Ins", CSV
Hotkey % "*" A_LoopField, press, On
Hotkey If
#If
F3::
on := !on
SoundBeep 1000 + 500 * on
Return
press() {
hk := SubStr(A_ThisHotkey, 2)
ControlSend % control, % "{Blind}{" hk "}", % winTitle
}
Esc::ExitApp
Re: control sending all keyboard keys
thank you! I wish I was as good as you at making these lol, heck would be great if I could even understand what was going on in this code, there's just so much that I haven't encountered before in this, saved me from literally hotkeying every single key and a toggle activationmikeyww wrote: ↑27 May 2023, 06:56An alternative is below.
Code: Select all
#Requires AutoHotkey v1.1.33 Global winTitle := "ahk_exe notepad.exe" , control := "Edit1" #If on && WinExist(winTitle) Hotkey If, on && WinExist(winTitle) Loop 0xFF { key := GetKeyName(Format("VK{:02X}", 256 - A_Index)) If !InStr(key, "Button") && key != "" Hotkey % "*" key, press, On } Loop Parse, % "!@#$%^&*()_+<>?{}|:""" Hotkey % "*" A_LoopField, press, On Loop Parse, % "Del,Down,End,PgUp,PgDn,Left,Right,Home,Ins", CSV Hotkey % "*" A_LoopField, press, On Hotkey If #If F3:: on := !on SoundBeep 1000 + 500 * on Return press() { hk := SubStr(A_ThisHotkey, 2) ControlSend % control, % "{Blind}{" hk "}", % winTitle } Esc::ExitApp
Re: control sending all keyboard keys
Some comments are below. Enjoy!
Code: Select all
; This script sends typed keys to another window that may be inactive.
; The Hotkey command is used in a loop to create context-sensitive hotkeys.
; "Hotkey If, Expression" associates subsequently created hotkeys with a given #If expression.
; The #If expression must be provided somewhere in the script.
#Requires AutoHotkey v1.1.33
Global winTitle := "ahk_exe notepad.exe" ; Target window
, control := "Edit1" ; Target control (ClassNN seen in Window Spy)
#If on && WinExist(winTitle) ; Required to make the next statement work
Hotkey If, on && WinExist(winTitle) ; Hotkeys enabled if "on" & target exists
Loop 0xFF { ; Loop through 255 keys
key := GetKeyName(Format("VK{:02X}", 256 - A_Index)) ; Get the key name
If !InStr(key, "Button") && key != "" ; If it's not a button and not null,
Hotkey % "*" key, press, On ; then set a hotkey with wildcard
}
Loop Parse, % "!@#$%^&*()_+<>?{}|:""" ; Set hotkey for these special characters
Hotkey % "*" A_LoopField, press, On
Loop Parse, % "Del,Down,End,PgUp,PgDn,Left,Right,Home,Ins", CSV ; Set hotkey for these, too
Hotkey % "*" A_LoopField, press, On
Hotkey If ; Turn off context sensitivity
#If
F3:: ; F3 = Toggle the toggle
on := !on
SoundBeep 1000 + 500 * on
Return
press() { ; Executed when any key is pressed
hk := SubStr(A_ThisHotkey, 2) ; Strip the wildcard
ControlSend % control, % "{Blind}{" hk "}", % winTitle ; Send to target; include any modifiers
}
Esc::ExitApp
Re: control sending all keyboard keys
I love youmikeyww wrote: ↑28 May 2023, 18:38Some comments are below. Enjoy!
Code: Select all
; This script sends typed keys to another window that may be inactive. ; The Hotkey command is used in a loop to create context-sensitive hotkeys. ; "Hotkey If, Expression" associates subsequently created hotkeys with a given #If expression. ; The #If expression must be provided somewhere in the script. #Requires AutoHotkey v1.1.33 Global winTitle := "ahk_exe notepad.exe" ; Target window , control := "Edit1" ; Target control (ClassNN seen in Window Spy) #If on && WinExist(winTitle) ; Required to make the next statement work Hotkey If, on && WinExist(winTitle) ; Hotkeys enabled if "on" & target exists Loop 0xFF { ; Loop through 255 keys key := GetKeyName(Format("VK{:02X}", 256 - A_Index)) ; Get the key name If !InStr(key, "Button") && key != "" ; If it's not a button and not null, Hotkey % "*" key, press, On ; then set a hotkey with wildcard } Loop Parse, % "!@#$%^&*()_+<>?{}|:""" ; Set hotkey for these special characters Hotkey % "*" A_LoopField, press, On Loop Parse, % "Del,Down,End,PgUp,PgDn,Left,Right,Home,Ins", CSV ; Set hotkey for these, too Hotkey % "*" A_LoopField, press, On Hotkey If ; Turn off context sensitivity #If F3:: ; F3 = Toggle the toggle on := !on SoundBeep 1000 + 500 * on Return press() { ; Executed when any key is pressed hk := SubStr(A_ThisHotkey, 2) ; Strip the wildcard ControlSend % control, % "{Blind}{" hk "}", % winTitle ; Send to target; include any modifiers } Esc::ExitApp