Guicontrol, text,, *Any letter on keyboard*

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Guicontrol, text,, *Any letter on keyboard*

Post by SirSocks » 16 Apr 2021, 07:51

Hello, I am trying to control the text within a gui. I don't want to use an Edit Box.
Is there any way to control the text within a gui without having to code every single letter of the keyboard?

All help and guidance is appreciated.

Image


Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#Persistent
#SingleInstance Force

gui, add, text, xm ym w300 center, This is my text gui
gui, add, text, xm y+20 wp center vMyText,
gui, add, button, gReset_gui, Reset
gui, show,, Text_Control_gui
return

#IfWinActive, Text_Control_gui

Numpad0::
DisplayText .= "0"
Guicontrol, text, MyText, %DisplayText%
return

Numpad1::
DisplayText .= "1"
Guicontrol, text, MyText, %DisplayText%
return

Numpad2::
DisplayText .= "2"
Guicontrol, text, MyText, %DisplayText%
return

Numpad3::
DisplayText .= "3"
Guicontrol, text, MyText, %DisplayText%
return

#IF ; Ends the "If" statement

Reset_gui:
DisplayText :=
Guicontrol, text, MyText, %DisplayText%
return

GuiClose:
Esc::
ExitApp
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Re: Guicontrol, text,, *Any letter on keyboard*

Post by SirSocks » 16 Apr 2021, 08:33

Thanks for pointing me to that link, It looks helpful.

This seems to do the trick....

Code: Select all

SingleKey := ""

TheStart:
Input, SingleKey, L1,0
DisplayKey .= SingleKey
Tooltip, % DisplayKey
GoTo, TheStart
return

~Backspace::
Length := StrLen(DisplayKey)
Length--
DisplayKey := SubStr(DisplayKey, 1, Length)
Tooltip, % DisplayKey
Return

~Esc::
ExitApp
Post Reply

Return to “Ask for Help (v1)”