├── .gitignore
├── .gitmodules
├── AHK-ToolKit.ahk
├── Changelog.txt
├── README.md
├── lib
├── LexAHKL.dll
├── attach.ahk
├── hash.ahk
├── hkswap.ahk
├── htmlhelp.ahk
├── httprequest.ahk
├── klist.ahk
├── normalizephone.ahk
├── normalizetext.ahk
├── sc.ahk
├── sci.ahk
└── uriswap.ahk
└── res
├── AHK-TK.ico
├── Unicode32v1.bak
├── Unicode32v2.bak
├── Unicode64v1.bak
├── Unicode64v2.bak
└── img
├── AHK-TK_About.png
├── AHK-TK_Splash.png
└── AHK-TK_UnderConstruction.png
/.gitignore:
--------------------------------------------------------------------------------
1 | conf.xml
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lib/ScriptObj"]
2 | path = lib/ScriptObj
3 | url = D:/Cloud/RaptorX/OneDrive/Documents/coding/AutoHotkey/v1/Libraries/ScriptObj
4 |
--------------------------------------------------------------------------------
/Changelog.txt:
--------------------------------------------------------------------------------
1 | Versioning:
2 | Major.Minor.Fix-Build
3 |
4 | Legend:
5 | ==================
6 | + Add
7 | - Remove
8 | ! Fix
9 | * Change
10 | ^ Update
11 | ==================
12 |
13 | AHK-TK v0.8.7.3
14 | Date: Sun Oct 13 10:10:54 2013 -0400
15 |
16 | Changes:
17 |
18 | ! Fix Codet pop up not showing
19 |
20 | AHK-TK v0.8.7.2
21 | Date: Sun Oct 28 15:38:29 2012 +0100
22 |
23 | Changes:
24 |
25 | + Add LexAHK styles
26 | + Add Folding logic
27 |
28 | ^ Update scintilla wrapper to latest version
29 |
30 | AHK-TK v0.8.5.2
31 | Date: Tue Oct 23 02:01:30 2012 +0200
32 |
33 | Changes:
34 |
35 | * Change versioning
36 | ^ Update scintilla wrapper to latest version
37 | ^ Update code for new scintilla syntax
38 |
39 | Todo:
40 |
41 | + Add #ifwindow active functionality to hotkeys/hotstrings
42 |
43 | ! Fix Append to exported hotkeys/hotstrings function
44 |
45 | * Conditional download of AHK_L backup
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/README.md
--------------------------------------------------------------------------------
/lib/LexAHKL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/lib/LexAHKL.dll
--------------------------------------------------------------------------------
/lib/attach.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | Function: Attach
3 | Determines how a control is resized with its parent.
4 |
5 | hCtrl:
6 | - hWnd of the control if aDef is not empty.
7 | - hWnd of the parent to be reset if aDef is empty. If you omit this parameter function will use
8 | the first hWnd passed to it.
9 | With multiple parents you need to specify which one you want to reset.
10 | - Handler name, if parameter is string and aDef is empty. Handler will be called after the function has finished
11 | moving controls for the parent. Handler receives hWnd of the parent as its only argument.
12 |
13 | aDef:
14 | Attach definition string. Space separated list of attach options. If omitted, function working depends on hCtrl parameter.
15 | You can use following elements in the definition string:
16 |
17 | - "x,y,w,h" letters along with coefficients, decimal numbers which can also be specified in m/n form (see example below).
18 | - "r". Use "r1" (or "r") option to redraw control immediately after repositioning, set "r2" to delay redrawing 100ms for the control
19 | (prevents redrawing spam).
20 | - "p" (for "proportional") is the special coefficient. It will make control's dimension always stay in the same proportion to its parent
21 | (so, pin the control to the parent). Although you can mix pinned and non-pinned controls and dimensions that is rarely what you want.
22 | You will generally want to pin every control in the parent.
23 | - "+" or "-" enable or disable function for the control. If control is hidden, you may want to disable the function for
24 | performance reasons, especially if control is container attaching its children. Its perfectly OK to leave invisible controls
25 | attached, but if you have lots of them you can use this feature to get faster and more responsive updates.
26 | When you want to show disabled hidden control, make sure you first attach it back so it can take its correct position
27 | and size while in hidden state, then show it. "+" must be used alone while "-" can be used either alone or in Attach definition string
28 | to set up control as initially disabled.
29 |
30 | Remarks:
31 | Function monitors WM_SIZE message to detect parent changes. That means that it can be used with other eventual container controls
32 | and not only top level windows.
33 |
34 | You should reset the function when you programmatically change the position of the controls in the parent control.
35 | Depending on how you created your GUI, you might need to put "autosize" when showing it, otherwise resetting the Gui before its
36 | placement is changed will not work as intented. Autosize will make sure that WM_SIZE handler fires. Sometimes, however, WM_SIZE
37 | message isn't sent to the window. One example is for instance when some control requires Gui size to be set in advance in which case
38 | you would first have "Gui, Show, w100 h100 Hide" line prior to adding controls, and only Gui, Show after controls are added. This
39 | case will not trigger WM_SIZE message unless AutoSize is added.
40 |
41 |
42 | Examples:
43 | (start code)
44 | Attach(h, "w.5 h1/3 r2") ;Attach control's w, h and redraw it with delay.
45 | Attach(h, "-") ;Disable function for control h but keep its definition. To enable it latter use "+".
46 | Attach(h, "- w.5") ;Make attach definition for control but do not attach it until you call Attach(h, "+").
47 | Attach() ;Reset first parent. Use when you have only 1 parent.
48 | Attach(hGui2) ;Reset Gui2.
49 | Attach("Win_Redraw") ;Use Win_Redraw function as a Handler. Attach will call it with parent's handle as argument.
50 | Attach(h, "p r2") ;Pin control with delayed refreshing.
51 |
52 |
53 | ; This is how to do delayed refresh of entire window.
54 | ; To prevent redraw spam which can be annoying in some cases,
55 | ; you can choose to redraw entire window only when user has finished resizing it.
56 | ; This is similar to r2 option for controls, except it works with entire parent.
57 |
58 | Attach("OnAttach") ;Set Handler to OnAttach function
59 | ...
60 |
61 | OnAttach( Hwnd ) {
62 | global hGuiToRedraw := hwnd
63 | SetTimer, Redraw, -100
64 | }
65 |
66 | Redraw:
67 | Win_Redraw(hGuiToRedraw)
68 | return
69 | (end code)
70 | Working sample:
71 | (start code)
72 | #SingleInstance, force
73 | Gui, +Resize
74 | Gui, Add, Edit, HWNDhe1 w150 h100
75 | Gui, Add, Picture, HWNDhe2 w100 x+5 h100, pic.bmp
76 |
77 | Gui, Add, Edit, HWNDhe3 w100 xm h100
78 | Gui, Add, Edit, HWNDhe4 w100 x+5 h100
79 | Gui, Add, Edit, HWNDhe5 w100 yp x+5 h100
80 |
81 | gosub SetAttach ;comment this line to disable Attach
82 | Gui, Show, autosize
83 | return
84 |
85 | SetAttach:
86 | Attach(he1, "w.5 h")
87 | Attach(he2, "x.5 w.5 h r")
88 | Attach(he3, "y w1/3")
89 | Attach(he4, "y x1/3 w1/3")
90 | Attach(he5, "y x2/3 w1/3")
91 | return
92 | (end code)
93 |
94 | About:
95 | o 1.1 by majkinetor
96 | o Licensed under BSD
97 | */
98 | Attach(hCtrl="", aDef="") {
99 | Attach_(hCtrl, aDef, "", "")
100 | }
101 |
102 | Attach_(hCtrl, aDef, Msg, hParent){
103 | static
104 | local s1,s2, enable, reset, oldCritical
105 |
106 | if (aDef = "") { ;Reset if integer, Handler if string
107 | if IsFunc(hCtrl)
108 | return Handler := hCtrl
109 |
110 | ifEqual, adrWindowInfo,, return ;Resetting prior to adding any control just returns.
111 | hParent := hCtrl != "" ? hCtrl+0 : hGui
112 | loop, parse, %hParent%a, %A_Space%
113 | {
114 | hCtrl := A_LoopField, SubStr(%hCtrl%,1,1), aDef := SubStr(%hCtrl%,1,1)="-" ? SubStr(%hCtrl%,2) : %hCtrl%, %hCtrl% := ""
115 | gosub Attach_GetPos
116 | loop, parse, aDef, %A_Space%
117 | {
118 | StringSplit, z, A_LoopField, :
119 | %hCtrl% .= A_LoopField="r" ? "r " : (z1 ":" z2 ":" c%z1% " ")
120 | }
121 | %hCtrl% := SubStr(%hCtrl%, 1, -1)
122 | }
123 | reset := 1, %hParent%_s := %hParent%_pw " " %hParent%_ph
124 | }
125 |
126 | if (hParent = "") { ;Initialize controls
127 | if !adrSetWindowPos
128 | adrSetWindowPos := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "user32"), A_IsUnicode ? "astr" : "str", "SetWindowPos")
129 | ,adrWindowInfo := DllCall("GetProcAddress", "uint", DllCall("GetModuleHandle", "str", "user32"), A_IsUnicode ? "astr" : "str", "GetWindowInfo")
130 | ,OnMessage(5, A_ThisFunc), VarSetCapacity(B, 60), NumPut(60, B), adrB := &B
131 | ,hGui := DllCall("GetParent", "uint", hCtrl, "Uint")
132 |
133 | hParent := DllCall("GetParent", "uint", hCtrl, "Uint")
134 |
135 | if !%hParent%_s
136 | DllCall(adrWindowInfo, "uint", hParent, "uint", adrB), %hParent%_pw := NumGet(B, 28) - NumGet(B, 20), %hParent%_ph := NumGet(B, 32) - NumGet(B, 24), %hParent%_s := !%hParent%_pw || !%hParent%_ph ? "" : %hParent%_pw " " %hParent%_ph
137 |
138 | if InStr(" " aDef " ", "p")
139 | StringReplace, aDef, aDef, p, xp yp wp hp
140 | ifEqual, aDef, -, return SubStr(%hCtrl%,1,1) != "-" ? %hCtrl% := "-" %hCtrl% :
141 | else if (aDef = "+")
142 | if SubStr(%hCtrl%,1,1) != "-"
143 | return
144 | else
145 | %hCtrl% := SubStr(%hCtrl%, 2), enable := 1
146 | else {
147 | gosub Attach_GetPos
148 | %hCtrl% := ""
149 | loop, parse, aDef, %A_Space%
150 | {
151 | if (l := A_LoopField) = "-" {
152 | %hCtrl% := "-" %hCtrl%
153 | continue
154 | }
155 | f := SubStr(l,1,1), k := StrLen(l)=1 ? 1 : SubStr(l,2)
156 | if (j := InStr(l, "/"))
157 | k := SubStr(l, 2, j-2) / SubStr(l, j+1)
158 | %hCtrl% .= f ":" k ":" c%f% " "
159 | }
160 | return %hCtrl% := SubStr(%hCtrl%, 1, -1), %hParent%a .= InStr(%hParent%, hCtrl) ? "" : (%hParent%a = "" ? "" : " ") hCtrl
161 | }
162 | }
163 | ifEqual, %hParent%a,, return ;return if nothing to anchor.
164 |
165 | if !reset && !enable {
166 | %hParent%_pw := aDef & 0xFFFF, %hParent%_ph := aDef >> 16
167 | ifEqual, %hParent%_ph, 0, return ;when u create gui without any control, it will send message with height=0 and scramble the controls ....
168 | }
169 |
170 | if !%hParent%_s
171 | %hParent%_s := %hParent%_pw " " %hParent%_ph
172 |
173 | oldCritical := A_IsCritical
174 | critical, 5000
175 |
176 | StringSplit, s, %hParent%_s, %A_Space%
177 | loop, parse, %hParent%a, %A_Space%
178 | {
179 | hCtrl := A_LoopField, aDef := %hCtrl%, uw := uh := ux := uy := r := 0, hCtrl1 := SubStr(%hCtrl%,1,1)
180 | if (hCtrl1 = "-")
181 | ifEqual, reset,, continue
182 | else aDef := SubStr(aDef, 2)
183 |
184 | gosub Attach_GetPos
185 | loop, parse, aDef, %A_Space%
186 | {
187 | StringSplit, z, A_LoopField, : ; opt:coef:initial
188 | ifEqual, z1, r, SetEnv, r, %z2%
189 | if z2=p
190 | c%z1% := z3 * (z1="x" || z1="w" ? %hParent%_pw/s1 : %hParent%_ph/s2), u%z1% := true
191 | else c%z1% := z3 + z2*(z1="x" || z1="w" ? %hParent%_pw-s1 : %hParent%_ph-s2), u%z1% := true
192 | }
193 | flag := 4 | (r=1 ? 0x100 : 0) | (uw OR uh ? 0 : 1) | (ux OR uy ? 0 : 2) ; nozorder=4 nocopybits=0x100 SWP_NOSIZE=1 SWP_NOMOVE=2
194 | ;m(hParent, %hParent%a, hCtrl, %hCTRL%)
195 | DllCall(adrSetWindowPos, "uint", hCtrl, "uint", 0, "uint", cx, "uint", cy, "uint", cw, "uint", ch, "uint", flag)
196 | r+0=2 ? Attach_redrawDelayed(hCtrl) :
197 | }
198 | critical %oldCritical%
199 | return Handler != "" ? %Handler%(hParent) : ""
200 |
201 | Attach_GetPos: ;hParent & hCtrl must be set up at this point
202 | DllCall(adrWindowInfo, "uint", hParent, "uint", adrB), lx := NumGet(B, 20), ly := NumGet(B, 24), DllCall(adrWindowInfo, "uint", hCtrl, "uint", adrB)
203 | ,cx :=NumGet(B, 4), cy := NumGet(B, 8), cw := NumGet(B, 12)-cx, ch := NumGet(B, 16)-cy, cx-=lx, cy-=ly
204 | return
205 | }
206 |
207 | Attach_redrawDelayed(hCtrl){
208 | static s
209 | s .= !InStr(s, hCtrl) ? hCtrl " " : ""
210 | SetTimer, %A_ThisFunc%, -100
211 | return
212 | Attach_redrawDelayed:
213 | loop, parse, s, %A_Space%
214 | WinSet, Redraw, , ahk_id %A_LoopField%
215 | s := ""
216 | return
217 | }
--------------------------------------------------------------------------------
/lib/hash.ahk:
--------------------------------------------------------------------------------
1 | Hash(ByRef sData, SID=4) { ; SID = 3: MD5, 4: SHA1
2 | ; Lazlo: http://www.autohotkey.com/forum/viewtopic.php?p=113252#113252
3 |
4 | DllCall("advapi32\CryptAcquireContextW", UIntP,hProv, UInt,0, UInt,0, UInt,1, UInt,0xF0000000)
5 | DllCall("advapi32\CryptCreateHash", UInt,hProv, UInt,0x8000|0|SID, UInt,0, UInt,0, UIntP, hHash)
6 | DllCall("advapi32\CryptHashData", UInt,hHash, UInt,&sData, UInt,nLen := strlen(sData), UInt,0)
7 | DllCall("advapi32\CryptGetHashParam", UInt,hHash, UInt,2, UInt,0, UIntP,nSize, UInt,0)
8 | VarSetCapacity(HashVal, nSize, 0)
9 | DllCall("advapi32\CryptGetHashParam", UInt,hHash, UInt,2, UInt,&HashVal, UIntP,nSize, UInt,0)
10 | DllCall("advapi32\CryptDestroyHash", UInt,hHash)
11 | DllCall("advapi32\CryptReleaseContext", UInt,hProv, UInt,0)
12 |
13 | IFormat := A_FormatInteger
14 | SetFormat Integer, H
15 | Loop %nSize%
16 | sHash .= SubStr(*(&HashVal+A_Index-1)+0x100,-1)
17 | SetFormat Integer, %IFormat%
18 | Return sHash
19 | }
--------------------------------------------------------------------------------
/lib/hkswap.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | Function : hkSwap(key,[type])
3 | Author : RaptorX
4 | Version : 1.0
5 | Created : July 03 , 2010
6 | Updated :
7 |
8 | Description:
9 | --------------
10 | Converts short hotkeys (#w) to long hotkeys (Win + w) and vice-versa, the parameter must be a variable
11 | that contains the hotkey to be swapped, and the type is the type that you want to convert it to.
12 | The types can be the name of the type (long | short) enclosed in quotes or 0/1 respectively.
13 |
14 | The function returns 0 on failure.
15 |
16 | Examples:
17 | --------------
18 | hkey := "#W"
19 | msgbox % key := hkSwap(hkey, "long") ; Returns Win + W
20 | msgbox % key := hkSwap(hkey) ; Returns Win + W
21 |
22 | hkey := "Win + W"
23 | msgbox % key := hkSwap(hkey, "short") ; Returns #w
24 | msgbox % key := hkSwap(hkey, 1) ; Returns #w
25 | */
26 |
27 | hkSwap(byref key, type = 0){
28 |
29 | if (type = "long" || type = 0)
30 | {
31 | long_hk := RegexReplace(key, "\+", "Shift + ")
32 | long_hk := RegexReplace(long_hk, "\^", "Ctrl + ")
33 | long_hk := RegexReplace(long_hk, "!", "Alt + ")
34 | long_hk := RegexReplace(long_hk, "#", "Win + ")
35 | return long_hk ; long hotkey, ex. Ctrl + Alt + Shift + Win + s
36 | }
37 | else if (type = "short" || type = 1)
38 | {
39 | ; This matches regardless of the spacing, ex. "Shift + " or "Shift+"
40 | short_hk := RegexReplace(key, "Shift\s?\+\s?", "+")
41 | short_hk := RegexReplace(short_hk, "Ctrl\s?\+\s?", "^")
42 | short_hk := RegexReplace(short_hk, "Alt\s?\+\s?", "!")
43 | short_hk := RegexReplace(short_hk, "Win\s?\+\s?", "#")
44 | return short_hk ; short hotkey, ex. ^!+#s
45 | }
46 | else if type =
47 | {
48 | ; invalid type
49 | return false
50 | }
51 | } ; Function End
--------------------------------------------------------------------------------
/lib/htmlhelp.ahk:
--------------------------------------------------------------------------------
1 | htmlhelp(hwndCaller=0, pszFile="", dwData=""){
2 |
3 | static HH_KEYWORD_LOOKUP:=0xD
4 |
5 | VarSetCapacity(HH_AKLINK, HH_AKLINK_size := 8+5*A_PtrSize+4, 0) ; HH_AKLINK struct
6 | NumPut(HH_AKLINK_size, HH_AKLINK, 0, "UInt"),NumPut(&dwData, HH_AKLINK, 8)
7 |
8 | if (hwndCaller = "ForumHelper")
9 | {
10 | Loop, Parse, Clipboard,`n,`r
11 | if a_index > 1
12 | return
13 | ToolTip, % Clipboard
14 |
15 | if RegexMatch(Clipboard, "i)a_\w+")
16 | Match := matchclip("Variables")
17 | else if RegexMatch(Clipboard, "i)\s?(\w+)\(.*", fnct_name)
18 | Match := matchclip("Functions", fnct_name1)
19 | else
20 | Match := matchclip("Commands")
21 |
22 | ; httpRequest(Match, htm)
23 | if (InStr(htm, "403") || InStr(htm, "404") || !Match)
24 | {
25 | ToolTip, % "Not found. `nTrying a manual search, results may be inaccurate"
26 | Sleep 3*sec
27 | Match := matchclip("manual")
28 | if !Match
29 | ToolTip, % "Not found in the documentation files"
30 | }
31 |
32 | if WinActive("AutoHotkey Community")
33 | Send, {Raw}[url=%Match%]%Clipboard%[/url]
34 | else
35 | Run, % Match
36 | Sleep, 2*sec
37 | ToolTip
38 | return 0
39 | }
40 |
41 | if !DllCall("hhctrl.ocx\HtmlHelp", "Ptr", hwndCaller, "Str", pszFile, "Uint", HH_KEYWORD_LOOKUP, "Ptr", &HH_AKLINK)
42 | {
43 | SetTitleMatchMode, 2
44 | Run, % pszFile
45 | WinWait, AutoHotkey Help
46 | WinActivate, AutoHotkey Help
47 | if WinActive("AutoHotkey Help")
48 | Send, !n%clipboard%{Enter}
49 | }
50 | return 0
51 | }
--------------------------------------------------------------------------------
/lib/httprequest.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | ###############################################################################################################
3 | ### HTTPRequest. Version: 2.41 ###
4 | ###############################################################################################################
5 |
6 | Copyright © 2011-2012 [VxE]. All rights reserved.
7 |
8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that
9 | the following conditions are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
12 | following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
15 | following disclaimer in the documentation and/or other materials provided with the distribution.
16 |
17 | 3. The name "[VxE]" may not be used to endorse or promote products derived from this software without specific
18 | prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY [VxE] "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22 | SHALL [VxE] BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 | THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | HTTPRequest( URL, byref In_POST__Out_Data="", byref In_Out_HEADERS="", Options="" ) { ; -----------------------
30 | ; Function by [VxE], compatible with AHK v1.0.48.05 (basic), v1.1.00.00 (AHK-L ANSI, Unicode, x64) and later.
31 | ; Special thanks to derRaphael and everyone who reported bugs and/or suggested improvements.
32 | ; Source is freely available at: http://www.autohotkey.com/forum/viewtopic.php?t=66290
33 | ; MUFL-Info: http://dl.dropbox.com/u/13873642/mufl_httprequest.txt
34 | ; Submits one request to the specified URL with optional POST data and custom headers. Upon success, returns
35 | ; the number of bytes downloaded OR the number of characters in the response. Otherwise, returns zero and a
36 | ; description of the error is placed in 'In_Out_HEADERS'. The response body and headers are placed into
37 | ; 'In_POST__Out_Data' and 'In_Out_HEADERS' respectively, and text data is converted from the codepage stated in
38 | ; the header to the script's ANSI codepage OR to UTF-16 for unicode versions of AHK.
39 | ; "ErrorLevel" is set to '0' if there is a problem, otherwise it is set to the HTTP response code.
40 |
41 | Static version := "2.41", Ptr, PtrSize, IsUnicode, MyACP, MyCharset, Default_Agent, WorA := ""
42 | , Default_Accept_Types := "text/xml, text/json; q=0.4, text/html; q=0.3, text/*; q=0.2, */*; q=0.1"
43 | ; This list of content subtypes is not official, I just globbed together a few MIME subtypes to use
44 | ; as a whitelist for converting downloaded text to the script's codepage. If the Content-Type
45 | ; response header IS "text/..." OR one of these subtypes follows the "/", then the data is treated
46 | ; as text. Otherwise, the data is treated as binary and the user must deal with it as binary.
47 | , Text_Content_Subtypes := "/atom/html/json/rss/soap/xhtml/xml/x-www-form-urlencoded"
48 | ; The list of internet flags and values has been condensed and obfuscated for version (09-10-2011).
49 | ; Flag values may be found here > http://msdn.microsoft.com/en-us/library/aa383661%28v=vs.85%29.aspx
50 | , internet_flags_list := "
51 | ( LTRIM JOIN|INTERNET_FLAG_
52 | ....
53 | NEED_FILE
54 | MUST_CACHE_REQUEST|.
55 | FWD_BACK|.
56 | FORMS_SUBMIT|..
57 | PRAGMA_NOCACHE|.
58 | NO_UI|.
59 | HYPERLINK|.
60 | RESYNCHRONIZE|.
61 | IGNORE_CERT_CN_INVALID|.
62 | IGNORE_CERT_DATE_INVALID|.
63 | IGNORE_REDIRECT_TO_HTTPS|.
64 | IGNORE_REDIRECT_TO_HTTP|..
65 | RESTRICTED_ZONE|.
66 | NO_AUTH|.
67 | NO_COOKIES|.
68 | READ_PREFETCH|.
69 | NO_AUTO_REDIRECT|.
70 | KEEP_CONNECTION|.
71 | SECURE|.
72 | FROM_CACHE
73 | OFFLINE|.
74 | MAKE_PERSISTENT|.
75 | DONT_CACHE|...
76 | NO_CACHE_WRITE|.
77 | RAW_DATA|.
78 | RELOAD|
79 | )"
80 | ; Update (12-10-2011): The list of security flags and values is condensed and obfuscated.
81 | ; Flag values may be found here > http://msdn.microsoft.com/en-us/library/aa385328%28v=VS.85%29.aspx
82 | , security_flags_list := "
83 | ( LTRIM JOIN|SECURITY_FLAG_
84 | SECURE|.
85 | SSL|.
86 | SSL3|.
87 | PCT|.
88 | PCT4|.
89 | IETFSSL4|..
90 | IGNORE_REVOCATION|.
91 | IGNORE_UNKNOWN_CA|.
92 | IGNORE_WRONG_USAGE|...
93 | IGNORE_CERT_CN_INVALID|.
94 | IGNORE_CERT_DATE_INVALID|.
95 | IGNORE_REDIRECT_TO_HTTPS|.
96 | IGNORE_REDIRECT_TO_HTTP|............
97 | FORTEZZA|.
98 | 40BIT
99 | NORMALBITNESS
100 | STRENGTH_WEAK|.
101 | 128BIT
102 | STRENGTH_STRONG|.
103 | 56BIT
104 | STRENGTH_MEDIUM|.
105 | UNKNOWNBIT|
106 | )"
107 | , Codepage_Charsets := "|
108 | ; Codepage list taken from here > http://msdn.microsoft.com/en-us/library/dd317756%28v=vs.85%29.aspx
109 | ( LTRIM JOIN|
110 | 00037=IBM037|00437=IBM437|00500=IBM500|00708=ASMO-708|00720=DOS-720|00737=ibm737
111 | 00775=ibm775|00850=ibm850|00852=ibm852|00855=IBM855|00857=ibm857|00858=IBM00858|00860=IBM860
112 | 00861=ibm861|00862=DOS-862|00863=IBM863|00864=IBM864|00865=IBM865|00866=cp866|00869=ibm869
113 | 00870=IBM870|00874=windows-874|00875=cp875|00932=shift_jis|00936=gb2312|00949=ks_c_5601-1987
114 | 00950=big5|01026=IBM1026|01047=IBM01047|01140=IBM01140|01141=IBM01141|01142=IBM01142
115 | 01143=IBM01143|01144=IBM01144|01145=IBM01145|01146=IBM01146|01147=IBM01147|01148=IBM01148
116 | 01149=IBM01149|01200=utf-16|01201=unicodeFFFE|01250=windows-1250|01251=windows-1251
117 | 01252=Windows-1252|01253=windows-1253|01254=windows-1254|01255=windows-1255
118 | 01256=windows-1256|01257=windows-1257|01258=windows-1258|01361=Johab|10000=macintosh
119 | 10001=x-mac-japanese|10002=x-mac-chinesetrad|10003=x-mac-korean|10004=x-mac-arabic
120 | 10005=x-mac-hebrew|10006=x-mac-greek|10007=x-mac-cyrillic|10008=x-mac-chinesesimp
121 | 10010=x-mac-romanian|10017=x-mac-ukrainian|10021=x-mac-thai|10029=x-mac-ce
122 | 10079=x-mac-icelandic|10081=x-mac-turkish|10082=x-mac-croatian|12000=utf-32|12001=utf-32BE
123 | 20000=x-Chinese-CNS|20001=x-cp20001|20002=x-Chinese-Eten|20003=x-cp20003|20004=x-cp20004
124 | 20005=x-cp20005|20105=x-IA5|20106=x-IA5-German|20107=x-IA5-Swedish|20108=x-IA5-Norwegian
125 | 20127=us-ascii|20261=x-cp20261|20269=x-cp20269|20273=IBM273|20277=IBM277|20278=IBM278
126 | 20280=IBM280|20284=IBM284|20285=IBM285|20290=IBM290|20297=IBM297|20420=IBM420|20423=IBM423
127 | 20424=IBM424|20833=x-EBCDIC-KoreanExtended|20838=IBM-Thai|20866=koi8-r|20871=IBM871
128 | 20880=IBM880|20905=IBM905|20924=IBM00924|20932=EUC-JP|20936=x-cp20936|20949=x-cp20949
129 | 21025=cp1025|21866=koi8-u|28591=iso-8859-1|28592=iso-8859-2|28593=iso-8859-3|28594=iso-8859-4
130 | 28595=iso-8859-5|28596=iso-8859-6|28597=iso-8859-7|28598=iso-8859-8|28599=iso-8859-9
131 | 28603=iso-8859-13|28605=iso-8859-15|29001=x-Europa|38598=iso-8859-8-i|50220=iso-2022-jp
132 | 50221=csISO2022JP|50222=iso-2022-jp|50225=iso-2022-kr|50227=x-cp50227|51932=euc-jp
133 | 51936=EUC-CN|51949=euc-kr|52936=hz-gb-2312|54936=GB18030|57002=x-iscii-de|57003=x-iscii-be
134 | 57004=x-iscii-ta|57005=x-iscii-te|57006=x-iscii-as|57007=x-iscii-or|57008=x-iscii-ka
135 | 57009=x-iscii-ma|57010=x-iscii-gu|57011=x-iscii-pa|65000=utf-7|65001=utf-8|
136 | )"
137 |
138 | ; Step 1: Initialize internal variables, including the static variables for unknown constants.
139 | If ( WorA = "" )
140 | {
141 | If ( A_PtrSize = "" ) ; Check for 64 bit environment
142 | PtrSize := 4, Ptr := "UInt"
143 | Else PtrSize := A_PtrSize, Ptr := "Ptr"
144 | If !( IsUnicode := 1 = A_IsUnicode ) ; Check for unicode (wide char) environment
145 | ; GetACP > http://msdn.microsoft.com/en-us/library/ms905215.aspx
146 | WorA := "A", MyACP := SubStr( 100000.0 + DllCall("GetACP"), 2, 5 )
147 | Else WorA := "W", MyACP := "01200" ; UTF-16
148 | ; Detect the active codepage and look up the charset identifier for it (default = UTF-8)
149 | MyCharset := ( 7 = pos := 7 + InStr( Codepage_Charsets, "|" MyACP "=" ) ) ? "UTF-8"
150 | : SubStr( Codepage_Charsets, pos, InStr( Codepage_Charsets, "|", 0, pos ) - pos )
151 | SplitPath, A_ScriptName,,,, Default_Agent
152 | Default_Agent .= "/1.0 (Language=AutoHotkey/" A_AhkVersion "; Platform=" A_OSVersion ")"
153 | }
154 |
155 | ; Initialize local variables
156 | Internet_Open_Type := 1 ; INTERNET_OPEN_TYPE_DIRECT = 1 ; _PRECONFIG = 0 ; _PROXY = 3
157 | Security_Flags := Security_Flags_Add := Security_Flags_Nix := 0
158 | Response_Code := "0"
159 | Do_Callback := 0
160 | Do_NonBinary_Up := 0
161 | Do_Binary_Down := 0
162 | Do_Up_MD5_Hash := 0
163 | Do_Dn_MD5_Hash := 0
164 | Do_File_Upload := 0
165 | Do_Multipart := 0
166 | Do_Download_To_File := 0
167 | Do_Download_Resume := 0
168 | Do_Legacy_Dual_Output := 0
169 | Agent := Default_Agent
170 | Accept_Types := Default_Accept_Types
171 | Multipart_Boundary := ""
172 | proxy_bypass := ""
173 | Method_Verb := ""
174 | MyErrors := ""
175 | dbuffsz := 0
176 | port := 0
177 | dtsz := 0
178 | Convert_POST_To_Codepage := MyACP
179 |
180 | ; Initialize typical flags for a normal request. These can be modified with the 'Options' parameter.
181 | Internet_Flags := 0
182 | | 0x400000 ; INTERNET_FLAG_KEEP_CONNECTION
183 | | 0x80000000 ; INTERNET_FLAG_RELOAD
184 | | 0x20000000 ; INTERNET_FLAG_NO_CACHE_WRITE
185 |
186 | StringLen, Content_Length, In_POST__Out_Data ; predetermine the content-length.
187 | Content_Length <<= IsUnicode
188 |
189 | ; Step 2: Crack the url into its components. WinINet\InternetCrackURL limits the url to about 2060
190 | ; characters, which is unacceptable, especially for a function designed to service web APIs.
191 |
192 | hbuffer := "The provided url could not be parsed: """ URL """" ; pre-generate the bad-url error
193 |
194 | ; Crack the scheme (setting it to 'http' if omitted, allowing a url like "www.***.com")
195 | If ( pos := InStr( URL, "://" ) )
196 | {
197 | StringLeft, scheme, URL, pos - 1
198 | StringLower, scheme, scheme
199 | StringTrimLeft, URL, URL, pos + 2
200 | If ( scheme = "https" ) ; Connect using SSL. Add the following internet flags:
201 | Internet_Flags |= 0x1000 ; INTERNET_FLAG_IGNORE_CERT_CN_INVALID
202 | | 0x2000 ; INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
203 | | 0x800000 ; INTERNET_FLAG_SECURE ; Technically, this is redundant for https
204 | Else If ( scheme != "http" )
205 | Return 0, ErrorLevel := 0, In_Out_HEADERS := "HTTPRequest does not support '" scheme "' type connections."
206 | }
207 | Else scheme := "http"
208 |
209 | ; Crack the path and query (leave them joined as one string because that's how HttpOpenRequest accepts them).
210 | StringLeft, host, URL, pos := InStr( URL "/", "/" ) - 1
211 | StringTrimLeft, URL, URL, pos
212 |
213 | ; Crack the username and password from the host (if present).
214 | If ( pos := InStr( host, "@" ) )
215 | {
216 | StringLeft, user, host, pos - 1
217 | StringTrimLeft, host, host, pos
218 | If ( pos := InStr( user, ":" ) )
219 | {
220 | StringTrimLeft, pass, user, pos
221 | StringLeft, user, user, pos - 1
222 | }
223 | Else pass := ""
224 | }
225 | Else user := pass := ""
226 |
227 | ; Crack the port from the host. If the host looks like a bracketed IP literal, look for the colon
228 | ; to the right of the close-bracket. Default port is 80 for HTTP and 443 for HTTPS
229 | If ( pos := InStr( host, ":", 0, InStr( host, "[" ) = 1 ? InStr( host, "]" ) + 1 : 1 ) )
230 | && ( 0 < port := 0 | SubStr( host, pos + 1 ) ) && ( port < 65536 )
231 | {
232 | StringTrimLeft, port, host, pos
233 | StringLeft, host, host, pos - 1
234 | }
235 | Else port := scheme = "https" ? 443 : 80
236 |
237 | ; Return error if the host is blank (don't check for other format errors).
238 | If ( host = "" )
239 | Return 0, ErrorLevel := 0, In_Out_HEADERS := hbuffer
240 |
241 | ; Step 3: Parse the request headers so we can copy them to an internal buffer, make them pretty, and
242 | ; handle special headers (like acceptable mime types, user agent and content specs).
243 | StringLen, pos, In_Out_HEADERS
244 | VarSetCapacity( hbuffer, 1 + pos << IsUnicode )
245 | hbuffer := "`r`n"
246 | Loop, Parse, In_Out_HEADERS, `n
247 | {
248 | StringReplace, rbuffer, A_LoopField, :, `n
249 | Loop, Parse, rbuffer, `n, % "`t`r "
250 | If ( A_Index = 1 )
251 | rbuffer := A_LoopField
252 | Else If ( A_LoopField = "" )
253 | If ( rbuffer = "Content-MD5" )
254 | Do_Up_MD5_Hash := 1
255 | Else Continue
256 | Else If ( rbuffer = "Accept" )
257 | Accept_Types := A_LoopField
258 | Else If ( rbuffer = "Content-Length" ) && ( 0 < 1 | A_LoopField )
259 | Content_Length := A_LoopField
260 | Else If ( rbuffer = "Content-Type" )
261 | {
262 | hbuffer .= "Content-Type: " A_LoopField "`r`n"
263 | StringReplace, Multipart_Boundary, A_LoopField, % ",", % ";", A
264 | If ( 7 != pos := 7 + InStr( Multipart_Boundary, "charset=" ) )
265 | && ( pos := InStr( Codepage_Charsets, SubStr( Multipart_Boundary, pos
266 | , InStr( Multipart_Boundary ";" , ";", 0, pos ) - pos ) "|" ) )
267 | StringMid, Convert_POST_To_Codepage, Codepage_Charsets, pos - 5, 5
268 |
269 | ; NOT YET IMPLEMENTED: detect multipart content and determine the boundary
270 | Multipart_Boundary := ( InStr( A_LoopField, "Multipart/" ) != 1
271 | || 9 = pos := 9 + InStr( Multipart_Boundary, "boundary=" ) ) ? ""
272 | : SubStr( Multipart_Boundary, pos, InStr( Multipart_Boundary ";", ";" ) - pos )
273 | }
274 | Else If ( rbuffer = "Referrer" )
275 | hbuffer .= "Referer: " A_LoopField "`r`n"
276 | Else If ( rbuffer = "User-Agent" )
277 | Agent := A_LoopField
278 | Else hbuffer .= rbuffer ": " A_LoopField "`r`n"
279 | }
280 | ; Automatically add the 'no cookies' flag if the user specified a custom cookie. The flag actually tells
281 | ; wininet not to automatically handle cookies (which 'automatically' ignores custom cookie headers).
282 | IfInString, hbuffer, % "`r`nCookie: "
283 | options .= "`n+NO_COOKIES"
284 |
285 | ; Step 4: Extract the multipart envelope from the options parameter, then parse the options normally.
286 | If ( Multipart_Boundary != "" ) && ( pos := InStr( options, "--" Multipart_Boundary ) )
287 | && ( ( 4 + StrLen( Multipart_Boundary ) ) != ( Multipart_Boundary := 4
288 | + StrLen( Multipart_Boundary ) + InStr( options, "--" Multipart_Boundary "--", 0, 0 ) ) )
289 | {
290 | StringMid, Multipart_Envelope, options, pos, Multipart_Boundary - pos
291 | options := SubStr( options, 1, pos - 1 ) SubStr( options, Multipart_Boundary )
292 | ; Do_Multipart := 1 ; NOT YET IMPLEMENTED
293 | }
294 | Loop, Parse, options, `n
295 | {
296 | If InStr( A_LoopField, ">" ) + 3 >> 2 = 1
297 | {
298 | ; Handle the legacy output-file syntax
299 | Loop, Parse, A_LoopField, >, % "`t`n`r "
300 | If ( A_Index = 1 )
301 | options := ( InStr( A_LoopField, "R" ) ? "RESUME`n" : "SAVEAS`n" )
302 | , Do_Legacy_Dual_Output := !!InStr( A_LoopField, "N" )
303 | Else options .= A_LoopField
304 | }
305 | Else IfInString, A_LoopField, :
306 | StringReplace, options, A_LoopField, :, `n
307 | Else options := A_LoopField "`n"
308 | Loop, Parse, options, `n, % "`t`r "
309 | If ( A_Index = 1 )
310 | StringUpper, options, A_LoopField
311 | ; AutoProxy option: use IE's proxy configuration
312 | Else If ( options = "AUTOPROXY" )
313 | Internet_Open_Type := !!A_LoopField || A_LoopField = "" ? 0 : 1
314 | ; Binary option: do not attempt to convert downloaded data to the script's codepage.
315 | Else If ( options = "BINARY" )
316 | Do_Binary_Down := !!A_LoopField || A_LoopField = ""
317 | ; Callback option: inform a function in the script about the transaction progress
318 | Else If ( options = "CALLBACK" )
319 | {
320 | If ( pos := InStr( A_LoopField, "," ) ) || ( pos := InStr( A_LoopField, ";" ) )
321 | || ( pos := InStr( A_LoopField, "`t" ) ) || ( pos := InStr( A_LoopField, " " ) )
322 | {
323 | StringLeft, Do_Callback_Func, A_LoopField, pos - 1
324 | StringTrimLeft, Do_Callback_3rdParam, A_LoopField, pos
325 | Loop, Parse, Do_Callback_3rdParam, `n, % "`t`r " ; explicit trim
326 | Do_Callback_3rdParam := A_LoopField
327 | }
328 | Else Do_Callback_Func := A_LoopField
329 |
330 | Do_Callback := IsFunc( Do_Callback_Func ) + 3 >> 2 = 1
331 | }
332 | ; Charset option: convert POST text's codepage before uploading it
333 | Else If ( options = "CHARSET" )
334 | Do_NonBinary_Up := !( pos := InStr( Codepage_Charsets, "=" A_LoopField "|" ) ) ? Convert_POST_To_Codepage
335 | : SubStr( Codepage_Charsets, pos - 5, 5 )
336 | ; CheckMD5 option: use the indicated URL as the proxy server for this request.
337 | Else If ( options = "CHECKMD5" ) || ( options = "CHECK MD5" )
338 | Do_Dn_MD5_Hash := 1
339 | ; Codepage option: convert POST text's codepage before uploading it
340 | Else If ( options = "CODEPAGE" )
341 | Do_NonBinary_Up := ( A_LoopField | 0 < 1 || A_LoopField >> 16 ) ? Convert_POST_To_Codepage
342 | : ( Convert_POST_To_Codepage := SubStr( A_LoopField + 100000.0, 2, 5 ) )
343 | ; Flags option: add or remove flags
344 | Else If InStr( options, "+" ) = 1 || InStr( options, "-" ) = 1
345 | {
346 | ; When handling flag options, first determine whether the flag is being added or removed.
347 | StringLeft, flag_plus_or_minus, options, 1
348 | Loop, Parse, options, +-, % "`t`n`r _" ; explicit trim
349 | options := A_LoopField
350 |
351 | ; For backwards compatibility, support the "+FLAG: " syntax.
352 | If ( options = "FLAG" )
353 | StringUpper, options, A_LoopField
354 |
355 | ; Determine whether the flag is a security flag or a regular flag and get its value
356 | If ( pos := InStr( internet_flags_list, "|" options "|" ) )
357 | || ( pos := InStr( internet_flags_list, "|INTERNET_FLAG_" options "|" ) )
358 | {
359 | StringLeft, options, internet_flags_list, pos
360 | StringReplace, options, options, ., ., UseErrorLevel
361 | If ( flag_plus_or_minus = "+" )
362 | Internet_Flags |= 1 << ErrorLevel
363 | Else Internet_Flags &= ~( 1 << ErrorLevel )
364 | }
365 | ; Look in the security flags for one with this name (or this short name)
366 | Else If ( pos := InStr( security_flags_list, "|" options "|" ) )
367 | || ( pos := InStr( security_flags_list, "|SECURITY_FLAG_" options "|" ) )
368 | {
369 | StringLeft, options, security_flags_list, pos
370 | StringReplace, options, options, ., ., UseErrorLevel
371 | If ( flag_plus_or_minus = "+" )
372 | Security_Flags_Add |= 1 << ErrorLevel
373 | Else Security_Flags_Nix |= 1 << ErrorLevel
374 | }
375 | ; If the first letter is an 'S', and the rest is an INT power of 2, it's a security flag
376 | Else If ( InStr( options, "S" ) = 1 ) && ( 0 < pos := Abs( SubStr( options, 2 ) ) )
377 | && ( pos = 1 << Round( Ln( pos ) / Ln(2) ) )
378 | {
379 | If ( flag_plus_or_minus = "+" )
380 | Security_Flags_Add |= pos
381 | Else Security_Flags_Nix |= pos
382 | }
383 | ; If it is an INT power of 2, treat it as an internet flag
384 | Else If ( 0 < pos := Abs( options ) ) && ( pos = 1 << Round( Ln( pos ) / Ln(2) ) )
385 | If ( flag_plus_or_minus = "+" )
386 | Internet_Flags |= pos
387 | Else Internet_Flags &= ~pos
388 | }
389 | ; Method option: use a different verb when creating the request
390 | Else If ( options = "METHOD" ) && InStr( "|GET|HEAD|POST|PUT|DELETE|OPTIONS|TRACE|", "|" A_LoopField "|" )
391 | StringUpper, Method_Verb, A_LoopField
392 | ; Proxy option: use the indicated URL as the proxy server for this request.
393 | Else If ( options = "PROXY" )
394 | Internet_Open_Type := 3, proxy_url := A_LoopField
395 | ; Proxy Bypass option: the URL should not beaccessed through the proxy.
396 | Else If ( options = "PROXY BYPASS" )
397 | proxy_bypass .= A_LoopField "`r`n"
398 | ; Resume OR SaveAs options: download the data to the hard drive and NOT to memory
399 | Else If ( options = "RESUME" ) || ( options = "SAVEAS" ) || ( options = "SAVE AS" )
400 | {
401 | file_ext := FileExist( output_file_path := A_LoopField )
402 | If ( file_ext = "" )
403 | {
404 | ; The file does not exist, so make sure the folder it belong to DOES exist
405 | If !( pos := InStr( output_file_path, "\", 0, 0 ) )
406 | || FileExist( SubStr( output_file_path, 1, pos - 1 ) )
407 | Do_Download_To_File := 1
408 | Else MyErrors .= "`nThe file path """ output_file_path """ is not valid. The folder can't be found."
409 | }
410 | Else If InStr( file_ext, "D" )
411 | {
412 | ; The user only gave us a path to a folder. We'll have to figure out the filename from the url
413 | file_ext := "V://x/E/" url
414 | SplitPath, file_ext, file_ext
415 | StringLeft, file_ext, file_ext, InStr( file_ext "?", "?" ) - 1
416 | output_file_path .= ( SubStr( output_file_path, 0 ) = "\" ? "" : "\" )
417 | . ( file_ext = "" ? "HTTPRequest " A_Year "-" A_MM "-" A_DD "_" SubStr( A_Now A_MSec, 9 ) ".txt" : file_ext )
418 | }
419 | Else
420 | ; The file exists, so the path is OK. Check if the user wants to resume a download.
421 | If ( options = "RESUME" )
422 | FileGetSize, Do_Download_Resume, % output_file_path
423 | }
424 | ; Upload option: use a file on the disk as the data source for the file upload.
425 | Else If ( options = "UPLOAD" )
426 | {
427 | If ( pos := InStr( A_LoopField, "*", 0, 0 ) )
428 | {
429 | Upload_File_Path := SubStr( A_LoopField, 1, pos - 1 ) "`n" SubStr( A_LoopField, pos + 1 )
430 | Loop, Parse, Upload_File_Path, `n, % "`t`r " ; explicit trim
431 | If ( A_Index = 1 )
432 | Upload_File_Path := A_LoopField
433 | Else If ( 0 < 0 | A_LoopField )
434 | Do_File_Upload := !FileExist( Upload_File_Path ) ? 0 : 0 | 1 + A_LoopField
435 | }
436 | Else Do_File_Upload := !FileExist( Upload_File_Path := A_LoopField ) ? 0 : 1
437 |
438 | If ( Do_File_Upload )
439 | {
440 | FileGetsize, Content_Length, % Upload_File_Path
441 | ; If ( Content_Length < Do_File_Upload )
442 | ; MyErrors .= "`nThe range specified for the partial file upload is invalid: file size (" Content_Length ") is less than " Do_File_Upload - 1 "."
443 | ; Else If ( 1 < Do_File_Upload )
444 | ; NYI: append a '*' then a number to the upload file path to SKIP the first N bytes when uploading.
445 | ; hbuffer .= "Content-Range: bytes " Do_File_Upload - 1 "-" Content_Length - 1 "/" Content_Length "`r`n"
446 | }
447 | Else MyErrors .= "`nFile upload failed: the file """ Upload_File_Path """ could not be found."
448 | }
449 | }
450 | StringTrimRight, proxy_bypass, proxy_bypass, 2
451 |
452 | ; Step 5: copy the POST data from the input variable to a local buffer. This is to protect the data
453 | ; from being altered or released during the upload (which may take a while). Also check whether
454 | ; the user wants to change the character encoding of text-type data (e.g: from UTF-16 to UTF-8).
455 | ; Also, even if we're uploading from a file, 'dbuffsz' must be the number of bytes in the data.
456 | If ( 0 < Content_Length )
457 | {
458 | If ( Do_File_Upload )
459 | {
460 | ; If we're doing a file upload, do NOT copy the files contents to a buffer yet. DO make
461 | ; sure the content-type header is present.
462 | VarSetCapacity( dbuffer, 4096, 0 )
463 | dbuffsz := Content_Length := SubStr( Content_Length + 0.0, 1, 1 + FLOOR( LOG( Content_Length )))
464 | hbuffer .= "Content-Length: " Content_Length "`r`n"
465 | IfNotInString, hbuffer, % "`r`nContent-Type: "
466 | {
467 | SplitPath, Upload_File_Path,,, file_ext
468 | hbuffer .= "Content-Type: " ( file_ext = "xml" ? "text/xml"
469 | : file_ext = "txt" ? "application/x-www-form-urlencoded"
470 | : "application/octet-stream" ) "`r`n"
471 | }
472 | ; Add an MD5 hash to the headers if that option is used
473 | If ( Do_Up_MD5_Hash )
474 | hbuffer .= "Content-MD5: " HTTPRequest_MD5( hbuffer, Upload_File_Path ) "`r`n"
475 | }
476 | Else If !( Do_NonBinary_Up ) || ( Do_NonBinary_Up = MyACP ) || ( Do_Multipart )
477 | {
478 | ; Either the POST is binary data or is already in the desired encoding, so just copy it.
479 | VarSetCapacity( dbuffer, dbuffsz := Content_Length, 0 )
480 | DllCall( "RtlMoveMemory", Ptr, &dbuffer, Ptr, &In_POST__Out_Data, "Int", Content_Length )
481 | Content_Length := SubStr( Content_Length + 0.0, 1, 1 + FLOOR( LOG( Content_Length )))
482 | hbuffer .= "Content-Length: " Content_Length "`r`n"
483 | IfNotInString, hbuffer, % "`r`nContent-Type: "
484 | hbuffer .= "Content-Type: " ( InStr( dbuffer, "> 2 = 1 ? "text/xml"
485 | : "application/x-www-form-urlencoded" ) "; charset=" MyCharset
486 | }
487 | Else
488 | {
489 | ; Change the character encoding while copying the POST data into the local buffer.
490 | IfNotInString, hbuffer, % "`r`nContent-Type: "
491 | {
492 | hbuffer .= "Content-Type: " ( InStr( dbuffer, "> 2 = 1 ? "text/xml"
493 | : "application/x-www-form-urlencoded" )
494 | If ( 7 != pos := 7 + InStr( Codepage_Charsets, "|" Do_NonBinary_Up "=" ) )
495 | hbuffer .= "; charset=" SubStr( Codepage_Charsets, pos, InStr( Codepage_Charsets, "|", 0, pos ) - pos )
496 | hbuffer .= "`r`n"
497 | }
498 | If ( IsUnicode )
499 | pos := &In_POST__Out_Data, rbuffsz := Content_Length >> 1
500 | Else
501 | {
502 | ; If this isn't a UTF-16 environment, convert the POST data to UTF-16. rbuffsz = bytes
503 | If ( 0 < rbuffsz := DllCall( "MultiByteToWideChar", "UInt", MyACP, "UInt", 0, Ptr, &In_POST__Out_Data, "Int", Content_Length, Ptr, 0, "Int", 0 ) )
504 | {
505 | VarSetCapacity( rbuffer, rbuffsz + 1 << 1, 0 )
506 | ; MultiByteToWideChar > http://msdn.microsoft.com/en-us/library/dd319072%28v=vs.85%29.aspx
507 | DllCall( "MultiByteToWideChar", "UInt", MyACP, "UInt", 0, Ptr, &In_POST__Out_Data, "Int", Content_Length, Ptr, pos := &rbuffer, "Int", rbuffsz )
508 | }
509 | Else MyErrors .= "`nThere was a problem converting codepage " MyACP " to " Convert_POST_To_Codepage ". 'MultiByteToWideChar' failed: Return value = " rbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
510 | }
511 | ; Convert the UTF-16 string to a multi-byte string in the chosen codepage
512 | If ( 0 < rbuffsz ) ; a zero or negative length here indicates a prior error
513 | If ( 0 < dbuffsz := DllCall( "WideCharToMultiByte", "UInt", Do_NonBinary_Up, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, 0, "Int", 0, Ptr, 0, Ptr, 0 ) )
514 | {
515 | VarSetCapacity( dbuffer, dbuffsz + 1, 0 )
516 | ; WideCharToMultiByte > http://msdn.microsoft.com/en-us/library/dd374130%28v=vs.85%29.aspx
517 | DllCall( "WideCharToMultiByte", "UInt", Do_NonBinary_Up, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, &dbuffer, "Int", dbuffsz, Ptr, 0, Ptr, 0 )
518 | Content_Length := SubStr( dbuffsz + 0.0, 1, 1 + FLOOR( LOG( dbuffsz )))
519 | hbuffer .= "Content-Length: " Content_Length "`r`n"
520 | }
521 | Else MyErrors .= "`nThere was a problem converting codepage " MyACP " to " Convert_POST_To_Codepage ". 'WideCharToMultiByte' failed: Return value = " dbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
522 | VarSetCapacity( rbuffer, 0 ) ; free this temporary buffer
523 | ; Add an MD5 hash to the headers if that option is used
524 | If ( Do_Up_MD5_Hash )
525 | hbuffer .= "Content-MD5: " HTTPRequest_MD5( dbuffer, dbuffsz ) "`r`n"
526 | }
527 | ; Set up an INTERNET_BUFFERS structure in preparation for calling HttpSendRequestEx
528 | VarSetCapacity( INTERNET_BUFFERS, 28 + PtrSize * 3, 0 )
529 | NumPut( 28 + PtrSize * 3, INTERNET_BUFFERS, 0, "Int" )
530 | NumPut( Content_Length, INTERNET_BUFFERS, 16 + PtrSize * 3, "Int" )
531 | }
532 |
533 | ; Update (future): assemble multipart/form-data here by combining the text from 'options' with
534 | ; the data the user wants to upload. How it works: the text portion of the multipart data is split
535 | ; at the first instance of "", and the data buffer is expanded to account for the
536 | ; length of the data plus the (codepage converted) lengths of the two portions. The, the first
537 | ; portion is copied or converted and placed into the front of the data buffer. The data is copied
538 | ; to the right of that, and finally, the second portion is copied or converted to the right of that.
539 | /*
540 | If ( Do_Multipart )
541 | {
542 | ; The multipart envelope is baked here. The text is split at "" and the two
543 | ; parts are converted to the desired codepage. When the upload begins, the first chunk(s) begin
544 | ; with the first part of the envelope, and the last chunk(s) end with the second. Doing it
545 | ; piecemeal like this is the simplest way to support disk and memory sources for the data.
546 | ; NOTE: when doing file-uploads WITH multipart/form-data, do NOT cache the file's data, instead
547 | ; modify the first and last chunk to begin and end with the respective parts of the envelope.
548 | ; Store the length of the first part of the envelope in "Do_Multipart"
549 | ; Don't forget to change the Content-Length to the real size of the eventual data.
550 |
551 | StringGetPos, Do_Multipart, Multipart_Envelope,
552 | }
553 | */
554 |
555 | ; Step 6: Build the pointer array for the accept types string
556 | ; The trick to this step is actually leaving all of the accept types in one string, then building
557 | ; the pointer array using the address + position of each member, then inserting nulls to make it
558 | ; look like a collection of independent null-terminated strings.
559 | ; First thing is to replace delimiting commas with newlines (but not quoted literal commas).
560 | Loop, Parse, Accept_Types, "
561 | If ( A_Index = 1 )
562 | StringReplace, Accept_Types, A_LoopField, `,, `n, A
563 | Else If ( A_Index & 1 )
564 | {
565 | StringReplace, Accept_PtrArray, A_LoopField, `,, `n, A
566 | Accept_Types .= Accept_PtrArray
567 | }
568 | Else Accept_Types .= """" A_LoopField """"
569 |
570 | ; Then trim whitespace around the delimiters and count how many accept-types there are
571 | Loop, Parse, Accept_Types, `n, % "`t`r "
572 | If ( 1 = pos := A_Index )
573 | Accept_Types := A_LoopField
574 | Else Accept_Types .= "`n" A_LoopField
575 |
576 | ; Wipe the variable we'll use as the pointer array. The array itself should be null-terminated, so add an extra member.
577 | VarSetCapacity( Accept_PtrArray, pos * PtrSize + PtrSize, 0 )
578 | pos := 0
579 | ; For each member, put the address + offset into the pointer array, then end it with a null.
580 | Loop, Parse, Accept_Types, `n
581 | {
582 | NumPut( &Accept_Types + pos, Accept_PtrArray, A_Index * PtrSize - PtrSize, Ptr )
583 | pos += 1 + StrLen( A_LoopField ) << IsUnicode
584 | NumPut( 0, Accept_Types, pos - 1 - IsUnicode, IsUnicode ? "UShort" : "UChar" )
585 | }
586 |
587 | ; Set the default HTTP verb to 'POST' if there is data to upload, 'GET' otherwise.
588 | Method_Verb := Method_Verb != "" ? Method_Verb : 0 < Content_Length ? "POST" : "GET"
589 | ; Trim the leading CRLF from the headers buffer.
590 | StringTrimLeft, hbuffer, hbuffer, 2
591 |
592 | ; Do an error check before we load WinINet. If we have errors, don't continue.
593 | ; Afterwards, if we encounter errors, don't simply return but continue to the cleanup step.
594 | If InStr( MyErrors, "`n" )
595 | Return 0, In_Out_HEADERS := SubStr( MyErrors, 2 ), ErrorLevel := oel
596 |
597 | ; Step 7: Load WinINet.dll and initialize the internet connection and request.
598 | ; Kernel32.dll\LoadLibrary > http://msdn.microsoft.com/en-us/library/ms684175%28v=VS.85%29.aspx
599 | If !( hModule := DllCall( "LoadLibrary" WorA, "Str", "WinINet.dll" ) )
600 | MyErrors .= "`nThere was a problem loading WinINet.dll. 'LoadLibrary" WorA "' failed: Return value = " hModule ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
601 |
602 | ; Initialize WinINet. InternetOpen > http://msdn.microsoft.com/en-us/library/aa385096%28v=VS.85%29.aspx
603 | Else If !( hInternet := Internet_Open_Type != 3 ? DllCall( "WinINet\InternetOpen" WorA, Ptr, &Agent, "UInt", Internet_Open_Type, Ptr, 0, Ptr, 0, "UInt", 0 )
604 | : DllCall( "WinINet\InternetOpen" WorA, Ptr, &Agent, "UInt", 3, ptr, &proxy_url, Ptr, proxy_bypass = "" ? 0 : &proxy_bypass, "UInt", 0 ) )
605 | MyErrors .= "`nThere was a problem initializing WinINet. 'WinINet\InternetOpen" WorA "' failed: Return value = " hInternet ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
606 |
607 | ; Open a HTTP session. InternetConnect > http://msdn.microsoft.com/en-us/library/aa384363%28v=VS.85%29.aspx
608 | ; dwService -> INTERNET_SERVICE_HTTP = 3
609 | Else If !( hConnection := DllCall( "WinINet\InternetConnect" WorA, Ptr, hInternet, Ptr, &Host, "UInt", Port, Ptr, &User, Ptr, &Pass, "UInt", 3, "UInt", Internet_Flags, "UInt", 0 ) )
610 | MyErrors .= "`nThere was a problem opening a HTTP session. 'WinINet\InternetConnect" WorA "' failed: Return value = " hConnection ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
611 |
612 | ; Create a HTTP request. HttpOpenRequest > http://msdn.microsoft.com/en-us/library/aa384233%28v=VS.85%29.aspx
613 | Else If !( hRequest := DllCall( "WinINet\HttpOpenRequest" WorA, Ptr, hConnection, Ptr, &Method_Verb, Ptr, &URL, "Str", "HTTP/1.1", Ptr, 0, Ptr, &Accept_PtrArray, "UInt", Internet_Flags ) )
614 | MyErrors .= "`nThere was a problem creating a HTTP request. 'WinINet\HttpOpenRequest" WorA "' failed: Return value = " hRequest ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
615 |
616 | ; Add headers. HttpAddRequestHeaders > http://msdn.microsoft.com/en-us/library/aa384227%28v=VS.85%29.aspx
617 | ; dwModifiers = (HTTP_ADDREQ_FLAG_ADD = 0x20000000) + (HTTP_ADDREQ_FLAG_REPLACE = 0x80000000)
618 | Else If ( hbuffer != "" ) && !DllCall( "WinINet\HttpAddRequestHeaders" WorA, Ptr, hRequest, Ptr, &hbuffer, "UInt", StrLen( hbuffer ), "UInt", 0xA0000000 )
619 | MyErrors .= "`nThere was a problem adding one or more headers to the request. 'WinINet\HttpAddRequestHeaders" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError "`nHeaders: `n" hbuffer
620 |
621 | ; Update (12-28-2011): Added security flags support. Security flags may be added/removed like normal flags
622 | ; InternetQueryOption > http://msdn.microsoft.com/en-us/library/aa385101%28v=VS.85%29.aspx
623 | Else If ( Security_Flags_Add || Security_Flags_Nix ) && !DllCall( "WinINet\InternetQueryOption" WorA, Ptr, hRequest, "UInt", 31, "UInt*", Security_Flags, "UInt*", 4 )
624 | MyErrors .= "`nThere was a problem retrieving the security flags. 'WinINet\InternetQueryOption" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
625 |
626 | ; InternetSetOption > http://msdn.microsoft.com/en-us/library/aa385114%28v=VS.85%29.aspx
627 | Else If ( Security_Flags_Add || Security_Flags_Nix ) && !DllCall( "WinINet\InternetSetOption" WorA, Ptr, hRequest, "UInt", 31, "UInt*", pos := ( ~Security_Flags_Nix & Security_Flags ) | Security_Flags_Add, "UInt*", 4 )
628 | MyErrors .= "`nThere was a problem setting the security flags. 'WinINet\InternetSetOption" WorA "' failed: Flags value = " pos ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
629 |
630 | ; Step 8a: If there is no data to upload, submit the request via HttpSendRequest.
631 | ; HttpSendRequest > http://msdn.microsoft.com/en-us/library/aa384247%28v=VS.85%29.aspx
632 | Else If !( 0 < Content_Length ) && !DllCall( "WinINet\HttpSendRequest" WorA, Ptr, hRequest, Ptr, 0, "UInt", 0, Ptr, 0, "UInt", 0 )
633 | MyErrors .= "`nThere was a problem sending the " Method_Verb " request. 'WinINet\HttpSendRequest" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
634 |
635 | ; Step 8b: If there is data to upload, begin submitting the request via HttpSendRequestEx, upload the data
636 | ; using InternetWriteFile, then end the request with HttpEndRequest.
637 | ; HttpSendRequestEx > http://msdn.microsoft.com/en-us/library/aa384318%28v=VS.85%29.aspx
638 | Else If ( 0 < Content_Length ) && !DllCall( "WinINet\HttpSendRequestEx" WorA, Ptr, hRequest, Ptr, &INTERNET_BUFFERS, "UInt", 0, Ptr, 0, "UInt", 0 )
639 | MyErrors .= "`nThere was a problem sending the " Method_Verb " request. 'WinINet\HttpSendRequestEx" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
640 | Else If ( 0 < Content_Length )
641 | {
642 | ; Here, we have a connection open to a remote resource and we should write data to it.
643 | ; But first, notfy the callback function that we are about to upload data by passing '-1' to it.
644 | If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( -1, Content_Length, Do_Callback_3rdParam ) )
645 | MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. Zero bytes were uploaded."
646 | ; Then, if we're uploading from a file, open the file with GENERIC_READ permission (0x80000000)
647 | Else If ( Do_File_Upload ) && !( Do_File_Upload := DllCall( "CreateFile" WorA, Ptr, &Upload_File_Path, "UInt", 0x80000000, "UInt", 0, Ptr, 0, "UInt", 4, "UInt", 0, Ptr, 0 ) )
648 | MyErrors .= "`nThere was a problem opening the file to upload """ Upload_File_Path """. 'CreateFile" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
649 | Else
650 | {
651 | ; Loop until the size of the data uploaded is equal or greater than the Content-Length.
652 | ; Actually, 'equal to' is the end condition, the 'greater than' is just good programming.
653 | size := 0 ; 'size' tracks the number of bytes actually uploaded so far.
654 | Loop
655 | If ( Content_Length <= size )
656 | Break
657 | Else IfInString, MyErrors, `n
658 | Break
659 | Else
660 | {
661 | ; Define the first data chunk of up to 4096 bytes (put the address into 'pos')
662 | ; NOTE: except with multipart data, 'dbuffsz' and 'Content-Length' are equal.
663 | If ( size < Do_Multipart )
664 | {
665 | ; Upload the first part of the multipart envelope.
666 | pos := &rbuffer
667 | dtsz := Do_Multipart - size < 4096 ? Do_Multipart - size : 4096
668 | }
669 | Else If ( Do_Multipart + dbuffsz <= size )
670 | {
671 | ; Upload the second part of the multipart envelope.
672 | pos := &rbuffer + Do_Multipart
673 | dtsz := Content_Length - size < 4096 ? Content_Length - size : 4096
674 | }
675 | ; ReadFile > http://msdn.microsoft.com/en-us/library/aa365467%28v=VS.85%29.aspx
676 | Else If ( Do_File_Upload ) && !DllCall( "ReadFile", Ptr, Do_File_Upload, Ptr, pos := &dbuffer, "UInt", dbuffsz - size < 4096 ? dbuffsz - size : 4096, "Int*", dtsz, Ptr, 0 )
677 | {
678 | ; Upload from a file AND we couldn't read from the file
679 | MyErrors .= "`nThere was a problem reading from the file """ Upload_File_Path """. 'ReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
680 | Break
681 | }
682 | Else
683 | {
684 | ; Upload from memory
685 | pos := &dbuffer + size
686 | dtsz := dbuffsz - size < 4096 ? dbuffsz - size : 4096
687 | }
688 |
689 | ; Upload the chunk, and then increment 'size' by how many bytes were uploaded.
690 | ; InternetWriteFile > http://msdn.microsoft.com/en-us/library/aa385128%28v=VS.85%29.aspx
691 | If !DllCall( "WinINet\InternetWriteFile", Ptr, hRequest, Ptr, pos, "UInt", dtsz + 0, "Int*", dtsz )
692 | MyErrors .= "`nThere was a problem uploading the POST data. 'WinINet\InternetWriteFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
693 | Else
694 | {
695 | size += dtsz
696 |
697 | ; If we have a callback function, tell it what percent has been uploaded
698 | If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( size / Content_Length - 1, Content_Length, Do_Callback_3rdParam ) )
699 | MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. " size " bytes were uploaded."
700 | }
701 | }
702 | ; Close the file handle (if the data was uploaded from a file).
703 | ; CloseHandle > http://msdn.microsoft.com/en-us/library/ms724211%28v=vs.85%29.aspx
704 | If ( Do_File_Upload ) && !DllCall( "CloseHandle", Ptr, Do_File_Upload )
705 | MyErrors .= "`nThere was a problem closing the file """ Upload_File_Path """. 'CloseHandle' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
706 | }
707 | ; We're done uploading data, so end the request.
708 | ; HttpEndRequest > http://msdn.microsoft.com/en-us/library/aa384230%28v=VS.85%29.aspx
709 | DllCall( "WinINet\HttpEndRequest" WorA, Ptr, hRequest, Ptr, 0, "UInt", 0, Ptr, 0 )
710 | }
711 |
712 | ; Step 9: Wait until data is available, then get the response headers.
713 | Content_Length := size := rbuffsz := 0
714 | If InStr( MyErrors, "`n" )
715 | hbuffer := ""
716 | Else
717 | {
718 | ; InternetQueryDataAvailable > http://msdn.microsoft.com/en-us/library/aa385100%28v=VS.85%29.aspx
719 | DllCall( "WinINet\InternetQueryDataAvailable", Ptr, hRequest, "Int*", Content_Length, "UInt", 0, Ptr, 0 )
720 |
721 | ; Get the response headers separated by CRLF. The first line has the HTTP response code
722 | ; HttpQueryInfo > http://msdn.microsoft.com/en-us/library/aa384238%28v=VS.85%29.aspx
723 | ; HTTP_QUERY_RAW_HEADERS_CRLF = 22. First-try buffer size = 4K
724 | If VarSetCapacity( hbuffer, hbuffsz := 4096, 0 )
725 | && !DllCall( "WinINet\HttpQueryInfo" WorA, Ptr, hRequest, "UInt", 22, Ptr, &hbuffer, "Int*", hbuffsz, Ptr, 0 )
726 | && VarSetCapacity( hbuffer, hbuffsz, 0 )
727 | && !DllCall( "WinINet\HttpQueryInfo" WorA, Ptr, hRequest, "UInt", 22, Ptr, &hbuffer, "Int*", hbuffsz, Ptr, 0 )
728 | MyErrors .= "`nThere was a problem reading the response headers. 'WinINet\HttpQueryInfo" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
729 | Else
730 | {
731 | ; We've got the response headers, but don't copy them to the output var yet.
732 | ; Replace CRLF with LF, get the response code, and see if there's a Content-Length.
733 | VarSetCapacity( hbuffer, -1 )
734 | StringReplace, hbuffer, hbuffer, `r`n, `n, A
735 | StringMid, Response_Code, hbuffer, InStr( hbuffer, " " ) + 1, 3
736 | If ( 17 != pos := 17 + InStr( hbuffer, "`nContent-Length: " ) )
737 | StringMid, Content_Length, hbuffer, pos, InStr( hbuffer, "`n", 0, pos ) - pos
738 | }
739 | }
740 |
741 | ; Step 10: Download the response data
742 | If ( Content_Length ) && !InStr( MyErrors, "`n" )
743 | {
744 | ; If we're downloading to a file, try to open the target file with GENERIC_WRITE (0x40000000) permission.
745 | ; CreateFile > http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx
746 | If ( Do_Download_To_File ) && !( Do_Download_To_File := DllCall( "CreateFile" WorA, Ptr, &output_file_path, "UInt", 0x40000000, "UInt", 0, Ptr, 0, "UInt", 4, "UInt", 0, Ptr, 0 ) )
747 | MyErrors .= "`nThere was a problem opening/creating the output file for writing data: """ output_file_path """. 'CreateFile" WorA "' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
748 | ; Then, if we're resuming a download, move the write-pointer to the end of the file.
749 | ; SetFilePointerEx > http://msdn.microsoft.com/en-us/library/aa365542%28v=VS.85%29.aspx
750 | Else If ( Do_Download_Resume ) && !DllCall( "SetFilePointerEx", Ptr, Do_Download_To_File, "Int64", Do_Download_Resume, Ptr, 0, "UInt", 0 )
751 | MyErrors .= "`nThere was a problem seeking to the end of the output file for resuming the download. 'SetFilePointerEx' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
752 | ; If we have a callback function, inform it that we're about to begin downloading data.
753 | Else If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( Do_Download_Resume, Content_Length + Do_Download_Resume, Do_Callback_3rdParam ) )
754 | MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. Zero bytes were downloaded."
755 | Else
756 | {
757 | ; Download the response data. Initialize the d-buffer to hold the reported content length plus 4K
758 | VarSetCapacity( dbuffer, dbuffsz := Do_Download_To_File ? 4096 : 4096 + Content_Length, 0 )
759 | Loop
760 | IfInString, MyErrors, `n
761 | Break
762 | Else
763 | {
764 | ; Update (1-8-2012): the data downloading loop no longer uses dynamic variables. Instead, if the d-buffer is
765 | ; too small, make space in the r-buffer to hold 4K plus the data in the d-buffer and download to the end of the
766 | ; r-buffer. If data was downloaded, copy the data from the d-buffer to the r-buffer, expand the d-buffer, and
767 | ; copy all of the data (old + new) back to the d-buffer. If ever InternetReadFile fails, or downloads zero
768 | ; bytes, that means we're done.
769 |
770 | If ( Do_Download_To_File )
771 | pos := &dbuffer
772 | Else If ( size + 4096 < Content_Length )
773 | pos := &dbuffer + size
774 | Else
775 | {
776 | VarSetCapacity( rbuffer, rbuffsz := size + 4096 + 1, 0 )
777 | pos := &rbuffer + size
778 | }
779 |
780 | ; Now that the target buffer has been determined, download the next chunk.
781 | ; InternetReadFile > http://msdn.microsoft.com/en-us/library/aa385103%28v=VS.85%29.aspx
782 | If !DllCall( "WinINet\InternetReadFile", Ptr, hRequest, Ptr, pos, "UInt", 4096, "Int*", dtsz )
783 | MyErrors .= "`nThere was a problem downoading data. 'WinINet\InternetReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
784 | Else If !dtsz
785 | {
786 | If ( Do_Callback )
787 | %Do_Callback_Func%( 1, Content_Length + Do_Download_Resume, Do_Callback_3rdParam )
788 | Break
789 | }
790 | ; WriteFile > http://msdn.microsoft.com/en-us/library/aa365747%28v=vs.85%29.aspx
791 | Else If ( Do_Download_To_File ) && !DllCall( "WriteFile", Ptr, Do_Download_To_File, Ptr, pos, "UInt", dtsz, "Int*", 0, Ptr, 0 )
792 | MyErrors .= "`nThere was a problem writing data to the disk. 'WriteFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
793 | Else If !( Do_Download_To_File ) && ( size < rbuffsz )
794 | {
795 | DllCall( "RtlMoveMemory", Ptr, &rbuffer, Ptr, &dbuffer, "Int", size )
796 | VarSetCapacity( dbuffer, Content_Length := 4096 + ( size += dtsz ), 0 )
797 | DllCall( "RtlMoveMemory", Ptr, &dbuffer, Ptr, &rbuffer, "Int", size )
798 | rbuffsz := 0
799 | }
800 | Else size += dtsz
801 |
802 | If ( Do_Callback ) && ( "CANCEL" = %Do_Callback_Func%( ( size + Do_Download_Resume ) / ( Content_Length + Do_Download_Resume ), Content_Length + Do_Download_Resume, Do_Callback_3rdParam ) )
803 | MyErrors .= "`nThe callback function: """ Do_Callback_Func """ returned 'CANCEL' to cancel the transaction. " size " bytes were uploaded."
804 | }
805 | If ( Do_Download_To_File )
806 | {
807 | If ( Do_Legacy_Dual_Output )
808 | {
809 | VarSetCapacity( dbuffer, size + 1, 0 )
810 | If !DllCall( "ReadFile", Ptr, Do_Download_To_File, Ptr, &dbuffer, "UInt", size, Ptr, 0, Ptr, 0 )
811 | MyErrors .= "`nThere was a problem reading the file """ output_file_path """. 'ReadFile' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
812 |
813 | }
814 | If !DllCall( "CloseHandle", Ptr, Do_Download_To_File )
815 | MyErrors .= "`nThere was a problem closing the file """ output_file_path """. 'CloseHandle' failed: ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
816 | }
817 | }
818 | }
819 |
820 | ; Step 11: Close handles, free the dll, and add the MD5 hash check if called for.
821 | ; InternetCloseHandle > http://msdn.microsoft.com/en-us/library/aa384350%28v=VS.85%29.aspx
822 | DllCall( "WinINet\InternetCloseHandle", Ptr, hRequest )
823 | DllCall( "WinINet\InternetCloseHandle", Ptr, hConnection )
824 | DllCall( "WinINet\InternetCloseHandle", Ptr, hInternet )
825 | DllCall( "FreeLibrary", Ptr, hModule )
826 |
827 | If ( Do_Dn_MD5_Hash ) && InStr( hbuffer, "`nContent-MD5: " )
828 | If ( Do_Download_To_File )
829 | hbuffer .= "`nComputed-MD5: " HTTPRequest_MD5( rbuffer, output_file_path )
830 | Else hbuffer .= "`nComputed-MD5: " HTTPRequest_MD5( dbuffer, size )
831 |
832 | ; Step 12: Copy the response data and headers into the output buffers, respecting the pertinent options.
833 | If ( size ) && ( !( Do_Download_To_File ) || ( Do_Legacy_Dual_Output ) )
834 | {
835 | ; First, detect the content type to see whether we CAN treat it like text.
836 | If ( 15 != pos := 15 + InStr( hbuffer, "`nContent-Type: " ) )
837 | StringMid, Content_Type, hbuffer, pos, InStr( hbuffer "`n", "`n", 0, pos ) - pos
838 | Else Content_Type := "text/plain; charset=" MyCharset
839 |
840 | ; Extract the charset information, if it's present
841 | If ( 7 != pos := 7 + InStr( Content_Type, "charset=" ) )
842 | && ( pos := InStr( Codepage_Charsets, SubStr( Content_Type, pos
843 | , InStr( Content_Type ";" , ";", 0, pos ) - pos ) "|" ) )
844 | StringMid, Convert_POST_To_Codepage, Codepage_Charsets, pos - 5, 5
845 | Else Convert_POST_To_Codepage := IsUnicode ? "65001" : MyACP
846 |
847 | ; Then, determine whether we should convert the data to a different codepage or not.
848 | StringLeft, Content_Type, Content_Type, InStr( Content_Type ";", ";" ) - 1
849 | If !( pos := InStr( Content_Type, "text/" ) = 1 )
850 | Loop, Parse, Text_Content_Subtypes, /
851 | If ( pos |= 0 < InStr( Content_Type, "/" A_LoopField ) )
852 | Break
853 |
854 | ; So, now we know whether or not to treat the data as text, or as binary
855 | If ( Do_Binary_Down ) || !( pos ) || ( Convert_POST_To_Codepage = MyACP )
856 | {
857 | VarSetCapacity( In_POST__Out_Data, size + 2, 0 )
858 | DllCall( "RtlMoveMemory", Ptr, &In_POST__Out_Data, Ptr, &dbuffer, "Int", size )
859 | If ( pos )
860 | VarSetCapacity( In_POST__Out_Data, -1 )
861 | }
862 | Else
863 | {
864 | ; convert the text data's codepage to whatever codepage the script is using.
865 | If ( Convert_POST_To_Codepage = "01200" )
866 | {
867 | ; the downloaded data is in UTF-16 already (I don't know if this ever happens IRL).
868 | pos := &dbuffer
869 | rbuffsz := size >> 1
870 | }
871 | Else If ( 0 < rbuffsz := DllCall( "MultiByteToWideChar", "UInt", Convert_POST_To_Codepage, "UInt", 0, Ptr, &dbuffer, "Int", size, Ptr, 0, "Int", 0 ) )
872 | {
873 | VarSetCapacity( rbuffer, rbuffsz + 1 << 1 )
874 | DllCall( "MultiByteToWideChar", "UInt", Convert_POST_To_Codepage, "UInt", 0, Ptr, &dbuffer, "Int", size, Ptr, pos := &rbuffer, "Int", rbuffsz )
875 | }
876 | Else MyErrors .= "`nThere was a problem converting codepage " Convert_POST_To_Codepage " to " MyACP ". 'MultiByteToWideChar' failed: Return value = " rbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
877 |
878 | If ( IsUnicode )
879 | {
880 | VarSetCapacity( In_POST__Out_Data, rbuffsz + 1 << 1, 0 )
881 | DllCall( "RtlMoveMemory", Ptr, &In_POST__Out_Data, Ptr, &rbuffer, "Int", rbuffsz << 1 )
882 | VarSetCapacity( In_POST__Out_Data, -1 )
883 | }
884 | Else If ( 0 < rbuffsz ) && ( 0 < dbuffsz := DllCall( "WideCharToMultiByte", "UInt", MyACP, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, 0, "Int", 0, Ptr, 0, Ptr, 0 ) )
885 | {
886 | VarSetCapacity( In_POST__Out_Data, dbuffsz + 1, 0 )
887 | DllCall( "WideCharToMultiByte", "UInt", MyACP, "UInt", 0, Ptr, pos, "Int", rbuffsz, Ptr, &In_POST__Out_Data, "Int", dbuffsz, Ptr, 0, Ptr, 0 )
888 | size := dbuffsz
889 | VarSetCapacity( In_POST__Out_Data, -1 )
890 | }
891 | Else MyErrors .= "`nThere was a problem converting codepage " Convert_POST_To_Codepage " to " MyACP ". 'WideCharToMultiByte' failed: Return value = " dbuffsz ", ErrorLevel = " ErrorLevel ", A_LastError = " A_LastError
892 | }
893 | }
894 | ; If there was no data downloaded, AND there were no errors so far, clear the data output var.
895 | Else
896 | In_POST__Out_Data := ""
897 |
898 | In_Out_HEADERS := SubStr( hbuffer, 1, -1 ) . SubStr( MyErrors, 1 + ( hbuffer = "" ) )
899 | Return size, dbuffer := "", hbuffer := "", rbuffer := "", ErrorLevel := Response_Code
900 | } ; HTTPRequest( URL, byref In_POST__Out_Data="", byref In_Out_HEADERS="", Options="" ) -----------------------
901 |
902 |
903 | HTTPRequest_MD5( byref data, length=-1 ) { ; ------------------------------------------------------------------
904 | ; Computes the MD5 hash of a data blob of length 'length'. If 'length' is less than zero, this function assumes
905 | ; that 'data' is a null-terminated string and determines the length automatically. If length is the path to a
906 | ; file, this function returns the Static variables and constants r[0~63], encoded here as bytes with an offset
907 | ; of 64 ( that means the real value is the byte value minus 64, e.g: r[0] = 7, so 7 + 64 = 71 = 'G' )
908 | Static s, k, pty, u, p:=0, r := "GLQVGLQVGLQVGLQVEINTEINTEINTEINTDKPWDKPWDKPWDKPWFJOUFJOUFJOUFJOU"
909 | ; Initialize the block buffer S and constants p and k[0~63]
910 | If !( p )
911 | {
912 | VarSetCapacity( k, 256 )
913 | VarSetCapacity( S, 64, 0 )
914 | u := !!A_IsUnicode
915 | pty := A_PtrSize = "" ? "UInt" : "Ptr"
916 | Loop, 64
917 | NumPut( i := Floor(Abs(Sin(A_Index)) * 0x100000000 ), k, A_Index - 1 << 2, "UInt" )
918 | }
919 |
920 | If length IS NOT NUMBER
921 | IfExist, % length ; use file-MD5 mode.
922 | {
923 | hFile := DllCall( "CreateFile" ( u ? "W" : "A" ), "Str", length
924 | , "UInt", 0x80000000 ; GENERIC_READ = 0x80000000
925 | , "UInt", 0, pty, 0
926 | , "UInt", 4 ; OPEN_ALWAYS = 4
927 | , "UInt", 0, pty, 0 )
928 | VarSetCapacity( l, 8 )
929 | DllCall( "GetFileSizeEx", pty, hFile, pty, &l )
930 | length := NumGet( l, 0, "Int64" )
931 | }
932 |
933 | ; autodetect message length if it's not specified (or is not positive)
934 | If Round( length ) < 1
935 | length := StrLen( dat ) << u
936 |
937 | ; initialize running accumulators
938 | ha := 0x67452301, hb := 0xEFCDAB89, hc := 0x98BADCFE, hd := 0x10325476
939 |
940 | ; Begin rolling the message. This loop does 1 iteration for each 64 byte block such that the
941 | ; last block has fewer than 55 bytes in it ( to leave room for the terminator and data length )
942 | Loop % length + 72 >> 6
943 | {
944 | If ( f := length - 64 > ( e := A_Index - 1 << 6 ) ? 64 : length > e ? length - e : 0 )
945 | If ( hFile )
946 | DllCall( "ReadFile", pty, hFile, pty, &s, "UInt", f, pty, &l, pty, 0 )
947 | Else DllCall( "RtlMoveMemory", pty, &s, pty, &data + e, "UInt", f ) ; copy the block
948 | If ( f != 64 && e <= length ) ; append the terminator to the message
949 | NumPut( 128, s, f, "UChar" )
950 | If ( f < 56 )
951 | Loop 8 ; if this is the real last block, insert the data length in BITS
952 | NumPut( ( ( length << 3 ) >> ( A_Index - 1 << 3 ) ) & 255, s, 55 + A_Index, "UChar" )
953 |
954 | a := ha, b := hb, c := hc, d := hd ; copy running accumulators to intermediate variables
955 |
956 | Loop 64 ; begin rolling the block. These operations have been condensed and obfuscated.
957 | {
958 | e := NumGet( r, ( i := A_Index - 1 ) << u, "UChar" ) & 31
959 | f := 0 = ( j := i >> 4 ) ? (b&c)|(~b&d) : j=1 ? (d&b)|(~d&c) : j=2 ? b^c^d : c^(~d|b)
960 | g := &s + (( i * ( 3817 >> j * 3 & 7 ) + ( 328 >> j * 3 & 7 ) & 15 ) << 2 )
961 | w := (*(g+3) << 24 | *(g+2) << 16 | *(g+1) << 8 | *g) + a + f + NumGet(k,i<<2,"UInt")
962 | a := d, d := c, c := b, b += w << e | (( w & 0xFFFFFFFF ) >> ( 32 - e ))
963 |
964 | }
965 | ; add the intermediate variables to the running accumlators (making sure to mod by 2**32)
966 | ha := ha+a&0xFFFFFFFF, hb := hb+b&0xFFFFFFFF, hc := hc+c&0xFFFFFFFF, hd := hd+d&0xFFFFFFFF
967 | VarSetCapacity( S, 64, 0 ) ; zero the block
968 | }
969 | If ( hFile )
970 | DllCall( "CloseHandle", pty, hFile )
971 | Loop 32 ; convert the running accumulators into 32 hex digits
972 | g:=1&(i:=A_Index-1), e:=Chr(97+(i>>3))
973 | , f:=15&(h%e%>>((!g-g+i&7)<<2)), s.=Chr(48+f+39*(9>6*(4-A_Index))&63, s.=i=63 ? "/" : i=62 ? "+" : Chr(i<26 ? i+65 : i<52 ? i+71 : i-4)
978 | Return SubStr( s, 37, 22 ) "==" ; return the base 64 encoded MD5 hash.
979 | } ; HTTPRequest_MD5( byref data, length=-1 ) ------------------------------------------------------------------
980 |
--------------------------------------------------------------------------------
/lib/klist.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | Function: kList
3 | Creates a list of autohotkey compatible key names ready to be parsed.
4 |
5 | This function will generate a delimited list of key names that can be used in autohotkey commands
6 | like "hotkey" or "getkeystate" or even for more general purposes like creating a list of keys that will be
7 | shown on a combobox.
8 |
9 |
10 | Parameters:
11 | kList([inc, exc, sep])
12 |
13 | inc - Allows you to include specific keys, ascii characters or mouse keys to the list.
14 | Although this option is for you to specify your own key/range you can make use
15 | of some predefine keywords to add common ranges of keys:
16 |
17 | + *all*: Adds all ascii characters, punctuation, numbers, keyboard and mouse keys. *
18 | + *alphanum*: Adds alphabetic and numeric characters and excludes punctuation signs. *
19 | + *lower*: Adds all alphabetic characters in lowercase.
20 | + *upper*: Adds all alphabetic characters in uppercase.
21 | + *num*: Adds only numeric characters.
22 | + *punct*: Adds only punctuation and math operator signs.
23 | + --------------------------------------------------------------
24 | + *msb*: Includes mouse buttons.
25 | + *mods*: Includes modifier keys. *
26 | + *fkeys*: Includes all the F keys.
27 | + *npad*: Controls the addition of numpad keys and NumLuck.
28 | + *kbd*: For all the other keys like *Enter*, *Space*, *Backspace* and such.
29 | + You can exclude one or more ranges of numbers and letters using the "1-5" or "b-h" format.
30 | Ranges should always be positive. "5-1" or "h-b" are not valid.
31 |
32 | Note :
33 | + The option "mods" will only return a short version of the modifiers.
34 | If you want the more detailed one use a caret "^" right next to it. Ex. "mods^" would bring the long list
35 | of modifiers.
36 |
37 | + When using the options "all" and "alphanum" kList will assume that you want only
38 | lowercase.
39 |
40 | Adding a "^" to those parameters would force the function to return uppercase characters.
41 | ex.: "alphanum" will return 0-9 and lowercase alpha chars unless you specify
42 | "alphanum^".
43 |
44 | exc - Allows you to exclude specific keys, ascii characters or mouse keys from the list.
45 | This parameter goes in the same tone of the above so everything
46 | works similar.
47 |
48 | + *alphanum*: Excludes alphabetic and numeric characters.
49 | + *lower*: Excludes all alphabetic characters in lowercase.
50 | + *upper*: Excludes all alphabetic characters in uppercase.
51 | + *num*: Excludes numeric characters.
52 | + *punct*: Excludes punctuation and math operator signs.
53 | + --------------------------------------------------------------
54 | + *msb*: Excludes mouse buttons.
55 | + *mods*: Excludes modifier keys.
56 | + *fkeys*: Excludes all the F keys.
57 | + *npad*: Excludes numpad keys and NumLuck.
58 | + *kbd*: Excludes all the other keys like *Enter*, *Space*, *Backspace* and such.
59 | + You can exclude one or more ranges of numbers and letters using the "1-5" or "b-h" format.
60 | Ranges should always be positive. "5-1" or "h-b" are not valid.
61 |
62 | sep - Allows you to specify a custom separator delimiter for the lists.
63 | Note that the separator itself is not going to be added to the list, so specifying "+" as a
64 | delimiter will cause it to be absent from the list.
65 |
66 | Returns:
67 | kList - List of ascii keys, mouse and keyboard keys and punctuation signs separated by spaces.
68 | False - When you try to input more than 1 character on the separator parameter.
69 |
70 | Examples:
71 |
72 | */
73 | kList(inc="all", exc="", sep=" "){
74 | Static lPunct,$reRF,vAll,vLower,vUpper,vNum,vAlnum,vPunct,msb,mods,fkeys,npad,kbd,nil=
75 |
76 | if strLen(sep) > 1
77 | return False ; You can only specify 1 character as the separator
78 |
79 | ; List of keyboard and mouse names as defined in "List of Keys, Mouse Buttons, and Joystick Controls".
80 | vNum :="0 1 2 3 4 5 6 7 8 9 "
81 | vLower:="a b c d e f g h i j k l m n o p q r s t u v w x y z "
82 | vUpper:="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
83 | vAlnum:= vNum (RegexMatch(inc, "(all|alphanum)\^") ? vUpper : vLower)
84 | vPunct:="! "" # $ % & ' ( ) * + , - . / : `; < = > ? @ [ \ ] ^ `` { | } ~ "
85 | msb :="LButton RButton MButton WheelDown WheelUp "
86 | mods :="AppsKey LWin RWin LControl RControl LShift RShift LAlt RAlt Control Alt Shift "
87 | fkeys :="F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 "
88 | npad :="NumLock Numpad0 Numpad1 Numpad2 Numpad3 Numpad4 Numpad5 Numpad6 Numpad7 Numpad8 "
89 | . "Numpad9 NumpadIns NumpadEnd NumpadDown NumpadPgDn NumpadLeft NumpadClear NumpadRight NumpadHome "
90 | . "NumpadUp NumpadPgUp NumpadDot NumpadDel NumpadDiv NumpadMult NumpadAdd NumpadSub NumpadEnter "
91 | kbd :="Space Tab Enter Escape Backspace Delete Insert Home End PgUp PgDn Up Down Left Right "
92 | . "ScrollLock CapsLock PrintScreen CtrlBreak Pause Break Help Sleep "
93 | vAll := RegexReplace(RegexReplace(vPunct vAlnum msb mods fkeys npad kbd , "\s", sep),"\" sep "$")
94 | kwords:= "lower|upper|num|punct|alphanum|msb|mods|fkeys|npad|kbd"
95 | $reRF :="(\s?)+(?P[a-zA-Z0-9])-(?P[a-zA-Z0-9])(\s?)+"
96 | lPunct:=",,,!,"",#,$,%,&,',(,),*,+,-,.,/,:,;,<,=,>,?,@,[,\,],^,``,{,|,},~" ; as a list for the if [in] command
97 |
98 | if (inStr(inc, "all") && !exc)
99 | return vAll
100 |
101 | While(RegexMatch(exc, kwords, match)){
102 | exc := RegexReplace(exc, "\b" match "\b(\s?)+"
103 | , match = "alphanum" ? vAlnum : nil
104 | . match = "lower" ? vLower : nil
105 | . match = "upper" ? vUpper : nil
106 | . match = "num" ? vNum : nil
107 | . match = "punct" ? vPunct : nil
108 | . match = "msb" ? msb : nil
109 | . match = "mods" ? mods : nil
110 | . match = "fkeys" ? fkeys : nil
111 | . match = "npad" ? npad : nil
112 | . match = "kbd" ? kbd : nil)
113 | }
114 |
115 | ; Advanced including options.
116 | ; This little loop allows excluding ranges like "1-5" or "a-d".
117 | ; The rage should always be positive i. e. ranges like "6-1" or "h-b" are not allowed.
118 | While(Regexmatch(inc, $reRF, r)){
119 | Loop % asc(rEnd) - asc(rStart) + 1 ; the + 1 is to include the last character in range.
120 | lst .= chr(a_index + asc(rStart) - 1) a_space
121 |
122 | inc := RegexReplace(inc, $reRF, "", "", 1)
123 | }
124 |
125 | ; This will include user specified keys and will replace keywords by their respective lists.
126 | lst .= inc a_space
127 | . (inStr(inc,"all") ? vPunct vAlnum msb mods fkeys npad kbd : nil)
128 | . (inStr(inc,"alphanum") && !inStr(exc, "alphanum") ? vAlnum : nil)
129 | . (inStr(inc, "lower") && !inStr(inc,"alphanum") && !inStr(exc, "lower") ? vLower : nil)
130 | . (inStr(inc, "upper") && !inStr(inc,"alphanum") && !inStr(exc, "upper") ? vUpper : nil)
131 | . (RegexMatch(inc,"\bnum\b") && !RegexMatch(exc,"\bnum\b") ? vNum : nil)
132 | . (inStr(inc, "punct") && !inStr(exc, "punct") ? vPunct : nil)
133 | . (inStr(inc, "msb") && !inStr(exc, "msb") ? msb : nil)
134 | . (inStr(inc, "fkeys") && !inStr(exc, "fkeys") ? fkeys : nil)
135 | . (inStr(inc, "npad") && !inStr(exc, "npad") ? npad : nil)
136 | . (inStr(inc,"kbd") && !inStr(exc,"kbd") ? kbd : nil)
137 | . (inStr(inc,"mods^") && !inStr(exc,"mods") ? mods : inStr(inc,"mods") && !inStr(exc,"mods") ? nil
138 | . RegexReplace(mods, "(AppsKey|LControl|RControl|LShift|RShift|LAlt|RAlt)(\s?)+") : nil)
139 |
140 | ; Advanced excluding options.
141 | ; This little loop allows excluding ranges like "1-5" or "a-d".
142 | ; The rage should always be positive i. e. ranges like "6-1" or "h-b" are not allowed.
143 | While(Regexmatch(exc, $reRF, r)){
144 | Loop % asc(rEnd) - asc(rStart) + 1 ; the + 1 is to include the last character in range.
145 | StringReplace,lst,lst,% chr(a_index + asc(rStart) - 1) a_space
146 |
147 | exc := RegexReplace(exc, $reRF, "", "", 1)
148 | }
149 |
150 | ; Remove excluded keys from list.
151 | Loop, Parse, exc, %a_space%
152 | {
153 | ; needed Regex to avoid deleting "NumpadEnter" when trying to delete "Enter" and such.
154 | if strLen(a_loopfield) > 1
155 | lst := RegexReplace(lst, "i)\b" a_loopfield "\b\s?")
156 | else if a_loopfield in %lPunct%
157 | lst := a_loopfield ? RegexReplace(lst, "\" a_loopfield "\s?") : lst
158 | else if (a_loopfield != "")
159 | lst := RegexReplace(lst, "\b" a_loopfield "\b\s?")
160 | }
161 |
162 | ; Cleaning.
163 | lst := RegexReplace(lst,"(\s?)+[a-zA-Z0-9]-[a-zA-Z0-9](\s?)+") ; remove ranges from include.
164 | lst := RegexReplace(lst,"i)(all\^?|lower|upper|\bnum\b|alphanum\^?|punct|msb|mods\^?|fkeys|npad|kbd)(\s?)+")
165 | return RegexReplace(RegexReplace(lst, "\s", sep), "\" sep "$")
166 | } ; Function End.
167 |
--------------------------------------------------------------------------------
/lib/normalizephone.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | function: normalizePhone
3 |
4 | description:
5 |
6 | returns:
7 | Properly formatted phone
8 |
9 | @Modification Date: July 29, 2019
10 | */
11 |
12 | normalizePhone(phone){
13 |
14 | if (regexmatch(phone, "\+?.?(809||829||849)")) {
15 | regexmatch(phone, "(\+?\d{1})?[\s.-]?\(?(\d{3})?\)?[\s.-]?(\d{3})[\s-.]?(\d{4})", match)
16 | format := "+1 (" match2 ")-" match3 "-" match4
17 | res := strlen(match4) > 4 ? "+" regexreplace(phone, "\D", "") : format
18 | } else
19 | res := "+1" regexreplace(phone, "\D", "")
20 |
21 | if (strlen(res) < 10) {
22 |
23 | msgbox % "The provided phone number is probably missing some digits.\n Only basic formatting performed."
24 | res := regexreplace(phone, "\D", "")
25 | }
26 |
27 | return res
28 | }
29 |
--------------------------------------------------------------------------------
/lib/normalizetext.ahk:
--------------------------------------------------------------------------------
1 | #Requires Autohotkey v1.1.33+ 32-Bit
2 | /*
3 | function: normalizeText
4 |
5 | description:
6 | This function strips text from unwanted characters and returns a properly formatted Text and
7 | provides some specific dominican address fixes.
8 |
9 | The normalization process is done in steps.
10 | This is to make sure everything that is not needed is removed completely
11 | because if we try to remove all in one step it will have troubles with
12 | text that has mixed removable characters.
13 |
14 | returns:
15 | Clean and title cased text.
16 |
17 | @Modification Date: July 29, 2019
18 | */
19 | normalizeText(value){
20 |
21 | /*
22 | remove accented characters
23 | */
24 | accnt := { "á" : "a"
25 | , "é" : "e"
26 | , "í" : "i"
27 | , "ó" : "o"
28 | , "ú" : "u"
29 | , "Á" : "A"
30 | , "É" : "E"
31 | , "Í" : "I"
32 | , "Ó" : "O"
33 | , "Ú" : "U"}
34 |
35 | for k,v in accnt
36 | if (instr(value, k))
37 | value := RegexReplace(value, k, v)
38 |
39 | /*
40 | remove period at the end because this is not a sentence
41 | */
42 | value := regexreplace(value, "\.$")
43 |
44 | /*
45 | trim leading/trailing spaces
46 | */
47 | value := regexreplace(value, "^\s+|\s+$")
48 |
49 | /*
50 | convert multiple spaces in to single spaces
51 | */
52 | value := regexreplace(value, "\s+", a_space)
53 |
54 | /*
55 | clean address abbreviations
56 | */
57 | value := regexreplace(value, "i)Esquina", "Esq.")
58 | value := regexreplace(value, "i)(C(\/|\\)|\b(Cll\.?)\b)\s?", "Calle ")
59 | value := regexreplace(value, "i)(\bNo\.?\b|Numero)\s?(\d+)", "#$2")
60 | value := regexreplace(value, "i)\bPiso\b", "Nivel")
61 | value := regexreplace(value, "i)residencial\s", "Res. ")
62 | value := regexreplace(value, "i)Ensanche\s", "Ens. ")
63 | value := regexreplace(value, "i)\b(Edificio|Edif\.?)\b", "Edf. ")
64 | value := regexreplace(value, "i)(\bav\.\b|avenida|\bave\.\b)\s?", "Av. ")
65 | value := regexreplace(value, "i)av\s", "Av. ")
66 | value := regexreplace(value, "i)(Apartamento|\bapto\.?\b|\bapart\.?\b)", "Apt. ")
67 | value := regexreplace(value, "i)(distrito nacional|sto\.?\s?dgo\.?|(\bd\.?\s?n\.?\b|\bs\.?\s?d\.?\b)\W)", "Santo Domingo")
68 |
69 | /*
70 | remove special non meaningful and non printable characters
71 | */
72 | value := regexreplace(value, "[^a-zA-Z0-9ñÑ\-\s\.\'\#]")
73 |
74 |
75 | /*
76 | convert to proper case
77 | */
78 | value := format("{1:T}", value)
79 | value := regexreplace(value, "i)\b(i{1,3})\b", "$U1")
80 | value := regexreplace(value, "i)\b(de la|de los|del|de|y|a)\b", "$L1")
81 |
82 | return value
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/lib/sc.ahk:
--------------------------------------------------------------------------------
1 | /*
2 | CaptureScreen(aRect, sFileTo, bCursor, nQuality)
3 | 1) If the optional parameter bCursor is True, captures the cursor too.
4 | 2) If the optional parameter sFileTo is 0, set the image to Clipboard.
5 | If it is omitted or "", saves to screen.bmp in the script folder,
6 | otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF.
7 | 3) The optional parameter nQuality is applicable only when sFileTo is JPG. Set it to the desired quality level of the resulting JPG, an integer between 0 - 100.
8 | 4) If aRect is 0/1/2/3, captures the entire desktop/active window/active client area/active monitor.
9 | 5) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed".
10 | In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed.
11 |
12 | Example:
13 | CaptureScreen(0)
14 | CaptureScreen(1)
15 | CaptureScreen(2)
16 | CaptureScreen(3)
17 | CaptureScreen("100, 100, 200, 200")
18 | CaptureScreen("100, 100, 200, 200, 400, 400") ; Zoomed
19 | */
20 |
21 | /*
22 | Convert(sFileFr, sFileTo, nQuality)
23 | Convert("C:\image.bmp", "C:\image.jpg")
24 | Convert("C:\image.bmp", "C:\image.jpg", 95)
25 | Convert(0, "C:\clip.png") ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0.
26 | */
27 |
28 | CaptureScreen(aRect = 0, sFile = "", bCursor = false, nQuality = "")
29 | {
30 | If (!aRect)
31 | {
32 | SysGet, nL, 76
33 | SysGet, nT, 77
34 | SysGet, nW, 78
35 | SysGet, nH, 79
36 | }
37 | Else If (aRect = 1)
38 | WinGetPos, nL, nT, nW, nH, A
39 | Else If (aRect = 2)
40 | {
41 | WinGet, hWnd, ID, A
42 | VarSetCapacity(rt, 16, 0)
43 | DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
44 | DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt)
45 | nL := NumGet(rt, 0, "int")
46 | nT := NumGet(rt, 4, "int")
47 | nW := NumGet(rt, 8)
48 | nH := NumGet(rt,12)
49 | }
50 | Else If (aRect = 3)
51 | {
52 | VarSetCapacity(mi, 40, 0)
53 | DllCall("GetCursorPos", "int64P", pt)
54 | DllCall("GetMonitorInfo", "Uint", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2), "Uint", NumPut(40,mi)-4)
55 | nL := NumGet(mi, 4, "int")
56 | nT := NumGet(mi, 8, "int")
57 | nW := NumGet(mi,12, "int") - nL
58 | nH := NumGet(mi,16, "int") - nT
59 | }
60 | Else If (isObject(aRect))
61 | {
62 | nL := aRect.Left, nT := aRect.Top, nW := aRect.Right - aRect.Left, nH := aRect.Bottom - aRect.Top
63 | znW := aRect.ZoomW, znH := aRect.ZoomH
64 | }
65 | Else
66 | {
67 | StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
68 | nL := rt1, nT := rt2, nW := rt3 - rt1, nH := rt4 - rt2
69 | znW := rt5, znH := rt6
70 | }
71 |
72 | mDC := DllCall("CreateCompatibleDC", "Uint", 0)
73 | hBM := CreateDIBSection(mDC, nW, nH)
74 | oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM)
75 | hDC := DllCall("GetDC", "Uint", 0)
76 | DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020)
77 | DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
78 | If bCursor
79 | CaptureCursor(mDC, nL, nT)
80 | DllCall("SelectObject", "Uint", mDC, "Uint", oBM)
81 | DllCall("DeleteDC", "Uint", mDC)
82 | If znW && znH
83 | hBM := Zoomer(hBM, nW, nH, znW, znH)
84 | If sFile = 0
85 | SetClipboardData(hBM)
86 | Else Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM)
87 | }
88 |
89 | CaptureCursor(hDC, nL, nT)
90 | {
91 | VarSetCapacity(mi, 20, 0)
92 | mi := Chr(20)
93 | DllCall("GetCursorInfo", "Uint", &mi)
94 | bShow := NumGet(mi, 4)
95 | hCursor := NumGet(mi, 8)
96 | xCursor := NumGet(mi,12)
97 | yCursor := NumGet(mi,16)
98 |
99 | VarSetCapacity(ni, 20, 0)
100 | DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni)
101 | xHotspot := NumGet(ni, 4)
102 | yHotspot := NumGet(ni, 8)
103 | hBMMask := NumGet(ni,12)
104 | hBMColor := NumGet(ni,16)
105 |
106 | If bShow
107 | DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor)
108 | If hBMMask
109 | DllCall("DeleteObject", "Uint", hBMMask)
110 | If hBMColor
111 | DllCall("DeleteObject", "Uint", hBMColor)
112 | }
113 |
114 | Zoomer(hBM, nW, nH, znW, znH)
115 | {
116 | mDC1 := DllCall("CreateCompatibleDC", "Uint", 0)
117 | mDC2 := DllCall("CreateCompatibleDC", "Uint", 0)
118 | zhBM := CreateDIBSection(mDC2, znW, znH)
119 | oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint", hBM)
120 | oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM)
121 | DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4)
122 | DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
123 | DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1)
124 | DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2)
125 | DllCall("DeleteDC", "Uint", mDC1)
126 | DllCall("DeleteDC", "Uint", mDC2)
127 | DllCall("DeleteObject", "Uint", hBM)
128 | Return zhBM
129 | }
130 |
131 | Convert(sFileFr = "", sFileTo = "", nQuality = "")
132 | {
133 | If sFileTo =
134 | sFileTo := A_ScriptDir . "\screen.bmp"
135 | SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo
136 |
137 | If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll")
138 | Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : ""
139 | VarSetCapacity(si, 16, 0), si := Chr(1)
140 | DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)
141 |
142 | If !sFileFr
143 | {
144 | DllCall("OpenClipboard", "Uint", 0)
145 | If DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2))
146 | DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage)
147 | DllCall("CloseClipboard")
148 | }
149 | Else If sFileFr Is Integer
150 | DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage)
151 | Else DllCall("gdiplus\GdipLoadImageFromFile", a_isunicode ? "Str" : "Uint", a_isunicode ? sFileFr : Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage)
152 |
153 | DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
154 | VarSetCapacity(ci,nSize,0)
155 | DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)
156 | Loop, % nCount
157 | If InStr(a_isunicode ? StrGet(NumGet(ci,76*(A_Index-1)+44), "UTF-16") : Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo)
158 | {
159 | pCodec := &ci+76*(A_Index-1)
160 | Break
161 | }
162 | If InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec
163 | {
164 | DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
165 | VarSetCapacity(pi,nSize,0)
166 | DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi)
167 | Loop, % NumGet(pi)
168 | If NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6
169 | {
170 | pParam := &pi+28*(A_Index-1)
171 | NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20)))
172 | Break
173 | }
174 | }
175 |
176 | If pImage
177 | pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, a_isunicode ? "Str" : "Uint", a_isunicode ? sFileTo : Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
178 |
179 | DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
180 | DllCall("FreeLibrary", "Uint", hGdiPlus)
181 | }
182 |
183 | CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
184 | {
185 | NumPut(VarSetCapacity(bi, 40, 0), bi)
186 | NumPut(nW, bi, 4)
187 | NumPut(nH, bi, 8)
188 | NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
189 | NumPut(0, bi,16)
190 | Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0)
191 | }
192 |
193 | SaveHBITMAPToFile(hBitmap, sFile)
194 | {
195 | DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
196 | hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0)
197 | DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0)
198 | DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0)
199 | DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0)
200 | DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0)
201 | DllCall("CloseHandle", "Uint", hFile)
202 | }
203 |
204 | SetClipboardData(hBitmap)
205 | {
206 | DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi)
207 | hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44))
208 | pDIB := DllCall("GlobalLock", "Uint", hDIB)
209 | DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40)
210 | DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44))
211 | DllCall("GlobalUnlock", "Uint", hDIB)
212 | DllCall("DeleteObject", "Uint", hBitmap)
213 | DllCall("OpenClipboard", "Uint", 0)
214 | DllCall("EmptyClipboard")
215 | DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB)
216 | DllCall("CloseClipboard")
217 | }
218 |
219 | Unicode4Ansi(ByRef wString, sString)
220 | {
221 | nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
222 | VarSetCapacity(wString, nSize * 2)
223 | DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
224 | Return &wString
225 | }
226 |
227 | Ansi4Unicode(pString)
228 | {
229 | nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
230 | VarSetCapacity(sString, nSize)
231 | DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
232 | Return sString
233 | }
--------------------------------------------------------------------------------
/lib/sci.ahk:
--------------------------------------------------------------------------------
1 | ; Title: Scintilla Wrapper for AHK
2 |
3 | class scintilla {
4 | hwnd := 0 ; Component Handle
5 | notify := "" ; Name of the function that will handle the window messages sent by the control
6 |
7 | ; Messages which set this variables.
8 | ; ---------------------------------------------------------------------------------------------------------------
9 | idFrom := 0 ; The handle from which the notification was sent
10 | scnCode := 0 ; The SCN_* notification code
11 | position := 0 ; SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK
12 | ; SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK
13 | ; SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK
14 | ; SCN_INDICATORCLICK, SCN_INDICATORRELEASE
15 | ; SCN_USERLISTSELECTION, SCN_AUTOCSELECTION
16 |
17 | ch := 0 ; SCN_CHARADDED, SCN_KEY
18 | modifiers := 0 ; SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK
19 | ; SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE
20 |
21 | modType := 0 ; SCN_MODIFIED
22 | text := 0 ; SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED
23 | length := 0 ; SCN_MODIFIED
24 | linesAdded := 0 ; SCN_MODIFIED
25 | macMessage := 0 ; SCN_MACRORECORD
26 | macwParam := 0 ; SCN_MACRORECORD
27 | maclParam := 0 ; SCN_MACRORECORD
28 | line := 0 ; SCN_MODIFIED
29 | foldLevelNow := 0 ; SCN_MODIFIED
30 | foldLevelPrev := 0 ; SCN_MODIFIED
31 | margin := 0 ; SCN_MARGINCLICK
32 | listType := 0 ; SCN_USERLISTSELECTION
33 | x := 0 ; SCN_DWELLSTART, SCN_DWELLEND
34 | y := 0 ; SCN_DWELLSTART, SCN_DWELLEND
35 | token := 0 ; SCN_MODIFIED with SC_MOD_CONTAINER
36 | annotLinesAdded := 0 ; SCN_MODIFIED with SC_MOD_CHANGEANNOTATION
37 | updated := false ; SCN_UPDATEUI
38 |
39 | __new(params*){
40 | if (params.MaxIndex())
41 | __SCI(this.hwnd := __Add(params*), this)
42 | else
43 | return this
44 | }
45 |
46 | __call(msg, ByRef wParam:=0, ByRef lParam:=0, params*){
47 |
48 | if (msg = "Add")
49 | __SCI(this.hwnd := __Add(wParam, lParam, params*), this)
50 | else
51 | {
52 | (wParam && !(wParam+0) && !isObject(wParam)) ? (VarSetCapacity(wParamA, StrPut(wParam, "CP0"))
53 | ,StrPut(wParam, &wParamA, "CP0")
54 | ,wParam:=&wParamA) : null
55 |
56 | (lParam && !(lParam+0) && !isObject(lParam)) ? (VarSetCapacity(lParamA, StrPut(lParam, "CP0"))
57 | ,StrPut(lParam, &lParamA, "CP0")
58 | ,lParam:=&lParamA) : null
59 |
60 | /*
61 | Special Operations
62 | Due to the fact that some functions require the user to manually prepare bufferst to store text
63 | I decided to make most of those operations internally to have cleaner code later on.
64 | */
65 |
66 | (msg = "GetText") ? (VarSetCapacity(lParam, wParam * (a_isunicode ? 2 : 1)+8), lParam := &lParam, buf:=true) : null
67 | (msg = "GetLine") ? (VarSetCapacity(lParam, this.linelength(wParam)+1 * (a_isunicode ? 2 : 1)),lParam := &lParam, buf:=true) : null
68 | (msg = "GetCurLine") ? (VarSetCapacity(lParam, this.linelength(wParam)+1 * (a_isunicode ? 2 : 1)), lParam := &lParam, buf:=true) : null
69 | (msg = "GetTextRange") ? (range:=abs(wParam.1 - wParam.2)+1, dSize := __sendEditor(this.hwnd, "GetLength")
70 | ,VarSetCapacity(lParam, range > dSize ? (dSize, wParam.2 := dSize) : range)
71 | ,VarSetCapacity(textRange, 12, 0)
72 | ,NumPut(wParam.1,textRange,0,"UInt")
73 | ,NumPut(wParam.2,textRange,4,"UInt")
74 | ,NumPut(&lParam,textRange,8,"UInt")
75 | ,blParam := &lParam, wParam := false,lParam := &textRange, buf:=true) : null
76 |
77 | __isHexColor(lParam, msg) ? lParam := (lParam & 0xFF) <<16 | (lParam & 0xFF00) | (lParam >>16) : null
78 | __isHexColor(wParam, msg) ? wParam := (wParam & 0xFF) <<16 | (wParam & 0xFF00) | (wParam >>16) : null
79 |
80 | res := __sendEditor(this.hwnd, msg, wParam, lParam)
81 |
82 | ; Retrieve Text from buffer
83 | ; I must switch lParam to another variable when using GetTextRange because lParam cant be overwriten
84 | ; It has the pointer to the TextRange Structure
85 | buf ? (lParam := StrGet((msg = "GetTextRange") ? blParam : &lParam, "CP0"), buf:=false) : null ; convert the text from ANSI
86 | return res
87 | }
88 | }
89 | }
90 |
91 | class sciCharRange {
92 |
93 | __new(_cMin:=0, _cMax:=0){
94 |
95 | this.cMin := _cMin
96 | this.cMax := _cMax
97 | }
98 | }
99 | class sciTextRange {
100 |
101 | __new(_chrg:=0, _pStr:=0){
102 |
103 | if (!isObject(_chrg)){
104 | Msgbox % 0x0
105 | , % "sciTextRange Object Error"
106 | , % "The first parameter must match a sciCharRange object"
107 | Exit
108 | }
109 |
110 | this.chrg := _chrg ? _chrg : new sciCharRange
111 | this.pStr := _pStr
112 | }
113 | }
114 | class sciTextToFind {
115 |
116 | __new(_chrg:=0, _text:="", _found:=0){
117 |
118 | if (!isObject(_chrg) || !isObject(_found)) {
119 | Msgbox % 0x0
120 | , % "sciTextToFind Object Error"
121 | , % "The first and last parameters must match a sciCharRange object"
122 | Exit
123 | }
124 |
125 | this.chrg := _chrg ? _chrg : new sciCharRange
126 | this.text := _text
127 | this.found := _found ? _found : new sciCharRange
128 | }
129 | }
130 | class sciRectangle {
131 |
132 | __new(_left:=0, _top:=0, _right:=0, _bottom:=0){
133 |
134 | this.left := _left
135 | this.top := _top
136 | this.right := _right
137 | this.bottom := _bottom
138 | }
139 | }
140 | class sciRangeToFormat {
141 |
142 | __new(_hdc:=0, _hdcTarget:=0, _rc:=0, _rcPage:=0, _chrg:=0){
143 | this.hdc := _hdc ; The Surface ID we print to
144 | this.hdcTarget := _hdcTarget ; The Surface ID we use for measuring (may be same as hdc)
145 | this.rc := _rc ? _rc : new sciRectangle ; Rectangle in which to print
146 | this.rcPage := _rcPage ? _rcPage : new sciRectangle ; Physically printable page size
147 | this.chrg := _chrg ? _chrg : new sciCharRange ; Range of characters to print
148 | }
149 | }
150 |
151 | ; | Internal Functions |
152 |
153 | /*
154 | Function: __Add
155 | Creates a Scintilla component and adds it to the Parent GUI.
156 |
157 | This function initializes the Scintilla Component.
158 | See for more information on how to add the component to a GUI/Control.
159 |
160 | Parameters:
161 | __Add(hParent, [x, y, w, h, DllPath, Styles])
162 |
163 | hParent - Hwnd of the parent control who will host the Scintilla Component
164 | x - x position for the control (default 5)
165 | y - y position for the control (default 5)
166 | w - Width of the control (default 590)
167 | h - Height of the control (default 390)
168 | DllPath - Path to the SciLexer.dll file, if omitted the function looks for it in *a_scriptdir*.
169 | Styles - List of window style variable names separated by spaces.
170 | The WS_ prefix for the variables is optional.
171 | Full list of Style names can be found at
172 | .
173 |
174 | Returns:
175 | HWND - Component handle.
176 |
177 | Examples:
178 | (start code)
179 | #include ..\SCI.ahk
180 | #singleinstance force
181 |
182 | ;---------------------
183 | ; This script adds a component with default values.
184 | ; If no path was specified when creating the object it expects scilexer.dll to be on the script's location.
185 | ; The default values are calculated to fit optimally on a 600x400 GUI/Control
186 |
187 | Gui +LastFound
188 | sci := new scintilla(WinExist())
189 |
190 | Gui, show, w600 h400
191 | return
192 |
193 | GuiClose:
194 | exitapp
195 |
196 | ;---------------------
197 | #include ..\SCI.ahk
198 | #singleinstance force
199 |
200 | ; Add multiple components.
201 |
202 | Gui +LastFound
203 | hwnd:=WinExist()
204 |
205 | sci1 := new scintilla(hwnd, 0, 0, 590, 190) ; you can put the parameters here
206 | sci2 := new scintilla
207 |
208 | sci2.add(hwnd, 0, 200, 590, 190) ; or you can use the add function like this
209 |
210 | Gui, show, w600 h400
211 | return
212 |
213 | GuiClose:
214 | exitapp
215 |
216 | ;---------------------
217 | #include ..\SCI.ahk
218 | #singleinstance force
219 |
220 | ; Here we add a component embedded in a tab.
221 | ; If the variables "x,w,h" are empty the default values are used.
222 |
223 | Gui, add, Tab2, HWNDhwndtab x0 y0 w600 h420 gtabHandler vtabLast,one|two
224 |
225 | sci := new scintilla
226 | sci.Add(hwndtab, x, 25, w, h, a_scriptdir "\scilexer.dll")
227 |
228 | Gui, show, w600 h420
229 | return
230 |
231 | ; This additional code is for hiding/showing the component depending on which tab is open
232 | ; In this example the Tab named "one" is the one that contains the control.
233 | ; If you switch the words "show" and "hide" the component will be shown when the tab called "two" is active.
234 |
235 | tabHandler: ; Tab Handler for the Scintilla Control
236 | Gui, submit, Nohide
237 | action := tabLast = "one" ? "Show" : "Hide" ; decide which action to take
238 | Control,%action%,,, % "ahk_id " sci.hwnd
239 | return
240 |
241 | GuiClose:
242 | exitapp
243 | (end)
244 | */
245 | __Add(hParent:=0, x:=5, y:=5, w:=590, h:=390, DllPath:="", Styles:=""){
246 | static WS_OVERLAPPED:=0x00000000,WS_POPUP:=0x80000000,WS_CHILD:=0x40000000,WS_MINIMIZE:=0x20000000
247 | ,WS_VISIBLE:=0x10000000,WS_DISABLED:=0x08000000,WS_CLIPSIBLINGS:=0x04000000,WS_CLIPCHILDREN:=0x02000000
248 | ,WS_MAXIMIZE:=0x01000000,WS_CAPTION:=0x00C00000,WS_BORDER:=0x00800000,WS_DLGFRAME:=0x00400000
249 | ,WS_VSCROLL:=0x00200000,WS_HSCROLL:=0x00100000,WS_SYSMENU:=0x00080000,WS_THICKFRAME:=0x00040000
250 | ,WS_GROUP:=0x00020000,WS_TABSTOP:=0x00010000,WS_MINIMIZEBOX:=0x00020000,WS_MAXIMIZEBOX:=0x00010000
251 | ,WS_TILED:=0x00000000,WS_ICONIC:=0x20000000,WS_SIZEBOX:=0x00040000,WS_EX_CLIENTEDGE:=0x00000200
252 | ,GuiID:=311210,init:=false, null:=0
253 |
254 | DllPath := !DllPath ? "SciLexer.dll" : inStr(DllPath, ".dll") ? DllPath : DllPath "\SciLexer.dll"
255 | if !init ; WM_NOTIFY = 0x4E
256 | old:=OnMessage(0x4E,"__sciNotify"),init:=true
257 |
258 | if !SCIModule:=DllCall("LoadLibrary", "Str", DllPath)
259 | return debug ? A_ThisFunc "> Could not load library: " DllPath : 1
260 |
261 | hStyle := WS_CHILD | (VISIBILITY := InStr(Styles, "Hidden") ? 0 : WS_VISIBLE) | WS_TABSTOP
262 |
263 | if Styles
264 | Loop, Parse, Styles, %a_tab%%a_space%, %a_tab%%a_space%
265 | hStyle |= %a_loopfield%+0 ? %a_loopfield% : WS_%a_loopfield% ? WS_%a_loopfield% : 0
266 |
267 | hSci:=DllCall("CreateWindowEx"
268 | ,Uint ,WS_EX_CLIENTEDGE ; Ex Style
269 | ,Str ,"Scintilla" ; Class Name
270 | ,Str ,"" ; Window Name
271 | ,UInt ,hStyle ; Window Styles
272 | ,Int ,x ? x : 5 ; x
273 | ,Int ,y ? y : 5 ; y
274 | ,Int ,w ? w : 590 ; Width
275 | ,Int ,h ? h : 390 ; Height
276 | ,UInt ,hParent ? hParent : WinExist() ; Parent HWND
277 | ,UInt ,GuiID ; (HMENU)GuiID
278 | ,UInt ,null ; hInstance
279 | ,UInt ,null, "UInt") ; lpParam
280 |
281 | ,__sendEditor(hSci) ; initialize sendEditor function
282 |
283 | return hSci
284 | }
285 |
286 | /*
287 | Function : __sendEditor
288 | Posts the messages used to modify the control's behaviour.
289 |
290 | *This is an internal function and it is not needed in normal situations. Please use the scintilla object to call all functions.
291 | They call this function automatically*
292 |
293 | Parameters:
294 | __sendEditor(hwnd, msg, [wParam, lParam])
295 |
296 | hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
297 | Scintilla components in the same script. The wrapper will remember the last used hwnd,
298 | so you can specify it once and only specify it again when you want to operate on a different
299 | component.
300 | *Note: This is converted internally by the wrapper from the object calling method. It is recommended that you dont use this function.*
301 | msg - The message to be posted, full list can be found here:
302 |
303 | wParam - wParam for the message
304 | lParam - lParam for the message
305 |
306 | Returns:
307 | Status code of the DllCall performed.
308 |
309 | Examples:
310 | (Start Code)
311 | __sendEditor(hSci1, "SCI_SETMARGINWIDTHN",0,40) ; Set the margin 0 to 40px on the first component.
312 | __sendEditor(0, "SCI_SETWRAPMODE",1,0) ; Set wrap mode to true on the last used component.
313 | __sendEditor(hSci2, "SCI_SETMARGINWIDTHN",0,50) ; Set the margin 0 to 50px on the second component.
314 | (End)
315 | */
316 | __sendEditor(hwnd, msg:=0, wParam:=0, lParam:=0){
317 | static
318 |
319 | hwnd := !hwnd ? oldhwnd : hwnd, oldhwnd := hwnd, msg := !(msg+0) ? "SCI_" msg : msg
320 |
321 | if !df_%hwnd%
322 | {
323 | SendMessage, SCI_GETDIRECTFUNCTION,0,0,,ahk_id %hwnd%
324 | df_%hwnd% := ErrorLevel
325 | SendMessage, SCI_GETDIRECTPOINTER,0,0,,ahk_id %hwnd%
326 | dp_%hwnd% := ErrorLevel
327 | }
328 |
329 | if !msg && !wParam && !lParam ; called only with the hwnd param from SCI_Add
330 | return ; Exit because we did what we needed to do already.
331 |
332 | ; The fast way to control Scintilla
333 | return DllCall(df_%hwnd% ; DIRECT FUNCTION
334 | ,"UInt" ,dp_%hwnd% ; DIRECT POINTER
335 | ,"UInt" ,!(msg+0) ? %msg% : msg
336 | ,"Int" ,inStr(wParam, "-") ? wParam : (%wParam%+0 ? %wParam% : wParam) ; handles negative ints
337 | ,"Int" ,%lParam%+0 ? %lParam% : lParam)
338 | }
339 |
340 | /*
341 | Function : __sciNotify
342 | This is the default function which will be called when the WM_NOTIFY message has been received. The message is tracked as soon as you
343 | add a new scintilla component.
344 |
345 |
346 | Parameters:
347 | __sciNotify(wParam, lParam, msg, hwnd)
348 |
349 | wParam - wParam for the message
350 | lParam - lParam for the message
351 | msg - The message which triggered this function
352 | hwnd - The hwnd of the control which sent the message
353 |
354 | Returns:
355 | This function sets some variables on the sciObject to which the component belongs to and procedes to call your user defined notify function
356 | which can be set in sciObj.notify.
357 |
358 | It will pass wParam, lParam, msg and hwnd to that function so make sure you define it that way.
359 | Returns nothing.
360 |
361 | Examples:
362 | */
363 | __sciNotify(wParam, lParam, msg, hwnd){
364 |
365 | ; fix int for x64 bit systems
366 | __sciObj := __SCI(NumGet(lParam + 0)) ; Returns original object
367 | __sciObj.idFrom := NumGet(lParam + a_Ptrsize * 1)
368 | __sciObj.scnCode := NumGet(lParam + a_Ptrsize * 2)
369 |
370 | __sciObj.position := NumGet(lParam + a_Ptrsize * 3)
371 | __sciObj.ch := NumGet(lParam + a_Ptrsize * 4)
372 | __sciObj.modifiers := NumGet(lParam + a_Ptrsize * 5)
373 | __sciObj.modType := NumGet(lParam + a_Ptrsize * 6)
374 | __sciObj.text := NumGet(lParam + a_Ptrsize * 7)
375 | __sciObj.length := NumGet(lParam + a_Ptrsize * 8)
376 | __sciObj.linesAdded := NumGet(lParam + a_Ptrsize * 9)
377 |
378 | __sciObj.macMessage := NumGet(lParam + a_Ptrsize * 10)
379 | __sciObj.macwParam := NumGet(lParam + a_Ptrsize * 11)
380 | __sciObj.maclParam := NumGet(lParam + a_Ptrsize * 12)
381 |
382 | __sciObj.line := NumGet(lParam + a_Ptrsize * 13)
383 | __sciObj.foldLevelNow := NumGet(lParam + a_Ptrsize * 14)
384 | __sciObj.foldLevelPrev := NumGet(lParam + a_Ptrsize * 15)
385 | __sciObj.margin := NumGet(lParam + a_Ptrsize * 16)
386 | __sciObj.listType := NumGet(lParam + a_Ptrsize * 17)
387 | __sciObj.x := NumGet(lParam + a_Ptrsize * 18)
388 | __sciObj.y := NumGet(lParam + a_Ptrsize * 19)
389 |
390 | __sciObj.token := NumGet(lParam + a_Ptrsize * 20)
391 | __sciObj.annotLinesAdded := NumGet(lParam + a_Ptrsize * 21)
392 | __sciObj.updated := NumGet(lParam + a_Ptrsize * 22)
393 |
394 | __sciObj.notify(wParam, lParam, msg, hwnd, __sciObj) ; Call user defined Notify Function and passes object to it as last parameter
395 | return __sciObj := "" ; free object
396 | }
397 |
398 | __isHexColor(hex, msg){
399 | if (RegexMatch(hex, "^0x[0-9a-fA-F]{6}$"))
400 | return true
401 | else
402 | return false
403 | }
404 |
405 | __SCI(var, val:=""){
406 | static
407 |
408 | if (RegExMatch(var,"i)[ `n-\.%,(\\\/=&^]")) ; Check if it is a valid variable name
409 | return
410 |
411 | lvar := %var%, val ? %var% := val : null
412 | return lvar
413 | }
414 |
415 | ; Global scintilla variables
416 | {
417 | global INVALID_POSITION:=-1, unused := 0 ; Some messages dont use one of their parameters. You can use this variable for them.
418 |
419 | ; Main Scintilla Functions
420 | {
421 | global SCI_ADDTEXT:=2001,SCI_ADDSTYLEDTEXT:=2002,SCI_INSERTTEXT:=2003,SCI_CLEARALL:=2004,SCI_CLEARDOCUMENTSTYLE:=2005,SCI_GETLENGTH:=2006
422 | ,SCI_GETCHARAT:=2007,SCI_GETCURRENTPOS:=2008,SCI_GETANCHOR:=2009,SCI_GETSTYLEAT:=2010,SCI_REDO:=2011,SCI_SETUNDOCOLLECTION:=2012
423 | ,SCI_SELECTALL:=2013,SCI_SETSAVEPOINT:=2014,SCI_GETSTYLEDTEXT:=2015,SCI_CANREDO:=2016,SCI_MARKERLINEFROMHANDLE:=2017
424 | ,SCI_MARKERDELETEHANDLE:=2018,SCI_GETUNDOCOLLECTION:=2019,SCI_GETVIEWWS:=2020,SCI_SETVIEWWS:=2021,SCI_POSITIONFROMPOINT:=2022
425 | ,SCI_POSITIONFROMPOINTCLOSE:=2023,SCI_GOTOLINE:=2024,SCI_GOTOPOS:=2025,SCI_SETANCHOR:=2026,SCI_GETCURLINE:=2027,SCI_GETENDSTYLED:=2028
426 | ,SCI_CONVERTEOLS:=2029,SCI_GETEOLMODE:=2030,SCI_SETEOLMODE:=2031,SCI_STARTSTYLING:=2032,SCI_SETSTYLING:=2033,SCI_GETBUFFEREDDRAW:=2034
427 | ,SCI_SETBUFFEREDDRAW:=2035,SCI_SETTABWIDTH:=2036,SCI_GETTABWIDTH:=2121,SCI_SETCODEPAGE:=2037,SCI_SETUSEPALETTE:=2039,SCI_MARKERDEFINE:=2040
428 | ,SCI_MARKERSETFORE:=2041,SCI_MARKERSETBACK:=2042,SCI_MARKERADD:=2043,SCI_MARKERDELETE:=2044,SCI_MARKERDELETEALL:=2045,SCI_MARKERGET:=2046
429 | ,SCI_MARKERNEXT:=2047,SCI_MARKERPREVIOUS:=2048,SCI_MARKERDEFINEPIXMAP:=2049,SCI_MARKERADDSET:=2466,SCI_MARKERSETALPHA:=2476
430 | ,SCI_SETMARGINTYPEN:=2240,SCI_GETMARGINTYPEN:=2241,SCI_SETMARGINWIDTHN:=2242,SCI_GETMARGINWIDTHN:=2243,SCI_SETMARGINMASKN:=2244
431 | ,SCI_GETMARGINMASKN:=2245,SCI_SETMARGINSENSITIVEN:=2246,SCI_GETMARGINSENSITIVEN:=2247,SCI_STYLECLEARALL:=2050,SCI_STYLESETFORE:=2051
432 | ,SCI_STYLESETBACK:=2052,SCI_STYLESETBOLD:=2053,SCI_STYLESETITALIC:=2054,SCI_STYLESETSIZE:=2055,SCI_STYLESETFONT:=2056
433 | ,SCI_STYLESETEOLFILLED:=2057,SCI_STYLEGETFORE:=2481,SCI_STYLEGETBACK:=2482,SCI_STYLEGETBOLD:=2483,SCI_STYLEGETITALIC:=2484
434 | ,SCI_STYLEGETSIZE:=2485,SCI_STYLEGETFONT:=2486,SCI_STYLEGETEOLFILLED:=2487,SCI_STYLEGETUNDERLINE:=2488,SCI_STYLEGETCASE:=2489
435 | ,SCI_STYLEGETCHARACTERSET:=2490,SCI_STYLEGETVISIBLE:=2491,SCI_STYLEGETCHANGEABLE:=2492,SCI_STYLEGETHOTSPOT:=2493,SCI_STYLERESETDEFAULT:=2058
436 | ,SCI_STYLESETUNDERLINE:=2059,SCI_STYLESETCASE:=2060,SCI_STYLESETCHARACTERSET:=2066,SCI_STYLESETHOTSPOT:=2409,SCI_SETSELFORE:=2067
437 | ,SCI_SETSELBACK:=2068,SCI_GETSELALPHA:=2477,SCI_SETSELALPHA:=2478,SCI_SETCARETFORE:=2069,SCI_ASSIGNCMDKEY:=2070,SCI_CLEARCMDKEY:=2071
438 | ,SCI_CLEARALLCMDKEYS:=2072,SCI_SETSTYLINGEX:=2073,SCI_STYLESETVISIBLE:=2074,SCI_GETCARETPERIOD:=2075,SCI_SETCARETPERIOD:=2076
439 | ,SCI_SETWORDCHARS:=2077,SCI_BEGINUNDOACTION:=2078,SCI_ENDUNDOACTION:=2079,SCI_INDICSETSTYLE:=2080,SCI_INDICGETSTYLE:=2081
440 | ,SCI_INDICSETFORE:=2082,SCI_INDICGETFORE:=2083,SCI_SETWHITESPACEFORE:=2084,SCI_SETWHITESPACEBACK:=2085,SCI_SETSTYLEBITS:=2090
441 | ,SCI_GETSTYLEBITS:=2091,SCI_SETLINESTATE:=2092,SCI_GETLINESTATE:=2093,SCI_GETMAXLINESTATE:=2094,SCI_GETCARETLINEVISIBLE:=2095
442 | ,SCI_SETCARETLINEVISIBLE:=2096,SCI_GETCARETLINEBACK:=2097,SCI_SETCARETLINEBACK:=2098,SCI_STYLESETCHANGEABLE:=2099,SCI_AUTOCSHOW:=2100
443 | ,SCI_AUTOCCANCEL:=2101,SCI_AUTOCACTIVE:=2102,SCI_AUTOCPOSSTART:=2103,SCI_AUTOCCOMPLETE:=2104,SCI_AUTOCSTOPS:=2105
444 | ,SCI_AUTOCSETSEPARATOR:=2106,SCI_AUTOCGETSEPARATOR:=2107,SCI_AUTOCSELECT:=2108,SCI_AUTOCSETCANCELATSTART:=2110
445 | ,SCI_AUTOCGETCANCELATSTART:=2111,SCI_AUTOCSETFILLUPS:=2112,SCI_AUTOCSETCHOOSESINGLE:=2113,SCI_AUTOCGETCHOOSESINGLE:=2114
446 | ,SCI_AUTOCSETIGNORECASE:=2115,SCI_AUTOCGETIGNORECASE:=2116,SCI_USERLISTSHOW:=2117,SCI_AUTOCSETAUTOHIDE:=2118,SCI_AUTOCGETAUTOHIDE:=2119
447 | ,SCI_AUTOCSETDROPRESTOFWORD:=2270,SCI_AUTOCGETDROPRESTOFWORD:=2271,SCI_REGISTERIMAGE:=2405,SCI_CLEARREGISTEREDIMAGES:=2408
448 | ,SCI_AUTOCGETTYPESEPARATOR:=2285,SCI_AUTOCSETTYPESEPARATOR:=2286,SCI_AUTOCSETMAXWIDTH:=2208,SCI_AUTOCGETMAXWIDTH:=2209
449 | ,SCI_AUTOCSETMAXHEIGHT:=2210,SCI_AUTOCGETMAXHEIGHT:=2211,SCI_SETINDENT:=2122,SCI_GETINDENT:=2123,SCI_SETUSETABS:=2124,SCI_GETUSETABS:=2125
450 | ,SCI_SETLINEINDENTATION:=2126,SCI_GETLINEINDENTATION:=2127,SCI_GETLINEINDENTPOSITION:=2128,SCI_GETCOLUMN:=2129,SCI_SETHSCROLLBAR:=2130
451 | ,SCI_GETHSCROLLBAR:=2131,SCI_SETINDENTATIONGUIDES:=2132,SCI_GETINDENTATIONGUIDES:=2133,SCI_SETHIGHLIGHTGUIDE:=2134
452 | ,SCI_GETHIGHLIGHTGUIDE:=2135,SCI_GETLINEENDPOSITION:=2136,SCI_GETCODEPAGE:=2137,SCI_GETCARETFORE:=2138,SCI_GETUSEPALETTE:=2139
453 | ,SCI_GETREADONLY:=2140,SCI_SETCURRENTPOS:=2141,SCI_SETSELECTIONSTART:=2142,SCI_GETSELECTIONSTART:=2143,SCI_SETSELECTIONEND:=2144
454 | ,SCI_GETSELECTIONEND:=2145,SCI_SETPRINTMAGNIFICATION:=2146,SCI_GETPRINTMAGNIFICATION:=2147,SCI_SETPRINTCOLORMODE:=2148
455 | ,SCI_GETPRINTCOLORMODE:=2149,SCI_FINDTEXT:=2150,SCI_FORMATRANGE:=2151,SCI_GETFIRSTVISIBLELINE:=2152,SCI_GETLINE:=2153
456 | ,SCI_GETLINECOUNT:=2154,SCI_SETMARGINLEFT:=2155,SCI_GETMARGINLEFT:=2156,SCI_SETMARGINRIGHT:=2157,SCI_GETMARGINRIGHT:=2158
457 | ,SCI_GETMODIFY:=2159,SCI_SETSEL:=2160,SCI_GETSELTEXT:=2161,SCI_GETTEXTRANGE:=2162,SCI_HIDESELECTION:=2163,SCI_POINTXFROMPOSITION:=2164
458 | ,SCI_POINTYFROMPOSITION:=2165,SCI_LINEFROMPOSITION:=2166,SCI_POSITIONFROMLINE:=2167,SCI_LINESCROLL:=2168,SCI_SCROLLCARET:=2169
459 | ,SCI_REPLACESEL:=2170,SCI_SETREADONLY:=2171,SCI_NULL:=2172,SCI_CANPASTE:=2173,SCI_CANUNDO:=2174,SCI_EMPTYUNDOBUFFER:=2175,SCI_UNDO:=2176
460 | ,SCI_CUT:=2177,SCI_COPY:=2178,SCI_PASTE:=2179,SCI_CLEAR:=2180,SCI_SETTEXT:=2181,SCI_GETTEXT:=2182,SCI_GETTEXTLENGTH:=2183
461 | ,SCI_GETDIRECTFUNCTION:=2184,SCI_GETDIRECTPOINTER:=2185,SCI_SETOVERTYPE:=2186,SCI_GETOVERTYPE:=2187,SCI_SETCARETWIDTH:=2188
462 | ,SCI_GETCARETWIDTH:=2189,SCI_SETTARGETSTART:=2190,SCI_GETTARGETSTART:=2191,SCI_SETTARGETEND:=2192,SCI_GETTARGETEND:=2193
463 | ,SCI_REPLACETARGET:=2194,SCI_REPLACETARGETRE:=2195,SCI_SEARCHINTARGET:=2197,SCI_SETSEARCHFLAGS:=2198,SCI_GETSEARCHFLAGS:=2199
464 | ,SCI_CALLTIPSHOW:=2200,SCI_CALLTIPCANCEL:=2201,SCI_CALLTIPACTIVE:=2202,SCI_CALLTIPPOSSTART:=2203,SCI_CALLTIPSETHLT:=2204
465 | ,SCI_CALLTIPSETBACK:=2205,SCI_CALLTIPSETFORE:=2206,SCI_CALLTIPSETFOREHLT:=2207,SCI_CALLTIPUSESTYLE:=2212,SCI_VISIBLEFROMDOCLINE:=2220
466 | ,SCI_DOCLINEFROMVISIBLE:=2221,SCI_WRAPCOUNT:=2235,SCI_SETFOLDLEVEL:=2222,SCI_GETFOLDLEVEL:=2223,SCI_GETLASTCHILD:=2224
467 | ,SCI_GETFOLDPARENT:=2225,SCI_SHOWLINES:=2226,SCI_HIDELINES:=2227,SCI_GETLINEVISIBLE:=2228,SCI_SETFOLDEXPANDED:=2229
468 | ,SCI_GETFOLDEXPANDED:=2230,SCI_TOGGLEFOLD:=2231,SCI_ENSUREVISIBLE:=2232,SCI_SETFOLDFLAGS:=2233,SCI_ENSUREVISIBLEENFORCEPOLICY:=2234
469 | ,SCI_SETTABINDENTS:=2260,SCI_GETTABINDENTS:=2261,SCI_SETBACKSPACEUNINDENTS:=2262,SCI_GETBACKSPACEUNINDENTS:=2263,SCI_SETMOUSEDWELLTIME:=2264
470 | ,SCI_GETMOUSEDWELLTIME:=2265,SCI_WORDSTARTPOSITION:=2266,SCI_WORDENDPOSITION:=2267,SCI_SETWRAPMODE:=2268,SCI_GETWRAPMODE:=2269
471 | ,SCI_SETWRAPVISUALFLAGS:=2460,SCI_GETWRAPVISUALFLAGS:=2461,SCI_SETWRAPVISUALFLAGSLOCATION:=2462,SCI_GETWRAPVISUALFLAGSLOCATION:=2463
472 | ,SCI_SETWRAPSTARTINDENT:=2464,SCI_GETWRAPSTARTINDENT:=2465,SCI_SETLAYOUTCACHE:=2272,SCI_GETLAYOUTCACHE:=2273,SCI_SETSCROLLWIDTH:=2274
473 | ,SCI_GETSCROLLWIDTH:=2275,SCI_TEXTWIDTH:=2276,SCI_SETENDATLASTLINE:=2277,SCI_GETENDATLASTLINE:=2278,SCI_TEXTHEIGHT:=2279
474 | ,SCI_SETVSCROLLBAR:=2280,SCI_GETVSCROLLBAR:=2281,SCI_APPENDTEXT:=2282,SCI_GETTWOPHASEDRAW:=2283,SCI_SETTWOPHASEDRAW:=2284
475 | ,SCI_TARGETFROMSELECTION:=2287,SCI_LINESJOIN:=2288,SCI_LINESSPLIT:=2289,SCI_SETFOLDMARGINCOLOR:=2290,SCI_SETFOLDMARGINHICOLOR:=2291
476 | ,SCI_ZOOMIN:=2333,SCI_ZOOMOUT:=2334,SCI_MOVECARETINSIDEVIEW:=2401,SCI_LINELENGTH:=2350,SCI_BRACEHIGHLIGHT:=2351,SCI_BRACEBADLIGHT:=2352
477 | ,SCI_BRACEMATCH:=2353,SCI_GETVIEWEOL:=2355,SCI_SETVIEWEOL:=2356,SCI_GETDOCPOINTER:=2357,SCI_SETDOCPOINTER:=2358,SCI_SETMODEVENTMASK:=2359
478 | ,SCI_GETEDGECOLUMN:=2360,SCI_SETEDGECOLUMN:=2361,SCI_GETEDGEMODE:=2362,SCI_SETEDGEMODE:=2363,SCI_GETEDGECOLOR:=2364,SCI_SETEDGECOLOR:=2365
479 | ,SCI_SEARCHANCHOR:=2366,SCI_SEARCHNEXT:=2367,SCI_SEARCHPREV:=2368,SCI_LINESONSCREEN:=2370,SCI_USEPOPUP:=2371,SCI_SELECTIONISRECTANGLE:=2372
480 | ,SCI_SETZOOM:=2373,SCI_GETZOOM:=2374,SCI_CREATEDOCUMENT:=2375,SCI_ADDREFDOCUMENT:=2376,SCI_RELEASEDOCUMENT:=2377,SCI_GETMODEVENTMASK:=2378
481 | ,SCI_SETFOCUS:=2380,SCI_GETFOCUS:=2381,SCI_SETSTATUS:=2382,SCI_GETSTATUS:=2383,SCI_SETMOUSEDOWNCAPTURES:=2384,SCI_GETMOUSEDOWNCAPTURES:=2385
482 | ,SCI_SETCURSOR:=2386,SCI_GETCURSOR:=2387,SCI_SETCONTROLCHARSYMBOL:=2388,SCI_GETCONTROLCHARSYMBOL:=2389,SCI_SETVISIBLEPOLICY:=2394
483 | ,SCI_SETXOFFSET:=2397,SCI_GETXOFFSET:=2398,SCI_CHOOSECARETX:=2399,SCI_GRABFOCUS:=2400,SCI_SETXCARETPOLICY:=2402,SCI_SETYCARETPOLICY:=2403
484 | ,SCI_SETPRINTWRAPMODE:=2406,SCI_GETPRINTWRAPMODE:=2407,SCI_SETHOTSPOTACTIVEFORE:=2410,SCI_SETHOTSPOTACTIVEBACK:=2411
485 | ,SCI_SETHOTSPOTACTIVEUNDERLINE:=2412,SCI_SETHOTSPOTSINGLELINE:=2421,SCI_POSITIONBEFORE:=2417,SCI_POSITIONAFTER:=2418
486 | ,SCI_COPYRANGE:=2419,SCI_COPYTEXT:=2420,SCI_SETSELECTIONMODE:=2422,SCI_GETSELECTIONMODE:=2423,SCI_GETLINESELSTARTPOSITION:=2424
487 | ,SCI_GETLINESELENDPOSITION:=2425,SCI_SETWHITESPACECHARS:=2443,SCI_SETCHARSDEFAULT:=2444,SCI_AUTOCGETCURRENT:=2445,SCI_ALLOCATE:=2446
488 | ,SCI_TARGETASUTF8:=2447,SCI_SETLENGTHFORENCODE:=2448,SCI_ENCODEDFROMUTF8:=2449,SCI_FINDCOLUMN:=2456,SCI_GETCARETSTICKY:=2457
489 | ,SCI_SETCARETSTICKY:=2458,SCI_TOGGLECARETSTICKY:=2459,SCI_SETPASTECONVERTENDINGS:=2467,SCI_GETPASTECONVERTENDINGS:=2468
490 | ,SCI_SETCARETLINEBACKALPHA:=2470,SCI_GETCARETLINEBACKALPHA:=2471,SCI_STARTRECORD:=3001,SCI_STOPRECORD:=3002,SCI_SETLEXER:=4001
491 | ,SCI_GETLEXER:=4002,SCI_COLORISE:=4003,SCI_SETPROPERTY:=4004,SCI_SETKEYWORDS:=4005,SCI_SETLEXERLANGUAGE:=4006,SCI_LOADLEXERLIBRARY:=4007
492 | ,SCI_GETPROPERTY:=4008,SCI_GETPROPERTYEXPANDED:=4009,SCI_GETPROPERTYINT:=4010,SCI_GETSTYLEBITSNEEDED:=4011
493 | }
494 |
495 | ; Styles, Markers and Indicators
496 | {
497 | global MARKER_MAX:=31,STYLE_DEFAULT:=32,STYLE_LINENUMBER:=33,STYLE_BRACELIGHT:=34,STYLE_BRACEBAD:=35,STYLE_CONTROLCHAR:=36
498 | ,STYLE_INDENTGUIDE:=37,STYLE_CALLTIP:=38,STYLE_LASTPREDEFINED:=39,STYLE_MAX:=127,INDIC_MAX:=7,INDIC_PLAIN:=0,INDIC_SQUIGGLE:=1,INDIC_TT:=2
499 | ,INDIC_DIAGONAL:=3,INDIC_STRIKE:=4,INDIC_HIDDEN:=5,INDIC_BOX:=6,INDIC_ROUNDBOX:=7,INDIC0_MASK:=0x20,INDIC1_MASK:=0x40,INDIC2_MASK:=0x80
500 | ,INDICS_MASK:=0xE0,SCI_START:=2000,SCI_OPTIONAL_START:=3000,SCI_LEXER_START:=4000,SCWS_INVISIBLE:=0,SCWS_VISIBLEALWAYS:=1
501 | ,SCWS_VISIBLEAFTERINDENT:=2,SC_EOL_CRLF:=0,SC_EOL_CR:=1,SC_EOL_LF:=2,SC_CP_UTF8:=65001,SC_CP_DBCS:=1,SC_MARK_CIRCLE:=0,SC_MARK_ROUNDRECT:=1
502 | ,SC_MARK_ARROW:=2,SC_MARK_SMALLRECT:=3,SC_MARK_SHORTARROW:=4,SC_MARK_EMPTY:=5,SC_MARK_ARROWDOWN:=6,SC_MARK_MINUS:=7,SC_MARK_PLUS:=8
503 | ,SC_MARK_VLINE:=9,SC_MARK_LCORNER:=10,SC_MARK_TCORNER:=11,SC_MARK_BOXPLUS:=12,SC_MARK_BOXPLUSCONNECTED:=13,SC_MARK_BOXMINUS:=14
504 | ,SC_MARK_BOXMINUSCONNECTED:=15,SC_MARK_LCORNERCURVE:=16,SC_MARK_TCORNERCURVE:=17,SC_MARK_CIRCLEPLUS:=18,SC_MARK_CIRCLEPLUSCONNECTED:=19
505 | ,SC_MARK_CIRCLEMINUS:=20,SC_MARK_CIRCLEMINUSCONNECTED:=21,SC_MARK_BACKGROUND:=22,SC_MARK_DOTDOTDOT:=23,SC_MARK_ARROWS:=24
506 | ,SC_MARK_PIXMAP:=25,SC_MARK_FULLRECT:=26,SC_MARK_CHARACTER:=10000,SC_MARKNUM_FOLDEREND:=25,SC_MARKNUM_FOLDEROPENMID:=26
507 | ,SC_MARKNUM_FOLDERMIDTAIL:=27,SC_MARKNUM_FOLDERTAIL:=28,SC_MARKNUM_FOLDERSUB:=29,SC_MARKNUM_FOLDER:=30,SC_MARKNUM_FOLDEROPEN:=31
508 | ,SC_MASK_FOLDERS:=0xFE000000,SC_MARGIN_SYMBOL:=0,SC_MARGIN_NUMBER:=1
509 | }
510 |
511 | ; Character Sets and Printing
512 | {
513 | global SC_CHARSET_ANSI:=0,SC_CHARSET_DEFAULT:=1,SC_CHARSET_BALTIC:=186
514 | ,SC_CHARSET_CHINESEBIG5:=136,SC_CHARSET_EASTEUROPE:=238,SC_CHARSET_GB2312:=134,SC_CHARSET_GREEK:=161,SC_CHARSET_HANGUL:=129
515 | ,SC_CHARSET_MAC:=77,SC_CHARSET_OEM:=255,SC_CHARSET_RUSSIAN:=204,SC_CHARSET_CYRILLIC:=1251,SC_CHARSET_SHIFTJIS:=128
516 | ,SC_CHARSET_SYMBOL:=2,SC_CHARSET_TURKISH:=162,SC_CHARSET_JOHAB:=130,SC_CHARSET_HEBREW:=177,SC_CHARSET_ARABIC:=178,SC_CHARSET_VIETNAMESE:=163
517 | ,SC_CHARSET_THAI:=222,SC_CHARSET_8859_15:=1000, SC_CASE_MIXED:=0,SC_CASE_UPPER:=1,SC_CASE_LOWER:=2,SC_PRINT_NORMAL:=0,SC_PRINT_INVERTLIGHT:=1
518 | ,SC_PRINT_BLACKONWHITE:=2,SC_PRINT_COLORONWHITE:=3,SC_PRINT_COLORONWHITEDEFAULTBG:=4
519 | }
520 |
521 | ; Search Flags
522 | {
523 | global SCFIND_WHOLEWORD:=2,SCFIND_MATCHCASE:=4
524 | ,SCFIND_WORDSTART:=0x00100000,SCFIND_REGEXP:=0x00200000,SCFIND_POSIX:=0x00400000
525 | }
526 |
527 | ; Folding
528 | {
529 | global SC_FOLDLEVELBASE:=0x400,SC_FOLDLEVELWHITEFLAG:=0x1000
530 | ,SC_FOLDLEVELHEADERFLAG:=0x2000,SC_FOLDLEVELBOXHEADERFLAG:=0x4000,SC_FOLDLEVELBOXFOOTERFLAG:=0x8000,SC_FOLDLEVELCONTRACTED:=0x10000
531 | ,SC_FOLDLEVELUNINDENT:=0x20000,SC_FOLDLEVELNUMBERMASK:=0x0FFF,SC_FOLDFLAG_LINEBEFORE_EXPANDED:=0x0002,SC_FOLDFLAG_LINEBEFORE_CONTRACTED:=0x0004
532 | ,SC_FOLDFLAG_LINEAFTER_EXPANDED:=0x0008,SC_FOLDFLAG_LINEAFTER_CONTRACTED:=0x0010,SC_FOLDFLAG_LEVELNUMBERS:=0x0040,SC_FOLDFLAG_BOX:=0x0001
533 | }
534 |
535 | ; Keys
536 | {
537 | global SCMOD_NORM:=0, SCMOD_SHIFT:=1,SCMOD_CTRL:=2,SCMOD_ALT:=4, SCK_DOWN:=300,SCK_UP:=301,SCK_LEFT:=302,SCK_RIGHT:=303,SCK_HOME:=304,SCK_END:=305
538 | ,SCK_PRIOR:=306,SCK_NEXT:=307,SCK_DELETE:=308,SCK_INSERT:=309,SCK_ESCAPE:=7,SCK_BACK:=8,SCK_TAB:=9,SCK_RETURN:=13,SCK_ADD:=310,SCK_SUBTRACT:=311
539 | ,SCK_DIVIDE:=312
540 | }
541 |
542 | ; Lexing
543 | {
544 | global SCLEX_CONTAINER:=0,SCLEX_NULL:=1,SCLEX_PYTHON:=2,SCLEX_CPP:=3,SCLEX_HTML:=4,SCLEX_XML:=5,SCLEX_PERL:=6,SCLEX_SQL:=7,SCLEX_VB:=8
545 | ,SCLEX_PROPERTIES:=9,SCLEX_ERRORLIST:=10,SCLEX_MAKEFILE:=11,SCLEX_BATCH:=12,SCLEX_XCODE:=13,SCLEX_LATEX:=14,SCLEX_LUA:=15,SCLEX_DIFF:=16
546 | ,SCLEX_CONF:=17,SCLEX_PASCAL:=18,SCLEX_AVE:=19,SCLEX_ADA:=20,SCLEX_LISP:=21,SCLEX_RUBY:=22,SCLEX_EIFFEL:=23,SCLEX_EIFFELKW:=24
547 | ,SCLEX_TCL:=25,SCLEX_NNCRONTAB:=26,SCLEX_BULLANT:=27,SCLEX_VBSCRIPT:=28,SCLEX_BAAN:=31,SCLEX_MATLAB:=32,SCLEX_SCRIPTOL:=33
548 | ,SCLEX_ASM:=34,SCLEX_CPPNOCASE:=35,SCLEX_FORTRAN:=36,SCLEX_F77:=37,SCLEX_CSS:=38,SCLEX_POV:=39,SCLEX_LOUT:=40,SCLEX_ESCRIPT:=41
549 | ,SCLEX_PS:=42,SCLEX_NSIS:=43,SCLEX_MMIXAL:=44,SCLEX_CLW:=45,SCLEX_CLWNOCASE:=46,SCLEX_LOT:=47,SCLEX_YAML:=48,SCLEX_TEX:=49
550 | ,SCLEX_METAPOST:=50,SCLEX_POWERBASIC:=51,SCLEX_FORTH:=52,SCLEX_ERLANG:=53,SCLEX_OCTAVE:=54,SCLEX_MSSQL:=55,SCLEX_VERILOG:=56,SCLEX_KIX:=57
551 | ,SCLEX_GUI4CLI:=58,SCLEX_SPECMAN:=59,SCLEX_AU3:=60,SCLEX_APDL:=61,SCLEX_BASH:=62,SCLEX_ASN1:=63,SCLEX_VHDL:=64,SCLEX_CAML:=65
552 | ,SCLEX_BLITZBASIC:=66,SCLEX_PUREBASIC:=67,SCLEX_HASKELL:=68,SCLEX_PHPSCRIPT:=69,SCLEX_TADS3:=70,SCLEX_REBOL:=71,SCLEX_SMALLTALK:=72
553 | ,SCLEX_FLAGSHIP:=73,SCLEX_CSOUND:=74,SCLEX_FREEBASIC:=75,SCLEX_INNOSETUP:=76,SCLEX_OPAL:=77,SCLEX_SPICE:=78,SCLEX_D:=79,SCLEX_CMAKE:=80
554 | ,SCLEX_GAP:=81,SCLEX_PLM:=82,SCLEX_PROGRESS:=83,SCLEX_ABAQUS:=84,SCLEX_ASYMPTOTE:=85,SCLEX_R:=86,SCLEX_MAGIK:=87,SCLEX_POWERSHELL:=88
555 | ,SCLEX_MYSQL:=89,SCLEX_PO:=90,SCLEX_TAL:=91,SCLEX_COBOL:=92,SCLEX_TACL:=93,SCLEX_SORCUS:=94,SCLEX_POWERPRO:=95,SCLEX_NIMROD:=96,SCLEX_SML:=97
556 | ,SCLEX_MARKDOWN:=98,SCLEX_TXT2TAGS:=99,SCLEX_A68K:=100,SCLEX_MODULA:=101,SCLEX_COFFEESCRIPT:=102,SCLEX_TCMD:=103,SCLEX_AVS:=104,SCLEX_ECL:=105
557 | ,SCLEX_OSCRIPT:=106,SCLEX_VISUALPROLOG:=107,SCLEX_LITERATEHASKELL:=108,SCLEX_AHKL:=109
558 | ,SCE_AHKL_NEUTRAL:=0,SCE_AHKL_IDENTIFIER:=1,SCE_AHKL_COMMENTDOC:=2,SCE_AHKL_COMMENTLINE:=3,SCE_AHKL_COMMENTBLOCK:=4,SCE_AHKL_COMMENTKEYWORD:=5
559 | ,SCE_AHKL_STRING:=6,SCE_AHKL_STRINGOPTS:=7,SCE_AHKL_STRINGBLOCK:=8,SCE_AHKL_STRINGCOMMENT:=9,SCE_AHKL_LABEL:=10,SCE_AHKL_HOTKEY:=11
560 | ,SCE_AHKL_HOTSTRING:=12,SCE_AHKL_HOTSTRINGOPT:=13,SCE_AHKL_HEXNUMBER:=14,SCE_AHKL_DECNUMBER:=15,SCE_AHKL_VAR:=16,SCE_AHKL_VARREF:=17
561 | ,SCE_AHKL_OBJECT:=18,SCE_AHKL_USERFUNCTION:=19,SCE_AHKL_DIRECTIVE:=20,SCE_AHKL_COMMAND:=21,SCE_AHKL_PARAM:=22,SCE_AHKL_CONTROLFLOW:=23
562 | ,SCE_AHKL_BUILTINFUNCTION:=24,SCE_AHKL_BUILTINVAR:=25,SCE_AHKL_KEY:=26,SCE_AHKL_USERDEFINED1:=27,SCE_AHKL_USERDEFINED2:=28,SCE_AHKL_ESCAPESEQ:=30
563 | ,SCE_AHKL_ERROR:=31,AHKL_LIST_DIRECTIVES:=0,AHKL_LIST_COMMANDS:=1,AHKL_LIST_PARAMETERS:=2,AHKL_LIST_CONTROLFLOW:=3,AHKL_LIST_FUNCTIONS:=4
564 | ,AHKL_LIST_VARIABLES:=5,AHKL_LIST_KEYS:=6,AHKL_LIST_USERDEFINED1:=7,AHKL_LIST_USERDEFINED2:=8,SCLEX_AUTOMATIC:=1000
565 | }
566 |
567 | ; Notifications
568 | {
569 | global SCEN_CHANGE:=768,SCEN_SETFOCUS:=512,SCEN_KILLFOCUS:=256, SCN_STYLENEEDED:=2000,SCN_CHARADDED:=2001
570 | ,SCN_SAVEPOINTREACHED:=2002,SCN_SAVEPOINTLEFT:=2003,SCN_MODIFYATTEMPTRO:=2004,SCN_KEY:=2005,SCN_DOUBLECLICK:=2006,SCN_UPDATEUI:=2007
571 | ,SCN_MODIFIED:=2008,SCN_MACRORECORD:=2009,SCN_MARGINCLICK:=2010,SCN_NEEDSHOWN:=2011,SCN_PAINTED:=2013,SCN_USERLISTSELECTION:=2014
572 | ,SCN_URIDROPPED:=2015,SCN_DWELLSTART:=2016,SCN_DWELLEND:=2017,SCN_ZOOM:=2018,SCN_HOTSPOTCLICK:=2019,SCN_HOTSPOTDOUBLECLICK:=2020
573 | ,SCN_CALLTIPCLICK:=2021,SCN_AUTOCSELECTION:=2022
574 | }
575 |
576 | ; Other
577 | {
578 | global SCI_LINEDOWN:=2300,SCI_LINEDOWNEXTEND:=2301,SCI_LINEDOWNRECTEXTEND:=2426
579 | ,SCI_LINESCROLLDOWN:=2342,SCI_LINEUP:=2302,SCI_LINEUPEXTEND:=2303,SCI_LINEUPRECTEXTEND:=2427,SCI_LINESCROLLUP:=2343,SCI_PARADOWN:=2413
580 | ,SCI_PARADOWNEXTEND:=2414,SCI_PARAUP:=2415,SCI_PARAUPEXTEND:=2416,SCI_CHARLEFT:=2304,SCI_CHARLEFTEXTEND:=2305,SCI_CHARLEFTRECTEXTEND:=2428
581 | ,SCI_CHARRIGHT:=2306,SCI_CHARRIGHTEXTEND:=2307,SCI_CHARRIGHTRECTEXTEND:=2429,SCI_WORDLEFT:=2308,SCI_WORDLEFTEXTEND:=2309,SCI_WORDRIGHT:=2310
582 | ,SCI_WORDRIGHTEXTEND:=2311,SCI_WORDLEFTEND:=2439,SCI_WORDLEFTENDEXTEND:=2440,SCI_WORDRIGHTEND:=2441,SCI_WORDRIGHTENDEXTEND:=2442
583 | ,SCI_WORDPARTLEFT:=2390,SCI_WORDPARTLEFTEXTEND:=2391,SCI_WORDPARTRIGHT:=2392,SCI_WORDPARTRIGHTEXTEND:=2393,SCI_HOME:=2312
584 | ,SCI_HOMEEXTEND:=2313,SCI_HOMERECTEXTEND:=2430,SCI_HOMEDISPLAY:=2345,SCI_HOMEDISPLAYEXTEND:=2346,SCI_HOMEWRAP:=2349
585 | ,SCI_HOMEWRAPEXTEND:=2450,SCI_VCHOME:=2331,SCI_VCHOMEEXTEND:=2332,SCI_VCHOMERECTEXTEND:=2431,SCI_VCHOMEWRAP:=2453,SCI_VCHOMEWRAPEXTEND:=2454
586 | ,SCI_LINEEND:=2314,SCI_LINEENDEXTEND:=2315,SCI_LINEENDRECTEXTEND:=2432,SCI_LINEENDDISPLAY:=2347,SCI_LINEENDDISPLAYEXTEND:=2348
587 | ,SCI_LINEENDWRAP:=2451,SCI_LINEENDWRAPEXTEND:=2452,SCI_DOCUMENTSTART:=2316,SCI_DOCUMENTSTARTEXTEND:=2317,SCI_DOCUMENTEND:=2318
588 | ,SCI_DOCUMENTENDEXTEND:=2319,SCI_PAGEUP:=2320,SCI_PAGEUPEXTEND:=2321,SCI_PAGEUPRECTEXTEND:=2433,SCI_PAGEDOWN:=2322,SCI_PAGEDOWNEXTEND:=2323
589 | ,SCI_PAGEDOWNRECTEXTEND:=2434,SCI_STUTTEREDPAGEUP:=2435,SCI_STUTTEREDPAGEUPEXTEND:=2436,SCI_STUTTEREDPAGEDOWN:=2437
590 | ,SCI_STUTTEREDPAGEDOWNEXTEND:=2438,SCI_DELETEBACK:=2326,SCI_DELETEBACKNOTLINE:=2344,SCI_DELWORDLEFT:=2335,SCI_DELWORDRIGHT:=2336
591 | ,SCI_DELLINELEFT:=2395,SCI_DELLINERIGHT:=2396,SCI_LINEDELETE:=2338,SCI_LINECUT:=2337,SCI_LINECOPY:=2455,SCI_LINETRANSPOSE:=2339
592 | ,SCI_LINEDUPLICATE:=2404,SCI_LOWERCASE:=2340,SCI_UPPERCASE:=2341,SCI_CANCEL:=2325,SCI_EDITTOGGLEOVERTYPE:=2324,SCI_NEWLINE:=2329
593 | ,SCI_FORMFEED:=2330,SCI_TAB:=2327,SCI_BACKTAB:=2328,SCI_SELECTIONDUPLICATE:=2469,SCI_SCROLLTOSTART:=2628,SCI_SCROLLTOEND:=2629
594 | ,SCI_DELWORDRIGHTEND:=2518,SCI_VERTICALCENTRECARET:=2619,SCI_MOVESELECTEDLINESUP:=2620,SCI_MOVESELECTEDLINESDOWN:=2621
595 | ,SC_TIME_FOREVER:=10000000,SC_WRAP_NONE:=0,SC_WRAP_WORD:=1,SC_WRAP_CHAR:=2,SC_WRAPVISUALFLAG_NONE:=0x0000,SC_WRAPVISUALFLAG_END:=0x0001
596 | ,SC_WRAPVISUALFLAG_START:=0x0002,SC_WRAPVISUALFLAG_MARGIN:=0x0004, SC_WRAPVISUALFLAGLOC_DEFAULT:=0x0000,SC_WRAPVISUALFLAGLOC_END_BY_TEXT:=0x0001
597 | ,SC_WRAPVISUALFLAGLOC_START_BY_TEXT:=0x0002,SC_CACHE_NONE:=0,SC_CACHE_CARET:=1,SC_CACHE_PAGE:=2,SC_CACHE_DOCUMENT:=3,EDGE_NONE:=0,EDGE_LINE:=1
598 | ,EDGE_BACKGROUND:=2,SC_CURSORNORMAL:=-1,SC_CURSORWAIT:=4,VISIBLE_SLOP:=0x01,VISIBLE_STRICT:=0x04,CARET_SLOP:=0x01,CARET_STRICT:=0x04
599 | ,CARET_JUMPS:=0x10,CARET_EVEN:=0x08,SC_SEL_STREAM:=0,SC_SEL_RECTANGLE:=1,SC_SEL_LINES:=2,SC_ALPHA_TRANSPARENT:=0,SC_ALPHA_OPAQUE:=255
600 | ,SC_ALPHA_NOALPHA:=256,KEYWORDSET_MAX:=8,SC_MOD_INSERTTEXT:=0x1,SC_MOD_DELETETEXT:=0x2,SC_MOD_CHANGESTYLE:=0x4,SC_MOD_CHANGEFOLD:=0x8
601 | ,SC_PERFORMED_USER:=0x10,SC_PERFORMED_UNDO:=0x20,SC_PERFORMED_REDO:=0x40,SC_MULTISTEPUNDOREDO:=0x80,SC_LASTSTEPINUNDOREDO:=0x100
602 | ,SC_MOD_CHANGEMARKER:=0x200,SC_MOD_BEFOREINSERT:=0x400,SC_MOD_BEFOREDELETE:=0x800,SC_MULTILINEUNDOREDO:=0x1000,SC_MODEVENTMASKALL:=0x1FFF
603 | ,SC_WEIGHT_NORMAL:=400, SC_WEIGHT_SEMIBOLD:=600, SC_WEIGHT_BOLD:=700
604 | }
605 |
606 | }
--------------------------------------------------------------------------------
/lib/uriswap.ahk:
--------------------------------------------------------------------------------
1 | uriSwap(str, action){
2 |
3 | if (action = "e"){
4 | f := A_FormatInteger
5 | SetFormat, Integer, hex
6 |
7 | ; the next two lines fix some bugs
8 | ; the first prevents literal hex code embeded in the text to be converted
9 | ; the next one prevents that a space or any other non word character that ends in 0
10 | ; converts a normal x into "hex code" e.g. h5 x20 --> h50x20x20 --> the parser sees that as:
11 | ; h5 (0x2) (0x20) and ends up like: h5%2%20 which is totally incorrect.
12 | StringReplace, str, str, 0x, ƒ, All ; remove all literal hex code before working.
13 | StringReplace, str, str, %a_space%x, ¥, All
14 |
15 | while (RegExMatch(str, "i)[^\w\.~:\/ƒ¥©]", char))
16 | {
17 | nchar := strlen(nchar:=Asc(char))<4 ? regexreplace(nchar,"(0x)(.)","${1}0${2}") : nchar
18 | StringReplace, str, str, %char%, %nchar%, All
19 | }
20 |
21 | StringReplace, str, str, 0x, `%, All
22 |
23 | ; these next two lines are the opposite of what was made in lines 18-19
24 | StringReplace, str, str, ƒ, 0x, All ; restore all literal hex code.
25 | StringReplace, str, str, ¥,%a_space%x, All
26 |
27 | SetFormat, Integer, %f%
28 | Return, str
29 | }
30 |
31 | if (action = "d"){
32 |
33 | while (RegExMatch(str, "i)(?<=%)[\da-f]{1,2}", hex))
34 | StringReplace, str, str, `%%hex%, % Chr("0x" . hex), All
35 |
36 | Return, str
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/res/AHK-TK.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/AHK-TK.ico
--------------------------------------------------------------------------------
/res/Unicode32v1.bak:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/Unicode32v1.bak
--------------------------------------------------------------------------------
/res/Unicode32v2.bak:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/Unicode32v2.bak
--------------------------------------------------------------------------------
/res/Unicode64v1.bak:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/Unicode64v1.bak
--------------------------------------------------------------------------------
/res/Unicode64v2.bak:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/Unicode64v2.bak
--------------------------------------------------------------------------------
/res/img/AHK-TK_About.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/img/AHK-TK_About.png
--------------------------------------------------------------------------------
/res/img/AHK-TK_Splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/img/AHK-TK_Splash.png
--------------------------------------------------------------------------------
/res/img/AHK-TK_UnderConstruction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the-Automator-com/AHK-ToolKit/f1c218904e37b7de08c47f01e1da71adcaafd913/res/img/AHK-TK_UnderConstruction.png
--------------------------------------------------------------------------------