Simple script doesn't work

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anaxio
Posts: 77
Joined: 02 Mar 2018, 15:03

Simple script doesn't work

09 Jul 2022, 08:38

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%
Rohwedder
Posts: 7718
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Simple sript doesn't work

09 Jul 2022, 08:51

Hallo,
try:

Code: Select all

$a::
$b::
$c:: ;and so forth, all alphanumerics
SingleKey := SubStr(A_ThisHotkey, 2)
ControlFocus, somecontrol
Send %SingleKey%
Return
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Simple sript doesn't work

09 Jul 2022, 08:59

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
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: Simple sript doesn't work

09 Jul 2022, 09:06

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
anaxio
Posts: 77
Joined: 02 Mar 2018, 15:03

Re: Simple sript doesn't work

09 Jul 2022, 10:09

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, just me, Rohwedder and 109 guests