forked from Pulover/PuloversMacroCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CbAutoComplete.ahk
38 lines (36 loc) · 1.16 KB
/
CbAutoComplete.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
;=======================================================================================
;
; Function: CbAutoComplete
; Description: Auto-completes typed values in a ComboBox.
;
; Author: Pulover [Rodolfo U. Batista]
; Usage: Call the function from the Combobox's gLabel.
;
;=======================================================================================
CbAutoComplete()
{ ; CB_GETEDITSEL = 0x0140, CB_SETEDITSEL = 0x0142
If ((GetKeyState("Delete", "P")) || (GetKeyState("Backspace", "P")))
return
GuiControlGet, lHwnd, Hwnd, %A_GuiControl%
SendMessage, 0x0140, 0, 0,, ahk_id %lHwnd%
MakeShort(ErrorLevel, Start, End)
GuiControlGet, CurContent,, %lHwnd%
GuiControl, ChooseString, %A_GuiControl%, %CurContent%
If (ErrorLevel)
{
ControlSetText,, %CurContent%, ahk_id %lHwnd%
PostMessage, 0x0142, 0, MakeLong(Start, End),, ahk_id %lHwnd%
return
}
GuiControlGet, CurContent,, %lHwnd%
PostMessage, 0x0142, 0, MakeLong(Start, StrLen(CurContent)),, ahk_id %lHwnd%
}
MakeLong(LoWord, HiWord)
{
return (HiWord << 16) | (LoWord & 0xffff)
}
MakeShort(Long, ByRef LoWord, ByRef HiWord)
{
LoWord := Long & 0xffff
, HiWord := Long >> 16
}