Page 1 of 1

Simple script doesn't work

Posted: 09 Jul 2022, 08:38
by anaxio
What am I doing wrong here? It won't send "a".

Code: Select all

a::
Input, SingleKey, L1
Send %SingleKey%
The point of that is to have any alphanumeric key focus a control and send the appropriate alphanumeric to that control:

Code: Select all

a::
b::
c:: ;and so forth, all alphanumerics
ControlFocus, somecontrol
Send %SingleKey%

Re: Simple sript doesn't work

Posted: 09 Jul 2022, 08:51
by Rohwedder
Hallo,
try:

Code: Select all

$a::
$b::
$c:: ;and so forth, all alphanumerics
SingleKey := SubStr(A_ThisHotkey, 2)
ControlFocus, somecontrol
Send %SingleKey%
Return

Re: Simple sript doesn't work

Posted: 09 Jul 2022, 08:59
by mikeyww

Code: Select all

Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Add, Edit, w300
Gui, Show, NoActivate, Controls
Loop, 75
 If ((char := Chr(A_Index + 47)) ~= "[0-9a-z]")
  Hotkey, %char%, Paste, On
Return

Paste:
Control, EditPaste,%A_ThisHotkey%, Edit1, ahk_class AutoHotkeyGUI
SoundBeep, 1500
Return

Re: Simple sript doesn't work

Posted: 09 Jul 2022, 09:06
by AlphaBravo
One more, accounts for upper/lower case

Code: Select all

loop, % 43
	Hotkey, % Chr(A_Index+47), focus
return

focus:
if !GetKeyState("CapsLock", "T")
	StringLower, key, A_ThisHotkey
else
	key := A_ThisHotkey
ControlFocus, somecontrol
Send % key
; or
ControlSend, somecontrol, % key, WinTitle
return

Re: Simple sript doesn't work

Posted: 09 Jul 2022, 10:09
by anaxio
Rohwedder' sript works fine! The other two I can't get to work. mikeyww's works by itself but not when applied to my situation, which is a Winamp library window:

Code: Select all

#IfWinActive ahk_class BaseWindow_RootWnd
Loop, 75
 If ((char := Chr(A_Index + 47)) ~= "[0-9a-z]")
  Hotkey, %char%, Paste, On
Return

Paste:
Control, EditPaste,%A_ThisHotkey%, SysListView321, ahk_class BaseWindow_RootWnd
Return
AlphaBravo's doesn't work either.