-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathSB (2).ahk
87 lines (75 loc) · 2.89 KB
/
SB (2).ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
; Various DllCall and Sendmessage to control Standard Scrollbars
; It will not work on Customized scrollbars (IE/FireFox etc)
;
; - Parameters
; hwnd = Unique ID(hwnd) of the control where Scrollbar belongs to, not window
; Which = "V"(vertical) or "H"(horizontal), can be 1(V) or 0(H)
;
; - Basic Functions
; SB_GetPos(hwnd, Which="V")
; SB_SetPos(hwnd, Which="V", To="0") ;it does not scroll pages actually
; SB_GetRange(hwnd, Which="V") ;eg) Min,Max
; SB_Show(hwnd, Which="V") ;Use carefully
; SB_Hide(hwnd, Which="V") ;Use carefully
;
; - Functions To scroll the page actually
; SB_LineUP(hwnd, Which="V")
; SB_LineDown(hwnd, Which="V")
; SB_PageUp(hwnd, Which="V")
; SB_PageDown(hwnd, Which="V")
; SB_Top(hwnd, Which="V")
; SB_Bottom(hwnd, Which="V")
;
; - When interact with horizontal scrollbar
; 'UP' means 'Left' and 'Down' means 'Right' for horizontal scrollbar
SB_GetPos(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 1 : (Which="H" || Which=0) ? 0 : 1
Return DllCall("GetScrollPos", "UInt", Hwnd, "Int", Which)
}
SB_SetPos(hwnd, Which="V", To="0"){
Which := (Which="V" || Which=1) ? 1 : (Which="H" || Which=0) ? 0 : 1
Return DllCall("SetScrollPos", "UInt", Hwnd, "Int", Which, "Int", To, "UInt", 1)
}
SB_GetRange(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 1 : (Which="H" || Which=0) ? 0 : 1
Dllcall("GetScrollRange", "uInt", hwnd, "int", Which, "uInt *", Min, "uInt *", Max)
Return Min "," Max
}
SB_Show(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 1 : (Which="H" || Which=0) ? 0 : 1
Return DllCall("ShowScrollBar", "uInt", Hwnd, "Int", Which, "Int", 1)
}
SB_Hide(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 1 : (Which="H" || Which=0) ? 0 : 1
Return DllCall("ShowScrollBar", "uInt", Hwnd, "Int", Which, "Int", 0)
}
SB_LineUP(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 0,,,ahk_id %hwnd%
Return Errorlevel
}
SB_LineDown(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 1,,,ahk_id %hwnd%
Return Errorlevel
}
SB_PageUp(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 2,,,ahk_id %hwnd%
Return Errorlevel
}
SB_PageDown(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 3,,,ahk_id %hwnd%
Return Errorlevel
}
SB_Top(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 6,,,ahk_id %hwnd%
Return Errorlevel
}
SB_Bottom(hwnd, Which="V"){
Which := (Which="V" || Which=1) ? 0x115 : (Which="H" || Which=0) ? 0x114 : 0x115
SendMessage, %Which%, 7,,,ahk_id %hwnd%
Return Errorlevel
}