Here is a working script for Surface Pen Users for AutoHotKey 1.1.33.08:
Double click eraser (#F19): Show/Hide Touch Keyboard
Hold Eraser (#F18): Show start menu
Click eraser (#F20): hold RMB/release RMB (needed to me for Disco Elysium game)
Checked and solved CRAZY AMOUNT issues:
- Not working scripts without activating AutoHotKey window (first line solved to me)
- Touch keyboard not showing/hiding with AUTOHIDE task bar (solved)
- Little tweaks for better showing/hiding keyboard
Based on a lot examples. Best working for me - use as you want and if you optimize something or make some cool features - post here!
PS. Also - dont forget to switch off in pen settings default apps.
Code: Select all
#IfWinExist, ahk_class Shell_TrayWnd
{
#F18::Send, {Ctrl up}{LWin}
return
#F19::
if (WinActive(ahk_class IPTip_Main_Window)=0 OR tabtipDeactivate=true) {
tabtipDeactivate:=false
;show task bar (keyboard not shown if task bar is autohuded)
WinShow ahk_class Shell_TrayWnd
WinActivate ahk_class Shell_TrayWnd
;show keyboard
ToggleTouchKeyboard()
} else {
WinShow ahk_class Shell_TrayWnd
;hide keyboard
PostMessage,0x112,0xF060,,,ahk_class IPTip_Main_Window
tabtipDeactivate:=true
}
return
#F20::
clickState:=not clickState
If (clickState) {
Click, Down Right
} else {
Click, Up Right
}
return
}
ToggleTouchKeyboard()
{
; Translated to AHK from https://stackoverflow.com/a/39385492
Shell_TrayWnd := FindWindowEx( 0, 0, "Shell_TrayWnd")
TrayNotifyWnd := FindWindowEx( Shell_TrayWnd, 0, "TrayNotifyWnd")
TIPBand := FindWindowEx( TrayNotifyWnd, 0, "TIPBand")
if (!TIPBand or ErrorLevel)
{
MsgBox % "Could not get TIPBand. ErrorLevel: " ErrorLevel
}
else
{
PostMessage, 0x201, 1, 65537, , ahk_id %TIPBand%
PostMessage, 0x202, 1, 65537, , ahk_id %TIPBand%
}
}
FindWindowEx( hwnd_parent, hwnd_child, str_class, p_title=0 )
{
if ( p_title = 0 )
type_title = UInt
else
type_title = Str
return, DllCall( "FindWindowEx"
, UInt, hwnd_parent
, UInt, hwnd_child
, Str, str_class
, type_title, p_title )
}