Skip to content

Commit b94e0a5

Browse files
committed
Packed Bot-it to 1mb
Client will check for botit. can download and update botit
1 parent 692f32a commit b94e0a5

File tree

2 files changed

+393
-0
lines changed

2 files changed

+393
-0
lines changed

Botit Project.ahk

Lines changed: 393 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,393 @@
1+
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
2+
; #Warn ; Enable warnings to assist with detecting common errors.
3+
4+
5+
6+
IniRead,BotitLocalV,Botit\BotitCore\Update.ini,BotIt Build,BotitLocalV
7+
UpdateBotURL=https://raw.githubusercontent.com/DizzyduckAR/BotIt/master/TXT/UpdateBots.ini
8+
URLDownloadToFile,%UpdateBotURL%,UpdateBots.ini
9+
IniRead,BotitSver,UpdateBots.ini,BotIt Build,BotitSver
10+
IniRead,BotitLink,UpdateBots.ini,BotIt Build,BotitLink
11+
FileDelete,UpdateBots.ini
12+
;msgbox, % BotitLocalV BotitSver BotitLink
13+
14+
IfNotExist, %A_ScriptDir%\Botit\Botit.exe
15+
{
16+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
17+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
18+
url := "https://github.com/DizzyduckAR/BotIt/blob/master/Info%20Images/Botit_Info1.png?raw=true"
19+
Gui, Margin, 20, 20
20+
Gui New, +HwndhWndGifAnim
21+
22+
AnimatedGifControl(hWndGifAnim, url, "w600 h400")
23+
Gui Add, Button, x260 w80 h23 , &Start Download
24+
Gui Add, Button, x260 w80 h23 , &Exit
25+
gui -SysMenu
26+
Gui Show, center ,Bot-It Project
27+
28+
return
29+
30+
}
31+
32+
if (BotitLocalV < BotitSver)
33+
{
34+
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
35+
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
36+
url := "https://user-images.githubusercontent.com/52171360/77746936-fe67f180-6fda-11ea-92bc-7a5e1fedb957.png"
37+
Gui, Margin, 20, 20
38+
Gui New, +HwndhWndGifAnim
39+
40+
AnimatedGifControl(hWndGifAnim, url, "w600 h400")
41+
Gui Add, Button, x260 w80 h23 , &Start Update
42+
Gui Add, Button, x260 w80 h23 , &Skip Update
43+
gui -SysMenu
44+
Gui Show, center ,Bot-It Project
45+
46+
return
47+
}
48+
49+
if (BotitLocalV >= BotitSver)
50+
{
51+
Gosub,ButtonStart
52+
}
53+
54+
return
55+
56+
57+
esc::exitapp
58+
59+
60+
ButtonStart:
61+
IfExist, %A_ScriptDir%\Botit\Botit.exe
62+
{
63+
Run,%A_ScriptDir%\Botit\Botit.exe
64+
ExitApp
65+
66+
}
67+
return
68+
69+
ButtonExit:
70+
ExitApp
71+
72+
ButtonSkipUpdate:
73+
Gosub,ButtonStart
74+
return
75+
76+
ButtonStartDownload:
77+
Download("Core.zip", "https://github.com/DizzyduckAR/BotIt/blob/master/Core.zip?raw=true")
78+
zipname=Core.zip
79+
zipFolder=%A_ScriptDir%\Botit
80+
SmartZip(zipname,zipFolder)
81+
FileDelete,%A_ScriptDir%\Core.zip
82+
Gosub,ButtonStart
83+
84+
ButtonStartUpdate:
85+
Download("Update.zip", BotitLink)
86+
;URLDownloadToFile,%BotitLink%,Update.zip
87+
zipname=Update.zip
88+
zipFolder=%A_ScriptDir%\Botit
89+
SmartZip(zipname,zipFolder)
90+
FileDelete,%A_ScriptDir%\Update.zip
91+
Gosub,ButtonStart
92+
return
93+
94+
95+
96+
;; --------- THE FUNCTION ------------------------------------
97+
/*
98+
SmartZip()
99+
Smart ZIP/UnZIP files
100+
Parameters:
101+
s, o When compressing, s is the dir/files of the source and o is ZIP filename of object. When unpressing, they are the reverse.
102+
t The options used by CopyHere method. For availble values, please refer to: http://msdn.microsoft.com/en-us/library/windows/desktop/bb787866
103+
Link:
104+
http://www.autohotkey.com/forum/viewtopic.php?p=523649#523649
105+
*/
106+
107+
SmartZip(s, o, t = 4)
108+
{
109+
IfNotExist, %s%
110+
return, -1 ; The souce is not exist. There may be misspelling.
111+
112+
oShell := ComObjCreate("Shell.Application")
113+
114+
if (SubStr(o, -3) = ".zip") ; Zip
115+
{
116+
IfNotExist, %o% ; Create the object ZIP file if it's not exist.
117+
CreateZip(o)
118+
119+
Loop, %o%, 1
120+
sObjectLongName := A_LoopFileLongPath
121+
122+
oObject := oShell.NameSpace(sObjectLongName)
123+
124+
Loop, %s%, 1
125+
{
126+
if (sObjectLongName = A_LoopFileLongPath)
127+
{
128+
continue
129+
}
130+
ToolTip, Zipping %A_LoopFileName% ..
131+
oObject.CopyHere(A_LoopFileLongPath, t)
132+
SplitPath, A_LoopFileLongPath, OutFileName
133+
Loop
134+
{
135+
oObject := "", oObject := oShell.NameSpace(sObjectLongName) ; This doesn't affect the copyhere above.
136+
if oObject.ParseName(OutFileName)
137+
break
138+
}
139+
}
140+
ToolTip
141+
}
142+
else if InStr(FileExist(o), "D") or (!FileExist(o) and (SubStr(s, -3) = ".zip")) ; Unzip
143+
{
144+
if !o
145+
o := A_ScriptDir ; Use the working dir instead if the object is null.
146+
else IfNotExist, %o%
147+
FileCreateDir, %o%
148+
149+
Loop, %o%, 1
150+
sObjectLongName := A_LoopFileLongPath
151+
152+
oObject := oShell.NameSpace(sObjectLongName)
153+
154+
Loop, %s%, 1
155+
{
156+
oSource := oShell.NameSpace(A_LoopFileLongPath)
157+
oObject.CopyHere(oSource.Items, t)
158+
}
159+
}
160+
}
161+
162+
CreateZip(n) ; Create empty Zip file
163+
{
164+
ZIPHeader1 := "PK" . Chr(5) . Chr(6)
165+
VarSetCapacity(ZIPHeader2, 18, 0)
166+
ZIPFile := FileOpen(n, "w")
167+
ZIPFile.Write(ZIPHeader1)
168+
ZIPFile.RawWrite(ZIPHeader2, 18)
169+
ZIPFile.close()
170+
}
171+
;; --------- FUNCTION END ------------------------------------
172+
173+
174+
175+
AnimatedGifControl(GuiNameOrHwnd, GifFilePath, ControlOptions="") {
176+
Static
177+
Static CallCount := 0
178+
Local pos, ObjectName, bgColor
179+
; Create a variable name for ActiveX Object
180+
ObjectName := "WB" ++CallCount
181+
182+
; Retrieve the given image dimenstions
183+
AnimatedGifControl_GetImageDimensions(GifFilePath, GifWidth, GifHeight)
184+
if RegExMatch(ControlOptions, "O)(\s|^)(w(\d+))(\s|$)", oM) {
185+
GifWidth := oM.Value(3)
186+
StringReplace, ControlOptions, ControlOptions, % oM.Value(2), ; Remove the found option
187+
}
188+
if pos := RegExMatch(ControlOptions, "O)(\s|^)(h(\d+))(\s|$)", oM) {
189+
GifHeight := oM.Value(3)
190+
StringReplace, ControlOptions, ControlOptions, % oM.Value(2), ; Remove the found option
191+
}
192+
; Retrieve the background color option
193+
if RegExMatch(ControlOptions, "O)(\s|^)(bgc(\w{6}))(\s|$)", oM) {
194+
bgColor := oM.Value(3)
195+
StringReplace, ControlOptions, ControlOptions, % oM.Value(2), ; Remove the found option
196+
} else
197+
bgColor := AnimatedGifControl_GetSysColor(15) ;COLOR_3DFACE :Face color for three-dimensional display elements and for dialog box backgrounds.
198+
199+
; Add the Gif Animation Control
200+
Gui, %GuiNameOrHwnd%: Add, ActiveX, % "v" ObjectName " w" GifWidth " h" GifHeight " Disabled " ControlOptions, Shell.Explorer ;Mozilla.Browser
201+
%ObjectName%.Navigate("about:blank")
202+
;How Do you Stretch a Background Image in a Web Page
203+
;http://webdesign.about.com/od/css3/f/blfaqbgsize.htm
204+
%ObjectName%.Document.Write("
205+
(Ltrim
206+
<html>
207+
<header>
208+
<style type='text/css'>
209+
img#bg {
210+
position:fixed;
211+
top:0;
212+
left:0;
213+
width:100%;
214+
height:100%;
215+
}
216+
</style>
217+
<!--[if IE 6]>
218+
<![endif]-->
219+
<!--[if IE 6]>
220+
<style type='text/css'>
221+
html { overflow-y: hidden; }
222+
body { overflow-y: hidden; }
223+
img#bg { position:absolute; z-index:-1; }
224+
#content { position:static; }
225+
</style>
226+
<![endif]-->
227+
</header>
228+
<body style='height: 100%; width: 100%; margin: 0; padding: 0; overflow-x: hidden; overflow-y: hidden; background-color: #" bgColor ";' />
229+
<img src='" GifFilePath "' id='bg' />
230+
</body>
231+
</html>
232+
)")
233+
234+
%ObjectName%.Document.close
235+
%ObjectName% := "" ;release the object
236+
Return
237+
}
238+
AnimatedGifControl_GetImageDimensions(ImgPath, Byref width, Byref height) {
239+
DHW := A_DetectHiddenWIndows
240+
DetectHiddenWindows, ON
241+
Gui, AnimatedGifControl_GetImageDimensions: Add, Picture, hwndhWndImage, % ImgPath
242+
GuiControlGet, Image, AnimatedGifControl_GetImageDimensions:Pos, % hWndImage
243+
Gui, AnimatedGifControl_GetImageDimensions: Destroy
244+
DetectHiddenWindows, % DHW
245+
width := ImageW, height := ImageH
246+
}
247+
248+
AnimatedGifControl_GetSysColor(d_element) {
249+
;Thanks SKAN ;http://www.autohotkey.com/forum/post-66521.html#66521
250+
A_FI:=A_FormatInteger
251+
SetFormat, Integer, Hex
252+
BGR:=DllCall("GetSysColor"
253+
,Int,d_element)+0x1000000
254+
SetFormat,Integer,%A_FI%
255+
StringMid,R,BGR,8,2
256+
StringMid,G,BGR,6,2
257+
StringMid,B,BGR,4,2
258+
RGB := R G B
259+
StringUpper,RGB,RGB
260+
Return RGB
261+
}
262+
263+
/*
264+
by A_Samurai
265+
2012/01/25 version 1.0.5
266+
Added:
267+
- background color option: bgcNNNNNN where Ns is 6-digit RGB color value.
268+
2012/01/24 version 1.0.4
269+
Added:
270+
- image resize support
271+
2012/01/22 version 1.0.3
272+
Removed:
273+
- the ObjectName parameter
274+
2012/01/22 version 1.0.2
275+
Fixed:
276+
- a bug that does not retrieve image dimensions properly.
277+
2012/01/22 version 1.0.1
278+
Fixed:
279+
- to use IE components from Firefox.
280+
Changed:
281+
- to allow wN and hN options.
282+
2012/01/22 version 1.0.0
283+
284+
Licence: Public Domain
285+
*/
286+
Download(path_p, dLocation_p)
287+
{
288+
global path, dLocation, FullFileName, FullSize
289+
path = %path_p%
290+
dLocation = %dLocation_p%
291+
SplitPath, dLocation, FullFileName ; Splits input path to get the server filename
292+
FullSize := HttpQueryInfo(dLocation, 5) / 1000 ; get download file size in bytes
293+
Progress, H80, , Downloading..., %FullFileName% Download
294+
SetTimer, GetSize, 100
295+
UrlDownloadToFile, %dLocation%, %path%
296+
Progress, Off
297+
SetTimer, GetSize, Off
298+
Progress, Off
299+
Return
300+
}
301+
302+
GetSize:
303+
FileOpen(path, "r")
304+
FileGetSize, FSize, %path%, K ; Get local file size in kb
305+
UpdateSize := Floor((FSize / FullSize) * 100) ; get percentage
306+
IfEqual, FSize, FullSize, Return
307+
IfNotEqual, ErrorLevel, 1
308+
Progress, %UpdateSize%, %UpdateSize%`% Complete, Downloading..., %FullFileName% ;<< %FullSize is showing as 211532.604000 hence i would like to show in MB, the file is actuallly 201.73 MB
309+
Return
310+
311+
312+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
313+
;Source: post by olfen "DllCall: HttpQueryInfo - Get HTTP headers"
314+
; http://www.autohotke...4567.html#64567
315+
;
316+
; For flag info, see: http://msdn.microsof...351(VS.85).aspx
317+
318+
HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") {
319+
hModule := DllCall("LoadLibrary", "str", dll := "wininet.dll")
320+
321+
; Adapt for build by 0x150||ISO
322+
ver := ( A_IsUnicode && !RegExMatch( A_AhkVersion, "\d+\.\d+\.4" ) ? "W" : "A" )
323+
InternetOpen := dll "\InternetOpen" ver
324+
HttpQueryInfo := dll "\HttpQueryInfo" ver
325+
InternetOpenUrl := dll "\InternetOpenUrl" ver
326+
327+
If (Proxy != "")
328+
AccessType=3
329+
Else
330+
AccessType=1
331+
332+
io_hInternet := DllCall( InternetOpen
333+
, "str", ""
334+
, "uint", AccessType
335+
, "str", Proxy
336+
, "str", ProxyBypass
337+
, "uint", 0) ;dwFlags
338+
If (ErrorLevel != 0 or io_hInternet = 0) {
339+
DllCall("FreeLibrary", "uint", hModule)
340+
return, -1
341+
}
342+
343+
iou_hInternet := DllCall( InternetOpenUrl
344+
, "uint", io_hInternet
345+
, "str", url
346+
, "str", ""
347+
, "uint", 0
348+
, "uint", 0x80000000
349+
, "uint", 0)
350+
If (ErrorLevel != 0 or iou_hInternet = 0) {
351+
DllCall("FreeLibrary", "uint", hModule)
352+
return, -1
353+
}
354+
355+
VarSetCapacity(buffer, 1024, 0)
356+
VarSetCapacity(buffer_len, 4, 0)
357+
358+
Loop, 5
359+
{
360+
hqi := DllCall( HttpQueryInfo
361+
, "uint", iou_hInternet
362+
, "uint", QueryInfoFlag
363+
, "uint", &buffer
364+
, "uint", &buffer_len
365+
, "uint", 0)
366+
If (hqi = 1) {
367+
hqi=success
368+
break
369+
}
370+
}
371+
372+
IfNotEqual, hqi, success, SetEnv, res, timeout
373+
374+
If (hqi = "success") {
375+
p := &buffer
376+
Loop
377+
{
378+
l := DllCall("lstrlen", "UInt", p)
379+
VarSetCapacity(tmp_var, l+1, 0)
380+
DllCall("lstrcpy", "Str", tmp_var, "UInt", p)
381+
p += l + 1
382+
res := res . tmp_var
383+
If (*p = 0)
384+
Break
385+
}
386+
}
387+
388+
DllCall("wininet\InternetCloseHandle", "uint", iou_hInternet)
389+
DllCall("wininet\InternetCloseHandle", "uint", io_hInternet)
390+
DllCall("FreeLibrary", "uint", hModule)
391+
392+
return, res
393+
}

Botit Project.exe

868 KB
Binary file not shown.

0 commit comments

Comments
 (0)