a movable spot is created as a trigger for the gui. so, i call it spotmenu. spotmenu is scrollable if its content is more than a screen space can cope with. i think it's touch friendly as the buttons are relatively big.
spotmenu comes with some functions i copied from others, such as, SetCtrlFont, GuiControlTips, UpdateScrollBars, and OnScroll. in which, i have made some changes to GuiControlTips and OnScroll.
Code: Select all
_menu_=
(
= = = Top = = =
^#{Left} Switch Desktop (Send)
^#{Right} Switch Desktop (Send)
^z Undo (Send)
^w Close Tab (Send)
^a Select All (Send)
{Esc} Escape (Send)
{Enter} Enter (Send)
f Fullscreen Toggle (Send)
m{Enter} MyActivity.Google (Send)
- - - - - - - - - - - - - - - -
menu.Gui_OnEscape Return To mSpot (Function)
demo1 hello world (Gosub)
demo2 foobar (Gosub)
demo3 blablabla (Function)
demo4 bla bla (Func+Param) _menu_
demo5 bla bla bla (Func+Param) _menu_,dummy
= = = Bottom = = =
)
dummy = i am param the second
menu.Spot()
Return
demo1:
msgbox, this is demo1
return
demo2:
msgbox, this is demo2 this is demo2
return
demo3(){
msgbox, this is demo3 this is demo3 this is demo3
}
demo4(p){
msgbox, % p
}
demo5(p1, p2){
msgbox, % p1 "`n`n=========================`n`n" p2
}
#IfWinActive ahk_group SpotMenu
WheelUp::
WheelDown::
+WheelUp::
+WheelDown::OnScroll(InStr(A_ThisHotkey, "Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist())
#If
WM_DISPLAYCHANGE() {
WinGetPos, x, y,,, mSpot
If (x > A_ScreenWidth - 50)
x := A_ScreenWidth - 100
If (y > A_ScreenHeight - 125)
y := A_ScreenHeight - 175
Gui, mSpot:Show, x%x% y%y% NoActivate
}
WM_ACTIVATE() {
IfWinActive, mSpot
WinSet, TransColor, White, mSpot
Else WinSet, TransColor, White 64, mSpot
}
Class menu {
Spot() {
Gui, mSpot:New
Gui, +LastFound -Caption +AlwaysOnTop +ToolWindow
Gui, Color, White
Gui, Margin, 0, 0
Gui, Font, s150, Consolas
Gui, Add, Text, x0 y0 cB2D6F3 BackgroundTrans, ●
OnSuch := this.HitEvent.Bind(this)
GuiControl +g, Static1, % OnSuch
WinSet, TransColor, White 64
x := A_ScreenWidth - 100, y := A_ScreenHeight - 530
Gui, Show, x%x% y%y% NoActivate, mSpot
this.HitEvent() ; Init sPos
OnMessage(0x7E, "WM_DISPLAYCHANGE")
OnMessage(0x06, "WM_ACTIVATE")
}
HitEvent(hwnd := "") {
static sPos
global _menu_
If not StrLen(sPos)
{ WinGetPos, x, y,,, mSpot
sPos := x "," y
}If not StrLen(hwnd)
Return sPos
SendMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
GuiControlGet, wHwnd, Hwnd, %hwnd%
WinGetPos, x, y,,, ahk_id %wHwnd%
If x "," y = sPos
{ Gui, mSpot:Hide
this.SpotMenu(_menu_)
}Else
{ sPos := x "," y
SetTimer, Deactivate, -500
}Return
Deactivate:
Gui, mSpot:Hide
Gui, mSpot:Show, NoActivate
WinSet, TransColor, White 64, mSpot
Return
}
SpotMenu(t) {
global TT
Loop, Parse, t, `n
If RegExMatch(A_LoopField, "[^\t]+(?=\t)", m)
w%A_Index% := this.GetButtonWidth(m, "30 bold", "Consolas")
OnMessage(0x115, "OnScroll") ; WM_VSCROLL
OnMessage(0x114, "OnScroll") ; WM_HSCROLL
OnMessage(0x20A, "OnScroll") ; WM_MOUSEWHEEL
OnMessage(0x20E, "OnScroll") ; WM_MOUSEHWHEEL
OnMessage(0x119, "gHandler") ; WM_GESTURE
Gui, menu:New, hwndHmenu +Labelmenu.Gui_On
Gui, +Resize +0x300000 ; WS_VSCROLL | WS_HSCROLL
TT := New GuiControlTips(Hmenu), TT.SetDelayTimes(1000, 15000, -1)
Gui, Font, s30 bold, Consolas
ci := nl := 1
Loop, Parse, t, `n
If RegExMatch(A_LoopField, "[^\t]+(?=\t)", m)
{ If not nl
nl := (gx + gw + 25 + w%A_Index%) > A_ScreenWidth - 40
p := nl ? "" : "+", y := nl ? "y+28" : ""
Gui, Add, Button, HwndhBtn%ci% x%p%25 %y% h57, % (m, pi := ci, ci++)
OnSuch := this.MenuClick.Bind(this)
GuiControl +g, Button%pi%, % OnSuch
GuiControlGet, g, Pos, Button%pi%
TT.Attach(hBtn%pi%, RegExReplace(RegExReplace(SubStr(A_LoopField, 0) = "`r" ? SubStr(A_LoopField, 1, -1) : A_LoopField, "[^\t]+\t",,, 1), "\t", "`n"))
nl := (gx + gw) > (A_ScreenWidth - 116)
}Else
{ Gui, Add, Text, x25 cWhite, % SubStr(A_LoopField, 0) = "`r" ? SubStr(A_LoopField, 1, -1) : A_LoopField
nl := True
}
Gui, Color, Black
TT.SetTitle("Descriptions", LoadPicture("shell32.dll", "Icon222", ImageType))
SetCtrlFont(TT.HTIP, "s20", "Arial New")
Gui, +LastFound
WinSet, Transparent, 180
Gui, Show,, Touch Friendly Menu
GroupAdd, SpotMenu, % "ahk_id " . WinExist()
}
Gui_OnSize() {
UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight)
}
Gui_OnEscape() {
menu.OnClose()
Gui, mSpot:Show, NoActivate
WinSet, TransColor, White 64, mSpot
}
Gui_OnClose() {
ExitApp
}
OnClose() {
OnMessage(0x115, "") ; WM_VSCROLL
OnMessage(0x114, "") ; WM_HSCROLL
OnMessage(0x20A, "") ; WM_MOUSEWHEEL
OnMessage(0x20E, "") ; WM_MOUSEHWHEEL
OnMessage(0x119, "") ; WM_GESTURE
Gui, %A_Gui%:Destroy
}
GetButtonWidth(t, s, f) {
Gui, New
Gui, Font, s%s%, % f
Gui, Add, Button,, % t
GuiControlGet, g, Pos, Button1
Gui, Destroy
Return gW
}
MenuClick(h) {
global TT
theText := A_GuiControl
this.OnClose()
WinWaitNotActive, Touch Friendly Menu
Sleep, 500
If InStr(t := TT.GetText(h), "(Send)")
Send, %theText%
Else If InStr(t, "(Gosub)")
Gosub, %theText%
Else If InStr(t, "(Function)")
If pos := InStr(theText, ".")
className := SubStr(theText, 1, pos - 1), method := SubStr(theText, pos + 1), %className%[method]()
Else %theText%()
Else If InStr(t, "(Func+Param)")
{ RegExMatch(t, "[^\n]+$", m)
If InStr(m, ",")
{ Loop, Parse, m, `,
p%A_Index% := A_LoopField
StrReplace(m, ",",, c)
If c = 1
%theText%(%p1%, %p2%)
Else If c = 2
%theText%(%p1%, %p2%, %p3%)
Else If c = 3
%theText%(%p1%, %p2%, %p3%, %p4%)
Else If c = 4
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%)
Else If c = 5
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%, %p6%)
Else If c = 6
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%, %p6%, %p7%)
Else If c = 7
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%, %p6%, %p7%, %p8%)
Else If c = 8
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%, %p6%, %p7%, %p8%, %p9%)
Else If c = 9
%theText%(%p1%, %p2%, %p3%, %p4%, %p5%, %p6%, %p7%, %p8%, %p9%, %p10%)
Else{} ;more than 10 parameters is not supported
}Else %theText%(%m%)
}
Gui, mSpot:Show, NoActivate
WinSet, TransColor, White 64, mSpot
}
} ;end of class
SetCtrlFont(CtrlHwnd, FontOptions := "", FontName := "") { ;written by iPhilip
static WM_SETFONT := 0x0030, WM_GETFONT := 0x0031
DefaultGui := A_DefaultGui
Gui, New
Gui, Font, % FontOptions, % FontName
Gui, Add, Text, hwndhText, Text
hFont := DllCall("SendMessage", "Ptr", hText, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
Gui, Destroy
Gui, %DefaultGui%:Default
DllCall("SendMessage", "Ptr", CtrlHwnd, "UInt", WM_SETFONT, "Ptr", hFont, "Ptr", true)
Return hFont
}
; ======================================================================================================================
; Namespace: GuiControlTips
; AHK version: AHK 1.1.14.03
; Function: Helper object to simply assign ToolTips for GUI controls
; Tested on: Win 7 (x64)
; Change history:
; 1.1.00.01/2020-06-03/just me - fixed missing Static WS_EX_TOPMOST
; 1.1.00.00/2014-03-06/just me - Added SetDelayTimes()
; 1.0.01.00/2012-07-29/just me
; ======================================================================================================================
; CLASS GuiControlTips
;
; The class provides four public methods to register (Attach), unregister (Detach), update (Update), and
; disable/enable (Suspend) common ToolTips for GUI controls.
;
; Usage:
; To assign ToolTips to GUI controls you have to create a new instance of GuiControlTips per GUI with
; MyToolTipObject := New GuiControlTips(HGUI)
; passing the HWND of the GUI.
;
; After this you may assign ToolTips to your GUI controls by calling
; MyToolTipObject.Attach(HCTRL, "ToolTip text")
; passing the HWND of the control and the ToolTip's text. Pass True/1 for the optional third parameter if you
; want the ToolTip to be shown centered below the control.
;
; To remove a ToolTip call
; MyToolTipObject.Detach(HCTRL)
; passing the HWND of the control.
;
; To update the ToolTip's text call
; MyToolTipObject.Update(HCTRL, "New text!")
; passing the HWND of the control and the new text.
;
; To deactivate the ToolTips call
; MyToolTipObject.Suspend(True),
; to activate them again afterwards call
; MyToolTipObject.Suspend(False).
;
; To adjust the ToolTips delay times call
; MyToolTipObject.SetDelayTimesd(),
; specifying the delay times in milliseconds.
;
; That's all you can / have to do!
; ======================================================================================================================
Class GuiControlTips { ;written by @"just me"
; ===================================================================================================================
; INSTANCE variables
; ===================================================================================================================
HTIP := 0
HGUI := 0
CTRL := {}
; ===================================================================================================================
; CONSTRUCTOR __New()
; ===================================================================================================================
__New(HGUI) {
Static CLASS_TOOLTIP := "tooltips_class32"
Static CW_USEDEFAULT := 0x80000000
Static TTM_SETMAXTIPWIDTH := 0x0418
Static TTM_SETMARGIN := 0x041A
Static WS_EX_TOPMOST := 0x00000008
Static WS_STYLES := 0x80000002 ; WS_POPUP | TTS_NOPREFIX
; Create a Tooltip control ...
HTIP := DllCall("User32.dll\CreateWindowEx", "UInt", WS_EX_TOPMOST, "Str", CLASS_TOOLTIP, "Ptr", 0
, "UInt", WS_STYLES
, "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT
, "Ptr", HGUI, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Ptr")
If ((ErrorLevel) || !(HTIP))
Return False
; ... prepare it to display multiple lines if required
DllCall("User32.dll\SendMessage", "Ptr", HTIP, "Int", TTM_SETMAXTIPWIDTH, "Ptr", 0, "Ptr", A_ScreenWidth*96//A_ScreenDPI) ;touched by SundayProgrammer who took it from iPhilip response for AddTooltip v2.0
; ... set the instance variables
This.HTIP := HTIP
This.HGUI := HGUI
If (DllCall("Kernel32.dll\GetVersion", "UInt") & 0xFF) < 6 ; to avoid some XP issues ...
This.Attach(HGUI, "") ; ... register the GUI with an empty tiptext
}
; ===================================================================================================================
; DESTRUCTOR __Delete()
; ===================================================================================================================
__Delete() {
If (This.HTIP) {
DllCall("User32.dll\DestroyWindow", "Ptr", This.HTIP)
}
}
; ===================================================================================================================
; PRIVATE METHOD SetToolInfo - Create and fill a TOOLINFO structure
; ===================================================================================================================
SetToolInfo(ByRef TOOLINFO, HCTRL, TipTextAddr, CenterTip = 0) {
Static TTF_IDISHWND := 0x0001
Static TTF_CENTERTIP := 0x0002
Static TTF_SUBCLASS := 0x0010
Static OffsetSize := 0
Static OffsetFlags := 4
Static OffsetHwnd := 8
Static OffsetID := OffsetHwnd + A_PtrSize
Static OffsetRect := OffsetID + A_PtrSize
Static OffsetInst := OffsetRect + 16
Static OffsetText := OffsetInst + A_PtrSize
Static StructSize := (4 * 6) + (A_PtrSize * 6)
Flags := TTF_IDISHWND | TTF_SUBCLASS
If (CenterTip)
Flags |= TTF_CENTERTIP
VarSetCapacity(TOOLINFO, StructSize, 0)
NumPut(StructSize, TOOLINFO, OffsetSize, "UInt")
NumPut(Flags, TOOLINFO, OffsetFlags, "UInt")
NumPut(This.HGUI, TOOLINFO, OffsetHwnd, "Ptr")
NumPut(HCTRL, TOOLINFO, OffsetID, "Ptr")
NumPut(TipTextAddr, TOOLINFO, OffsetText, "Ptr")
Return True
}
; ===================================================================================================================
; PUBLIC METHOD Attach - Assign a ToolTip to a certain control
; Parameters: HWND - Control's HWND
; TipText - ToolTip's text
; Optional: ------------------------------------------------------------------------------
; CenterTip - Centers the tooltip window below the control
; Values: True/False
; Default: False
; Return values: On success: True
; On failure: False
; ===================================================================================================================
Attach(HCTRL, TipText, CenterTip = False) {
Static TTM_ADDTOOL := A_IsUnicode ? 0x0432 : 0x0404 ; TTM_ADDTOOLW : TTM_ADDTOOLA
If !(This.HTIP) {
Return False
}
If This.CTRL.HasKey(HCTRL)
Return False
TOOLINFO := ""
This.SetToolInfo(TOOLINFO, HCTRL, &TipText, CenterTip)
If DllCall("User32.dll\SendMessage", "Ptr", This.HTIP, "Int", TTM_ADDTOOL, "Ptr", 0, "Ptr", &TOOLINFO) {
This.CTRL[HCTRL] := 1
This.TTT[HCTRL] := TipText ;added by SundayProgrammer
Return True
} Else {
Return False
}
}
; ===================================================================================================================
; PUBLIC METHOD Detach - Remove the ToolTip for a certain control
; Parameters: HWND - Control's HWND
; Return values: On success: True
; On failure: False
; ===================================================================================================================
Detach(HCTRL) {
Static TTM_DELTOOL := A_IsUnicode ? 0x0433 : 0x0405 ; TTM_DELTOOLW : TTM_DELTOOLA
If !This.CTRL.HasKey(HCTRL)
Return False
TOOLINFO := ""
This.SetToolInfo(TOOLINFO, HCTRL, 0)
DllCall("User32.dll\SendMessage", "Ptr", This.HTIP, "Int", TTM_DELTOOL, "Ptr", 0, "Ptr", &TOOLINFO)
This.CTRL.Remove(HCTRL, "")
This.TTT.Remove(HCTRL, "") ;added by SundayProgrammer
Return True
}
; ===================================================================================================================
; PUBLIC METHOD Update - Update the ToolTip's text for a certain control
; Parameters: HWND - Control's HWND
; TipText - New text
; Return values: On success: True
; On failure: False
; ===================================================================================================================
Update(HCTRL, TipText) {
Static TTM_UPDATETIPTEXT := A_IsUnicode ? 0x0439 : 0x040C ; TTM_UPDATETIPTEXTW : TTM_UPDATETIPTEXTA
If !This.CTRL.HasKey(HCTRL)
Return False
TOOLINFO := ""
This.SetToolInfo(TOOLINFO, HCTRL, &TipText)
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_UPDATETIPTEXT, "Ptr", 0, "Ptr", &TOOLINFO)
This.TTT[HCTRL] := TipText ;added by SundayProgrammer
Return True
}
;added by SundayProgrammer
GetText(HCTRL) {
If !This.CTRL.HasKey(HCTRL)
Return ""
Return This.TTT[HCTRL]
}
; ===================================================================================================================
; PUBLIC METHOD Suspend - Disable/enable the ToolTip control (don't show / show ToolTips)
; Parameters: Mode - True/False (1/0)
; Default: True/1
; Return values: On success: True
; On failure: False
; Remarks: ToolTips are enabled automatically on creation.
; ===================================================================================================================
Suspend(Mode = True) {
Static TTM_ACTIVATE := 0x0401
If !(This.HTIP)
Return False
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_ACTIVATE, "Ptr", !Mode, "Ptr", 0)
Return True
}
; ===================================================================================================================
; PUBLIC METHOD SetDelayTimes - Set the initial, pop-up, and reshow durations for a tooltip control.
; Parameters: Init - Amount of time, in milliseconds, a pointer must remain stationary within
; a tool's bounding rectangle before the tooltip window appears.
; Default: -1 (system default time)
; PopUp - Amount of time, in milliseconds, a tooltip window remains visible if the
; pointer is stationary within a tool's bounding rectangle.
; Default: -1 (system default time)
; ReShow - Amount of time, in milliseconds, it takes for subsequent tooltip windows
; to appear as the pointer moves from one tool to another.
; Default: -1 (system default time)
; Return values: On success: True
; On failure: False
; Remarks: Times are set per ToolTip control and applied to all added tools.
; ===================================================================================================================
SetDelayTimes(Init = -1, PopUp = -1, ReShow = -1) {
Static TTM_SETDELAYTIME := 0x0403
Static TTDT_RESHOW := 1
Static TTDT_AUTOPOP := 2
Static TTDT_INITIAL := 3
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_INITIAL, "Ptr", Init)
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_AUTOPOP, "Ptr", PopUp)
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_RESHOW , "Ptr", ReShow)
}
;added by SundayProgrammer who largely took it from AddTooltip v2.0
SetTitle(theTitle := "", theIcon := 0) {
Static TTM_SETTITLE := A_IsUnicode ? 0x421 : 0x420 ; TTM_SETTITLEW : TTM_SETTITLEA
If StrLen(theTitle) > 99
theTitle := SubStr(theTitle, 1, 99)
If theIcon is not Integer
theIcon := 0
DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETTITLE, "Ptr", theIcon, "Ptr", &theTitle)
}
}
UpdateScrollBars(GuiNum, GuiWidth, GuiHeight) { ;written by lexikos
static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
Gui, %GuiNum%:Default
Gui, +LastFound
; Calculate scrolling area.
Left := Top := 9999
Right := Bottom := 0
WinGet, ControlList, ControlList
Loop, Parse, ControlList, `n
{
GuiControlGet, c, Pos, %A_LoopField%
if (cX < Left)
Left := cX
if (cY < Top)
Top := cY
if (cX + cW > Right)
Right := cX + cW
if (cY + cH > Bottom)
Bottom := cY + cH
}
Left -= 8
Top -= 8
Right += 8
Bottom += 8
ScrollWidth := Right-Left
ScrollHeight := Bottom-Top
; Initialize SCROLLINFO.
VarSetCapacity(si, 28, 0)
NumPut(28, si) ; cbSize
NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
; Update horizontal scroll bar.
NumPut(ScrollWidth, si, 12) ; nMax
NumPut(GuiWidth, si, 16) ; nPage
DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
; Update vertical scroll bar.
; NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
NumPut(ScrollHeight, si, 12) ; nMax
NumPut(GuiHeight, si, 16) ; nPage
DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
if (Left < 0 && Right < GuiWidth)
x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
if (Top < 0 && Bottom < GuiHeight)
y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
if (x || y)
DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)
}
OnScroll(wParam, lParam, msg, hwnd) { ;written by lexikos
static SIF_ALL=0x17, SCROLL_STEP=85 ;changed by SundayProgrammer from 10 to 85 for a more practical outcome
static xpos := 0, ypos := 0 ;added by SundayProgrammer - for touch gesture scrolling
global gFlag ;added by SundayProgrammer - for touch gesture scrolling
if DllCall("GetParent", "uint", hwnd) ;added by SundayProgrammer - a quick fix for the scenario when any scrollable control is involved
return ;added by SundayProgrammer - a quick fix for the scenario when any scrollable control is involved
bar := (msg=0x115) or (msg=0x20A) ; (SB_HORZ=0, SB_VERT=1) or (WM_MOUSEHWHEEL=0, WM_MOUSEWHEEL=1) ;changed by SundayProgrammer - for WM_MOUSEWHEEL and WM_MOUSEHWHEEL
if gFlag ;added by SundayProgrammer - for touch gesture scrolling
{ gAction(xpos, ypos, bar, hwnd) ;added by SundayProgrammer - for touch gesture scrolling
return ;added by SundayProgrammer - for touch gesture scrolling
} ;added by SundayProgrammer - for touch gesture scrolling
VarSetCapacity(si, 28, 0)
NumPut(28, si) ; cbSize
NumPut(SIF_ALL, si, 4) ; fMask
if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
return
VarSetCapacity(rect, 16)
DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
new_pos := NumGet(si, 20) ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
if msg=0x20A ;added by SundayProgrammer - for WM_MOUSEWHEEL
wParam := wParam>0x780000 ;added by SundayProgrammer - for WM_MOUSEWHEEL
else if msg=0x20E ;added by SundayProgrammer - for WM_MOUSEHWHEEL
wParam := wParam=0x780000 ;added by SundayProgrammer - for WM_MOUSEHWHEEL
action := wParam & 0xFFFF
if action = 0 ; SB_LINEUP
new_pos -= SCROLL_STEP
else if action = 1 ; SB_LINEDOWN
new_pos += SCROLL_STEP
else if action = 2 ; SB_PAGEUP
new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
else if action = 3 ; SB_PAGEDOWN
new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
else if (action = 5 || action = 4) ; SB_THUMBTRACK || SB_THUMBPOSITION
new_pos := wParam>>16
else if action = 6 ; SB_TOP
new_pos := NumGet(si, 8, "int") ; nMin
else if action = 7 ; SB_BOTTOM
new_pos := NumGet(si, 12, "int") ; nMax
else
return
min := NumGet(si, 8, "int") ; nMin
max := NumGet(si, 12, "int") - NumGet(si, 16) ; nMax-nPage
new_pos := new_pos > max ? max : new_pos
new_pos := new_pos < min ? min : new_pos
old_pos := NumGet(si, 20, "int") ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
x := y := 0
if bar = 0 ; SB_HORZ
x := old_pos-new_pos
else
y := old_pos-new_pos
; Scroll contents of window and invalidate uncovered area.
DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
; Update scroll bar.
NumPut(new_pos, si, 20, "int") ; nPos (saw "25" in another version, which exhibited a bug in my testing, whereas "20" (this version) worked fine so far)
DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
z := bar ? "y" : "x", %z%pos := new_pos ;added by SundayProgrammer - for touch gesture scrolling
}
gAction(byref xpos, byref ypos, bar, hwnd) { ;written by SundayProgrammer - for touch gesture scrolling
VarSetCapacity(si, 28, 0), NumPut(28, si), NumPut(0x17, si, 4), DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si), aPos := NumGet(si, 20, "int"), z := bar ? "y" : "x"
if not (%z%pos = aPos)
x := y := 0, %z% := %z%pos - aPos, DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0), %z%pos := aPos
}
gHandler(wParam, lParam, msg, hwnd) { ;written by SundayProgrammer - for touch gesture scrolling
global gFlag
gFlag := true
settimer, Reset_gFlag, -100
return
Reset_gFlag:
gFlag := false
return
}