Skip to content

Instantly share code, notes, and snippets.

@masecla22
Last active May 5, 2018 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masecla22/6a632b5a1f18937f480947208e940384 to your computer and use it in GitHub Desktop.
Save masecla22/6a632b5a1f18937f480947208e940384 to your computer and use it in GitHub Desktop.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>
#include <Array.au3>
#include <Inet.au3>
Func FileSelector()
Local Const $sMessage = "Choose a PATH to install the libraries to"
Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
If @error Then
return -1
Else
return @CRLF&$sFileSelectFolder
EndIf
EndFunc
#Region ### START Koda GUI section ### Form=C:\Users\super\Desktop\Form1.kxf
$Form1_1 = GUICreate("Matt Libraries AutoUpdater", 484, 339, 330, 165)
GUISetFont(20, 400, 0, "Yu Gothic UI Light")
$Label1 = GUICtrlCreateLabel("What library do you want installed?", 48, 16, 396, 41)
$Button1 = GUICtrlCreateButton("mattcore.h", 18, 88, 83, 73)
GUICtrlSetFont(-1, 12, 400, 0, "Yu Gothic UI Light")
$Button2 = GUICtrlCreateButton("mattgui.h", 112, 88, 83, 73)
GUICtrlSetFont(-1, 12, 400, 0, "Yu Gothic UI Light")
$Button6 = GUICtrlCreateButton("mattmark.h", 300, 88, 83, 73)
GUICtrlSetFont(-1, 12, 400, 0, "Yu Gothic UI Light")
$Button7 = GUICtrlCreateButton("mattunit.h", 394, 88, 83, 73)
GUICtrlSetFont(-1, 12, 400, 0, "Yu Gothic UI Light")
$Button3 = GUICtrlCreateButton("mattsets.h", 206, 88, 83, 73)
GUICtrlSetFont(-1, 12, 400, 0, "Yu Gothic UI Light")
$Button4 = GUICtrlCreateButton("Open github", 128, 176, 83, 73)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Button5 = GUICtrlCreateButton("Install All", 232, 176, 83, 73)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Checkbox1 = GUICtrlCreateRadio("Install in CodeBlocks", 18, 292, 129, 17)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Label2 = GUICtrlCreateLabel("Requires Admin!", 42, 308, 86, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Checkbox2 = GUICtrlCreateRadio("Custom path",154,292,90,20)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Button10 = GUICtrlCreateButton("...",430,291,20,22)
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
$Input1 = GUICtrlCreateInput("",250,292,180,20,BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 9, 400, 0, "Yu Gothic UI Light")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#comments-start
StringRegExpReplace($test,"<[^<]*>","")
#comments-end
Func Format($string)
$string1 = StringSplit($string,"")
For $i = 1 to $string1[0]
if $string1[$i]=='\' Then
$string1[$i]='>'
EndIf
Next
_ArrayDelete($string1,0)
_ArrayDelete($string1,1)
return _ArrayToString($string1,"")
EndFunc
Func _GetNetworkConnect()
Local Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection
Local Const $NETWORK_ALIVE_WAN = 0x2 ;RAS (internet) connection
Local Const $NETWORK_ALIVE_AOL = 0x4 ;AOL
Local $aRet, $iResult
$aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0)
If BitAND($aRet[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
If BitAND($aRet[1], $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF
Return $iResult
EndFunc
func download($url,$file,$onCodeBlocks,$customPath,$path=0)
MsgBox(1,$onCodeBlocks,$customPath&" "&$path)
local $string=_INetGetSource($url)
if($onCodeBlocks==1 And $customPath==4) Then
if(FileExists("C:\Program Files (x86)\CodeBlocks\MinGW\include"&"\"&$file)) Then
local $choiiice=MsgBox(4,"Warning!","This will overwrite the current library! Procced?")
if($choiiice==$IDYES) Then
FileDelete("C:\Program Files (x86)\CodeBlocks\MinGW\include"&"\"&$file)
FileWrite("C:\Program Files (x86)\CodeBlocks\MinGW\include"&"\"&$file,$string)
Else
MsgBox(0,"Failed!","Operation failed!")
EndIf
Else
FileWrite("C:\Program Files (x86)\CodeBlocks\MinGW\include"&"\"&$file,$string)
EndIf
EndIf
if($onCodeBlocks==4 and $customPath==1) Then
if(FileExists($file)) Then
local $chh=MsgBox(4,"Warning!","This will overwrite the current library! Procced?")
if($chh==$IDYES) Then
FileDelete($path&"\"&$file)
FileWrite($path&"\"&$file,$string)
Else
MsgBox(0,"Failed!","Operation failed!")
EndIf
Else
FileWrite($path&"\"&$file,$string)
EndIf
EndIf
if($onCodeBlocks==4 And $customPath==4) Then
FileWrite($file,$string)
EndIf
EndFunc
$connect = _GetNetworkConnect()
$path=0
$ff = 0
If $connect Then
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattcore.h","mattcore.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
Case $Button2
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattgui.h","mattgui.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
Case $Button3
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattsets.h","mattsets.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
Case $Button6
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattmark.h","mattmark.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
Case $Button7
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattunit.h","mattunit.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
Case $Button4
ShellExecute("https://www.github.com/masecla22")
Case $Button10
$path = FileSelector()
$ff = $path
GUICtrlSetData($Input1,Format($path))
Case $Button5
local $choice=MsgBox(4,"Confirm","Are you sure? This will download a library which will take up some space and use some mobile data!")
if($choice==$IDYES) Then
$chhoice=GUICtrlRead($Checkbox1)
$hasPath=GUICtrlRead($Checkbox2)
$path = GUICtrlRead($Input1)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattgui.h","mattgui.h",$chhoice,$hasPath,$ff)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattsets.h","mattsets.h",$chhoice,$hasPath,$ff)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattcore.h","mattcore.h",$chhoice,$hasPath,$ff)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattunit.h","mattunit.h",$chhoice,$hasPath,$ff)
download("https://raw.githubusercontent.com/masecla22/libraries/master/mattmark.h","mattmark.h",$chhoice,$hasPath,$ff)
MsgBox(0,"Completed","Operation completed!")
EndIf
EndSwitch
WEnd
Else
GUISetState(@SW_HIDE)
MsgBox(48, "Warning", "No Internet Connection Detected!")
EndIf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment