Show Tool Tip When a certain Button is Held down & Removetool Tip when button is Released / Up

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
matsuikohiroka
Posts: 24
Joined: 06 Jun 2019, 17:12

Show Tool Tip When a certain Button is Held down & Removetool Tip when button is Released / Up

Post by matsuikohiroka » 02 Jun 2023, 21:07

need help creating an example script of tool tip

Scenario : when i held down / press down CTRL a tooltip will appear , the tooltip will only dissappear if

1. the CTRL modifier is released
2. when CTRL key is held down then combined with KEYS ( ex. Ctrl + A B C so forth ) or combined with modifier keys ex. ( Ctrl + SHIFT ) ( ctrl + alt ) ( ctrl + alt + shift ) so forth

thank you.

Rohwedder
Posts: 7647
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Show Tool Tip When a certain Button is Held down & Removetool Tip when button is Released / Up

Post by Rohwedder » 03 Jun 2023, 02:31

Hallo,
try:

Code: Select all

~*Ctrl::
ToolTip, only one Ctrl key is down
SetTimer, ~*Ctrl Up, 50
KeyWait, Ctrl
~*Ctrl Up::
IF StrLen(KeyCombination()) = 10
	Return
SetTimer, ~*Ctrl Up, Off
ToolTip
Return
KeyCombination(ExcludeKeys:="")
{ ;All pressed keys and buttons will be listed
    ExcludeKeys .= "{Shift}{Control}{Alt}{WheelUp}{WheelDown}"
    Loop, 0xFF
    {
        IF !GetKeyState(Key:=Format("VK{:02X}",0x100-A_Index),"P")
            Continue
        If !InStr(ExcludeKeys,Key:="{" GetKeyName(Key) "}")
            KeyCombination .= RegexReplace(Key,"Numpad(\D+)","$1")
    }
    Return, KeyCombination
}

Post Reply

Return to “Ask for Help (v1)”