Jump to content

Quick Download Tool


wolf9228
 Share

Recommended Posts

;The quick download tool surpasses the speed of the most powerful applications that feature
;multiple download of the same file ... the Url must be direct ... Thanks.

;Note the tool does not work on Windows servers

;Url to experiment

;https://download.microsoft.com/download/8/1/d/81d1f546-f951-45c5-964d-56bdbd758ba4/w2k3sp2_3959_usa_x64fre_spcd.iso

The tool is faster than all programs, but the tool list should be changed to 1 KB each loop for those who want to experiment to do so.

Quick Download Tool.zip

 

;The quick download tool surpasses the speed of the most powerful applications that feature
;multiple download of the same file ... the link must be direct ... Thanks.

;Note the tool does not work on Windows servers

;https://download.microsoft.com/download/8/1/d/81d1f546-f951-45c5-964d-56bdbd758ba4/w2k3sp2_3959_usa_x64fre_spcd.iso



#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Untitled.ico
#AutoIt3Wrapper_Res_File_Add=NORMAL1.bmp,2,NORMAL,0
#AutoIt3Wrapper_Res_File_Add=PRESS1.bmp,2,PRESS,0
#AutoIt3Wrapper_Res_File_Add=OVER1.bmp,2,OVER,0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

$OSVersion = @OSVersion
$BOOl = $OSVersion == "WIN_81" Or $OSVersion == "WIN_8" Or $OSVersion == "WIN_7" Or _
$OSVersion == "WIN_VISTA" Or $OSVersion == "WIN_XP" Or $OSVersion == "WIN_XPe" Or $OSVersion == "WIN_10"
if Not $BOOl Then
MsgBox(48,"Notice","The program is not intended to run on this system",10)
Exit
EndIf

Global $HIntOpen = 0 , $Connect = 0 , $OriginalUrl = "" , $ThreadArray = 0,$FileA = "" , $BytesAtaTime = 4096
Global $OpenRequest = 0  ,  $Combo1 = 0  ,  $Winhttp = 0  ,  $PtrSize = 4  ,  $FileSize = 0  , $DwordSize = 4
Global $idLabe3 = 0,$idLabe4 = 0 , $idLabel = 0,$ButtonA = 0,$ButtonE = 0,$Progress = 0,$HGui= 0,$ButtonD = 0
Global $ButtonA = 0 , $ButtonB = 0 , $ButtonC = 0 ,$DownloadDir = @MyDocumentsDir,$Label2=0,$lpszHostName = 0
Global $NotifyStruct =  0   , $TagNotifyStruct = "" , $ProgressLoop = False , $DISPOSITION = "" , $szPath = 0
Global $MaxInt =  2147483647  , $InputBoxUrl = "" ,  $hLockDataPtr = 0  ,  $hFile = 0
Global $tagInfoSt = "INT StrLenA;INT StrLenB;INT ProcessID;INT Complete;INT Pause;" & _
"INT Error;INT MovePos;INT BytesAtaTime;INT FileSize;INT Cancel;PTR UrlA;PTR UrlB;" & _
"INT TimeNu;INT  Remder;INT TimeNuPos;PTR FileName;INT StrLenC;PTR hFile;PTR FDir;" & _
"INT NuOfBytesRead;INT NuOfBytesWn;INT vBytesAtaTime;INT ContlThread;INT vContlThread"
Global $WinhttphModule=0,$WriteFile=0,$CloseHandle=0,$WinHttpReadData=0,$WinHttpCloseHandle = 0
Global $xFileSize = 0 , $xOriginalUrl = "" , $NewSize1 = 0 , $DwnhFile = 0 , $DwnhFilePatch = ""

Global $URL_COMPONENTS = 0
Global Const $GENERIC_EXECUTE = 0x20000000
Global Const $GENERIC_READ = 0x80000000
Global Const $GENERIC_WRITE = 0x40000000
Global Const $FILE_SHARE_DELETE = 0x00000004
Global Const $FILE_SHARE_READ = 0x00000001
Global Const $FILE_SHARE_WRITE = 0x00000002
Global Const $FILE_ATTRIBUTE_ARCHIVE = 0x00000020
Global Const $FILE_ATTRIBUTE_HIDDEN = 0x00000002
Global Const $FILE_ATTRIBUTE_READONLY = 0x00000001
Global Const $FILE_ATTRIBUTE_SYSTEM = 0x00000004
Global Const $CREATE_NEW = 1
Global Const $CREATE_ALWAYS = 2
Global Const $OPEN_EXISTING = 3
Global Const $OPEN_ALWAYS = 4
Global Const $TRUNCATE_EXISTING = 5
Global $GUI_DISABLE = 128
Global $GUI_ENABLE = (64)
Global Const $SS_CENTERIMAGE = 0x0200
Global $WS_BORDER = 0x00800000
Global Const $SS_CENTER = 0x1
Global $CBS_DROPDOWNLIST = 0x0003
Global $WS_VSCROLL = 0x00200000
Global Const $CBN_SELCHANGE = 1
Global Const $BN_CLICKED = 0
Global Const $GUI_EVENT_CLOSE = -3
Global $WM_NOTIFY = 0x004E
Global $WM_COMMAND = 0x0111
Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'
Global Const $INVALID_HANDLE_VALUE = Ptr(-1)
Global Const $ES_LEFT = 0
Global Const $ES_AUTOHSCROLL = 128
Global Const $GUI_BKCOLOR_TRANSPARENT = -2
Global Const $RDW_INVALIDATE = 0x0001
Global Const $RDW_UPDATENOW = 0x0100

Global $PointerSize = 4 , $ControlThread = DllStructCreate("INT TA;INT TB;INT TC")
Global $User32Dll = _WinAPI_LoadLibrary("User32.dll"), $AsmVar = DllStructCreate("INT LOOP;PTR PtrAtPos;HWND CurrentHwnd")
Global $StructButtonHover =  0   ,  $StructBHover   =   DllStructCreate( "INT  COUNT;PTR  BHOVER" )  ,  $StructBHSize = 32
Global $Kernel32dll  =  _WinAPI_LoadLibrary(  "Kernel32.dll"  )   ,  $StructBHoverPtr = DllStructGetPtr(  $StructBHover  )
Global $_GtPt=_WinAPI_GetProcAddress($User32Dll,"GetParent"),$_WnFPos=_WinAPI_GetProcAddress($User32Dll,"WindowFromPoint")
Global $SdMsg =_WinAPI_GetProcAddress($User32Dll,"SendMessageW"),$RiWin =_WinAPI_GetProcAddress($User32Dll,"RedrawWindow")
Global $G_CP =_WinAPI_GetProcAddress($User32Dll,"GetCursorPos"),$GKYState=_WinAPI_GetProcAddress($User32Dll,"GetKeyState")
Global $Sleep =_WinAPI_GetProcAddress($Kernel32dll,"Sleep") ,$PositionsSt = DllStructCreate("INT POS[2]") , $ThreadPtr = 0
Global $NewStructButtonHover= 0,$PositionsStPtr= DllStructGetPtr($PositionsSt),$IsPss = LIsPress(),$IsNPss = LIsNotPress()
Global $IsPssPtr = DllStructGetPtr($IsPss) , $IsNPssPtr = DllStructGetPtr($IsNPss),$MHover = LMHover(),$MNHover=LMNHover()
Global $MHoverPtr = DllStructGetPtr( $MHover ) ,  $MNHoverPtr = DllStructGetPtr( $MNHover )  ,  $ThreadAdd = LoadThread( )

if @Compiled Then
$NORMAL_hBMP = LoadBitmap_FromResources("NORMAL")
$PRESS_hBMP = LoadBitmap_FromResources("PRESS")
$OVER_hBMP = LoadBitmap_FromResources("OVER")
Else
$NORMAL_hBMP = LoadBitmap_FromFile("NORMAL1.bmp")
$PRESS_hBMP = LoadBitmap_FromFile("PRESS1.bmp")
$OVER_hBMP = LoadBitmap_FromFile("OVER1.bmp")
EndIf

$HGui = GUICreate(" Quick Download Tool ",831,180,10,200)
GUISetBkColor(7237230)
$ButtonA = CreateButtonHover ("Add Url", 5, 5,100, 35,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
$ButtonB = CreateButtonHover ("Download", 675 + 50, 5,100, 35,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("",112, 10, 607, 30,BitOR($SS_CENTERIMAGE,$WS_BORDER,0x1000),0x00000200)
GUICtrlSetBkColor($Label2,0xFFFFFF)
$idLabel = GUICtrlCreateLabel("",530,50,296,35,BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER,0x1000),0x00000200)
GUICtrlSetBkColor($idLabel, 0xFFFFFF)
$idLabe3 = GUICtrlCreateLabel("",530,94,295,35,BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER,0x1000),0x00000200)
GUICtrlSetBkColor($idLabe3, 0xFFFFFF)
$sVar = RegRead("HKEY_CURRENT_USER\Software\Download","DownloadDir")
if @error Then
RegWrite("HKEY_CURRENT_USER\Software\Download", "DownloadDir", "REG_SZ", $DownloadDir)
Else
if FileExists($sVar) Then
$DownloadDir = $sVar
Else
RegWrite("HKEY_CURRENT_USER\Software\Download", "DownloadDir", "REG_SZ", $DownloadDir)
EndIf
EndIf
$vidLabe = GUICtrlCreateLabel("",5,137,519,35,BitOR($SS_CENTERIMAGE,$WS_BORDER,0x1000),0x00000200)
GUICtrlSetBkColor($vidLabe, 0xFFFFFF)
GUICtrlSetData($vidLabe,$DownloadDir)
$Grb = GUICtrlCreateGroup("",530,130,295, 47)
$Combo1 = GUICtrlCreateCombo("",535,143,285, 35,BitOR($CBS_DROPDOWNLIST,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetOnEventEx($Combo1,$CBN_SELCHANGE,"SELCHANGE")
$Text = ""
$Text &= " downloding " & 1 & " KB in every Loop " & "|"
For $i = 2 To 1024 Step 2
$Text &= " downloding " & $i & " KB in every Loop " & "|"
Next
GUICtrlSetData ($Combo1,$Text," downloding " & 4 & " KB in every Loop ")
$Progress = GUICtrlCreateProgress(5, 50, 519, 36)
$ButtonC = CreateButtonHover ("Stop", 100, 94,100, 35,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
GUICtrlSetOnEventEx($ButtonC,$BN_CLICKED,"ButtonC")
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
$ButtonD = CreateButtonHover ("Select", 205, 95,120, 35,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
$ButtonE = CreateButtonHover ("Cancel", 5, 94,90, 35,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
$idLabe4 = GUICtrlCreateLabel("",330,94,193,35,BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER,0x1000),0x00000200)
GUICtrlSetBkColor($idLabe4, 0xFFFFFF)
GUISetState(@SW_SHOW)
GUISwitch($HGui)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $ButtonA
ButtonA()
Case $ButtonB
ButtonB()
Case $ButtonC
;ButtonC()
Case $ButtonD
ButtonD()
Case $ButtonE
ButtonE()
EndSwitch
WEnd
GUIDelete($HGui)
Exit

Func GUICtrl_SetState($Id,$State)
GUICtrlSetState($Id,$State)
GUICtrlSetState($Id - 1,$State)
EndFunc

Func ButtonA()
$Pos = WinGetPos($HGui)
$GuiH2 = GUICreate("Url input box",831,132,$Pos[0],$Pos[1],-1,-1,$HGui)
GUISetBkColor(0x747474)
$Label3 = GUICtrlCreateLabel("Url input box",265,8,300,30,BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetColor($Label3, 0xFFFFFF)
$Input12 = GUICtrlCreateInput("",5,5 + 40,819,30,BitOR($WS_BORDER,$ES_LEFT,$ES_AUTOHSCROLL),BitOR(0x00000200,0x00020000))
$ButtonA2 = CreateButtonHover("OK",315,45 + 45,90, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
$ButtonB2 = CreateButtonHover("Cancel",415,45 + 45,90, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,0xFFFFFF)
GUISetState(@SW_SHOW)
GUISwitch($GuiH2)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE  , $ButtonB2
DeleteButtonHover($ButtonA2)
DeleteButtonHover($ButtonB2)
GUIDelete($GuiH2)
GUISwitch($HGui)
ExitLoop
Case $ButtonA2
$ProgressLoop = False
$InputBox = GUICtrlRead($Input12)
DeleteButtonHover($ButtonA2)
DeleteButtonHover($ButtonB2)
GUIDelete($GuiH2)
GUISwitch($HGui)
if StringLen($InputBox) Then
$InputBoxUrl = StringStripWS($InputBox,1 + 2)
GUICtrl_SetState($ButtonA,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_DISABLE)
$Return = NewThreadA($InputBoxUrl)
if Not @error Or @error = 6 Then
GUICtrlSetData($Label2,$OriginalUrl)
$xFileSize = $FileSize
$xOriginalUrl = $OriginalUrl
if $FileSize <> 0 Then
Select
Case $FileSize < (1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize,15) & " Byte ")
Case $FileSize < (1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 ,15) & " Kilo Byte ")
Case $FileSize < (1024 * 1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 ,15) & " Mega Byte ")
Case $FileSize < (1024 * 1024 * 1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 / 1024 ,15) & " Giga Byte ")
Case Else
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 / 1024 / 1024 ,15) & " Terra Byte ")
EndSelect
Else
GUICtrlSetData($idLabel," Unknown File size ")
EndIf
GUICtrl_SetState($ButtonB,$GUI_ENABLE)
GUICtrl_SetState($ButtonE,$GUI_ENABLE)
WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0
Else
Local $Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0
ErrorFunc($Error,2)
EndIf
EndIf
ExitLoop
EndSwitch
WEnd
EndFunc

Func ButtonB()

GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrlSetState($Combo1,$GUI_DISABLE)

$Return = NewThreadA($InputBoxUrl)
if Not @error Or @error = 6 Then
GUICtrlSetData($Label2,$OriginalUrl)
if $FileSize <> 0 Then
Select
Case $FileSize < (1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize,15) & " Byte ")
Case $FileSize < (1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 ,15) & " Kilo Byte ")
Case $FileSize < (1024 * 1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 ,15) & " Mega Byte ")
Case $FileSize < (1024 * 1024 * 1024 * 1024)
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 / 1024 ,15) & " Giga Byte ")
Case Else
GUICtrlSetData($idLabel," File size " & StringLeft($FileSize /1024 / 1024 / 1024 / 1024 ,15) & " Terra Byte ")
EndSelect
Else
GUICtrlSetData($idLabel," Unknown File size ")
EndIf

if $FileSize <> $xFileSize Or Not $xOriginalUrl == $OriginalUrl Then
$Return = MsgBox(4 + 48,"Notice"," The download file has been modified, and from its source, do you want to download the file after modification? ",20,$HGui)
if $Return = 7 Or $Return = -1 Then
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0
Return
EndIf
WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0
$xFileSize = $FileSize
$xOriginalUrl = $OriginalUrl
ButtonB()
Return
EndIf

WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0

Else
Local $Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
WinHttpCloseHandle($OpenRequest)
WinHttpCloseHandle($Connect)
WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$ThreadArray = 0
ErrorFunc($Error,2)
Return
EndIf



if $FileSize = 0 Then
$ProgressLoop = False
$NewSize1 = 0
$Return = NewThreadB($InputBoxUrl)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadB()
ErrorFunc($Error,2)
Return
EndIf

GUICtrlSetData($Label2,$OriginalUrl)

$Return = ProgressLoopB()
if $Return Then
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadB()
GUICtrlSetData($Label2," Download completed ")
Return
Else
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadB()
ErrorFunc($Error,1)
Return
EndIf
EndIf

Local $MB = 1048576  , $NewSize = 0

Select
Case $FileSize >= ($MB * 8)
$Remainder = Mod($FileSize,8)
$NewSize = (($FileSize - $Remainder) / 8)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 7)
$Remainder = Mod($FileSize,7)
$NewSize = (($FileSize - $Remainder) / 7)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 6)
$Remainder = Mod($FileSize,6)
$NewSize = (($FileSize - $Remainder) / 6)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 5)
$Remainder = Mod($FileSize,5)
$NewSize = (($FileSize - $Remainder) / 5)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 4)
$Remainder = Mod($FileSize,4)
$NewSize = (($FileSize - $Remainder) / 4)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 3)
$Remainder = Mod($FileSize,3)
$NewSize = (($FileSize - $Remainder) / 3)
$NewSize1 = $NewSize + $Remainder
Case $FileSize >= ($MB * 2)
$Remainder = Mod($FileSize,2)
$NewSize = (($FileSize - $Remainder) / 2)
$NewSize1 = $NewSize + $Remainder
Case Else
$NewSize1 = $FileSize
EndSelect

$FreeSpace = DriveSpaceFree ($DownloadDir)
if $FreeSpace < ($FileSize / 1048576) + ($NewSize1 / 1048576) Then
if @error Then
MsgBox(48,"Notice","The download folder partition could not be accessed",0,$HGui)
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
Return
Else
MsgBox(48,"Notice","There is no space for downloaded files on the Download folder partition",0,$HGui)
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
Return
EndIf
EndIf

$FreeSpace = DriveSpaceFree (@SystemDir)
if $FreeSpace < ($FileSize / 1048576) + ($NewSize1 / 1048576) Then
MsgBox(48,"Notice","There is no space for the download process on the system partition",0,$HGui)
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
Return
EndIf


Select
Case $FileSize >= ($MB * 8)

$Remainder = Mod($FileSize,8)
$NewSize = (($FileSize - $Remainder) / 8)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 7)
$Remainder = Mod($FileSize,7)
$NewSize = (($FileSize - $Remainder) / 7)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 6)
$Remainder = Mod($FileSize,6)
$NewSize = (($FileSize - $Remainder) / 6)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 5)
$Remainder = Mod($FileSize,5)
$NewSize = (($FileSize - $Remainder) / 5)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 4)
$Remainder = Mod($FileSize,4)
$NewSize = (($FileSize - $Remainder) / 4)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 3)
$Remainder = Mod($FileSize,3)
$NewSize = (($FileSize - $Remainder) / 3)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer += $NewSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case $FileSize >= ($MB * 2)
$Remainder = Mod($FileSize,2)
$NewSize = (($FileSize - $Remainder) / 2)
$NewSize1 = $NewSize + $Remainder
$ProgressLoop = False

$Pointer = 0
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize1)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

$Pointer = $NewSize1
$Return = NewThreadA($InputBoxUrl,$Pointer,$NewSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

Case Else

$Pointer = 0
$ProgressLoop = False
$NewSize1 = $FileSize
$Return = NewThreadA($InputBoxUrl,$Pointer,$FileSize)
if @error Then
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,2)
Return
EndIf

EndSelect

GUICtrlSetData($Label2,$OriginalUrl)
$Return = ProgressLoopA()
if $Return Then

GUICtrlSetData($Progress,0)
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetData($ButtonC,"Stop grouping")

Local $nFileName = "" , $Extension = ""
if StringLen($DISPOSITION) Then
$zFileName = $DISPOSITION
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,(StringLen($zFileName) - StringLen($Extension)))
Else
$zFileName = StringSplit($OriginalUrl,"/")
$zFileName = $zFileName[$zFileName[0]]
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,(StringLen($zFileName) - StringLen($Extension)))
EndIf

DirCreate($DownloadDir)
Local $i = 1
$DwnhFilePatch = $DownloadDir & "\" & $nFileName & $Extension
While FileExists($DwnhFilePatch)
$DwnhFilePatch = $DownloadDir & "\" & $nFileName & "(" & $i & ")" & $Extension
If $ProgressLoop Then ExitLoop
$i += 1
WEnd

if $ProgressLoop Then
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
GUICtrlSetData($ButtonC,"Stop")
GUICtrlSetState($Combo1,$GUI_ENABLE)
Return
EndIf

$DwnhFile = _WinAPI_CreateFile($DwnhFilePatch,0)
if Not($DwnhFile) Then
MsgBox(16,"Error","file cannot be created in the download folder",0,$HGui)
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
GUICtrlSetData($ButtonC,"Stop")
GUICtrlSetState($Combo1,$GUI_ENABLE)
Return
EndIf

Local $nMovePos = 0 , $FArray[UBound($ThreadArray)][3] , $ExitLoop = False
For $i = 0 To UBound($ThreadArray) - 1
$TempFile = $ThreadArray[$i][4]
$TempFileSize = FileGetSize($TempFile)
$nhFile = _WinAPI_CreateFile($TempFile,2,2)
if Not ($nhFile) Or $ProgressLoop Then
if Not ($nhFile) Then MsgBox(16,"Error","The spool file could not be opened",0,$HGui)
For $j = 0 To UBound($FArray) - 1
if ($FArray[$j][0]) Then _WinAPI_CloseHandle($FArray[$j][0])
Next
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrlSetState($ButtonA,$GUI_ENABLE)
GUICtrlSetState($ButtonB,$GUI_DISABLE)
GUICtrlSetState($ButtonE,$GUI_DISABLE)
GUICtrlSetState($ButtonC,$GUI_DISABLE)
GUICtrlSetState($ButtonD,$GUI_ENABLE)
_WinAPI_CloseHandle($DwnhFile)
FileDelete($DwnhFilePatch)
CloseAllThreadA()
GUICtrlSetState($Combo1,$GUI_ENABLE)
GUICtrlSetData($ButtonC,"Stop")
Return
EndIf
$FArray[$i][0] = $nhFile
$FArray[$i][1] = $TempFileSize
$FArray[$i][2] = $TempFile
Next

For $i = 0 To UBound($FArray) - 1
$nhFile = $FArray[$i][0]
$TempFileSize = $FArray[$i][1]
$FileA = $FArray[$i][2]
if $ExitLoop Then ExitLoop
Local $CopySize = 1048576
$BufferSt = DllStructCreate("BYTE[" & $CopySize & "]")
$BufferStPtr = DllStructGetPtr($BufferSt)
WatNextB(" Parts of the file are being collected ")
While 1
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
if $ProgressLoop Then
$ExitLoop = True
ExitLoop
EndIf
Local $nBytesA = 0 , $nBytesB = 0
if $TempFileSize < $CopySize Then $CopySize = $TempFileSize
$FreeSpace = DriveSpaceFree ($DownloadDir)
if $FreeSpace <= ($nMovePos / 1048576) + ($NewSize1 / 1048576) Then
if @error Then
ErrorFunc($Error,14)
Else
ErrorFunc($Error,12)
EndIf
$ExitLoop = True
ExitLoop
EndIf
_WinAPI_ReadFile($nhFile,$BufferStPtr,$CopySize,$nBytesA)
_WinAPI_WriteFile($DwnhFile,$BufferStPtr,$nBytesA,$nBytesB)
$nMovePos += $nBytesB
Local $Text = ""
Select
Case $FileSize >= (1024 * 1024 * 1024 * 1024)
Select
Case $nMovePos < 1024
$Text = "" & StringLeft($nMovePos,7) & " Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $nMovePos < (1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024,7) & " Kilo Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $nMovePos < (1024 * 1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $nMovePos < (1024 * 1024 * 1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024 / 1024 / 1024,7) & " Giga Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case Else
$Text = "" & StringLeft($nMovePos / 1024 / 1024 / 1024 / 1024,7) & " Terra Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
EndSelect
Case $FileSize >= (1024 * 1024 * 1024)
Select
Case $nMovePos < 1024
$Text = "" & StringLeft($nMovePos,7) & " Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $nMovePos < (1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $nMovePos < (1024 * 1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $nMovePos < (1024 * 1024 * 1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024 / 1024 / 1024,7) & " Giga Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
EndSelect
Case $FileSize >= (1024 * 1024)
Select
Case $nMovePos < 1024
$Text = "" & StringLeft($nMovePos,7) & " Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
Case $nMovePos < (1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
Case $nMovePos < (1024 * 1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
EndSelect
Case $FileSize >= (1024)
Select
Case $nMovePos < 1024
$Text = "" & StringLeft($nMovePos,7) & " Byte From " & StringLeft($FileSize / 1024,7) &  " Kilo Byte "
Case $nMovePos < (1024 * 1024)
$Text = "" & StringLeft($nMovePos / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024,7) &  " Kilo Byte "
EndSelect
Case $FileSize >= 1
$Text = "" & StringLeft($nMovePos,7) & " Byte From " & StringLeft($FileSize,7) &  " Byte "
EndSelect
GUICtrlSetData($Progress,(100 / $FileSize) * $nMovePos)
GUICtrlSetData($idLabe3,$Text)
Sleep(75)
$Text = StringLeft((($nMovePos / $FileSize) * 100),4)
$Text =  " compiled "  & $Text & "%"
GUICtrlSetData($idLabe4,$Text)
$TempFileSize -= $nBytesB
if $TempFileSize = 0 Then ExitLoop
WEnd

_WinAPI_CloseHandle($nhFile)
WatNextB(" Deleting the temporary file ")
FileDelete($FileA)

Next

_WinAPI_CloseHandle($DwnhFile)
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)

CloseAllThreadA()
if Not ($ExitLoop) Then
GUICtrlSetData($Label2," Download completed ")
Else
FileDelete($DwnhFilePatch)
EndIf
GUICtrlSetState($Combo1,$GUI_ENABLE)
GUICtrlSetData($ButtonC,"Stop")
$DwnhFile = 0
Return

Else
$Error = @error
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrlSetData($Progress,0)
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
CloseAllThreadA()
ErrorFunc($Error,1)
GUICtrlSetData($ButtonC,"Stop")
GUICtrlSetState($Combo1,$GUI_ENABLE)
Return
EndIf
EndFunc

Func ButtonC($ControlID,$NotificationCode)
$ProgressLoop = True
EndFunc

Func SELCHANGE($ControlID,$NotificationCode)
$Text = StringReplace(GUICtrlRead($Combo1)," downloding ","")
$Text = StringReplace($Text," KB in every Loop ","")
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($ButtonC,$GUI_DISABLE)
$BytesAtaTime = Int($Text) * 1024
if IsArray($ThreadArray) Then
For $i = 0 To UBound($ThreadArray) - 1
$InfoStruct = $ThreadArray[$i][6]
$hThread = $ThreadArray[$i][8]
if IsDllStruct($InfoStruct) Then
if $hThread And DllStructGetData($InfoStruct,"Complete") = 0 Then
DllStructSetData($InfoStruct,"vContlThread",0)
DllStructSetData($InfoStruct,"ContlThread",1)
While 1
if DllStructGetData($InfoStruct,"Complete") Or _
DllStructGetData($InfoStruct,"vContlThread") Then ExitLoop
WatNextA(" The new setting is taking effect ")
WEnd
DllStructSetData($InfoStruct,"BytesAtaTime",$BytesAtaTime)
DllStructSetData($InfoStruct,"vBytesAtaTime",$BytesAtaTime)
DllStructSetData($InfoStruct,"ContlThread",0)
DllStructSetData($InfoStruct,"vContlThread",0)
Else
DllStructSetData($InfoStruct,"BytesAtaTime",$BytesAtaTime)
DllStructSetData($InfoStruct,"vBytesAtaTime",$BytesAtaTime)
EndIf
EndIf
Next
EndIf
GUICtrlSetState($ButtonC,$GUI_ENABLE)
GUICtrlSetState($Combo1,$GUI_ENABLE)
GUICtrlSetData($Label2,$OriginalUrl)
EndFunc

Func ButtonD()
$path = SelectFolder(" Select download folder ",$HGui)
if Not @error And FileExists($path) Then
RegWrite("HKEY_CURRENT_USER\Software\Download", "DownloadDir", "REG_SZ",$path)
$DownloadDir = $path
GUICtrlSetData($vidLabe,$DownloadDir)
Else
if Not @error Then MsgBox(48,"Notice"," It is not possible to download to this path ",0,$HGui)
EndIf
EndFunc

Func SelectFolder($Title,$HWND)
$tag_browseinfo = "HWND hwndOwner;PTR pidlRoot;PTR pszDisplayName;" & _
"PTR lpszTitle;UINT ulFlags;PTR lpfn;PTR lParam;int iImage"
$pszDisplayName = DllStructCreate("WCHAR[260]")
$lpszTitle = DllStructCreate("WCHAR[100]")
DllStructSetData($lpszTitle,1,$Title)
$browseinfo = DllStructCreate($tag_browseinfo)
DllStructSetData($browseinfo,"hwndOwner",$HWND)
DllStructSetData($browseinfo,"pszDisplayName",DllStructGetPtr($pszDisplayName))
DllStructSetData($browseinfo,"lpszTitle",DllStructGetPtr($lpszTitle))
DllStructSetData($browseinfo,"ulFlags",BitOR(0x00000002,0x00000040))
$PIDLIST_ABSOLUTE = DllCall("Shell32.dll","long","SHBrowseForFolderW","ptr",DllStructGetPtr($browseinfo))
if @error Or Not $PIDLIST_ABSOLUTE[0] Then Return SetError(1,0,"")
$pszPath = DllStructCreate("WCHAR[260]")
$Return = DllCall("Shell32.dll","BOOL","SHGetPathFromIDListW","ptr",$PIDLIST_ABSOLUTE[0],"ptr",DllStructGetPtr($pszPath))
Return SetError(0,0,DllStructGetData($pszPath,1))
EndFunc

Func ButtonE()
GUICtrlSetData($Label2,"")
GUICtrlSetData($idLabel,"")
GUICtrlSetData($idLabe3,"")
GUICtrlSetData($idLabe4,"")
GUICtrl_SetState($ButtonA,$GUI_ENABLE)
GUICtrl_SetState($ButtonB,$GUI_DISABLE)
GUICtrl_SetState($ButtonE,$GUI_DISABLE)
GUICtrl_SetState($ButtonC,$GUI_DISABLE)
GUICtrl_SetState($ButtonD,$GUI_ENABLE)
GUICtrlSetData($Progress,0)
CloseAllThreadA()
EndFunc

Func WatNextA($Text = " Open Url ")
GUICtrlSetData($Label2,$Text & " . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,"")
EndFunc

Func WatNextB($Text)
GUICtrlSetData($Label2,$Text & " . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
GUICtrlSetData($Label2,$Text & " . . . . ")
Sleep(20)
if  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
EndFunc


Func CloseAllThreadB()

GUICtrlSetState($Combo1,$GUI_DISABLE)

if IsArray($ThreadArray) Then

GUICtrlSetData($Progress,0)

For $i = 0 To UBound($ThreadArray) - 1

$OpenRequest = $ThreadArray[$i][1]
$hThread = $ThreadArray[$i][8]
$InfoStruct = $ThreadArray[$i][6]
$hFile = $ThreadArray[$i][5]

If $ProgressLoop Then WatNextB(" The multiple download process is completing ")

if $hThread Then

DllStructSetData($InfoStruct,"Cancel",1)
While DllStructGetData($InfoStruct,"Complete") = 0

WatNextB(" The multiple download process is completing ")

WEnd

_WinAPI_CloseHandle($hThread)

Else

if $hFile Then _WinAPI_CloseHandle($hFile)
if $OpenRequest Then WinHttpCloseHandle($OpenRequest)

EndIf

GUICtrlSetData($Progress,(100 / UBound($ThreadArray)) * ($i + 1))

Next

Sleep(1000)
GUICtrlSetData($Progress,0)
Local $TestExists = False
if $ProgressLoop Then
For $i = 0 To UBound($ThreadArray) - 1
$FileA = $ThreadArray[$i][4]
$hFile = $ThreadArray[$i][5]
if FileExists($FileA) Then
WatNextB(" Deleting the file ")
_WinAPI_CloseHandle($hFile)
FileDelete($FileA)
GUICtrlSetData($Progress,(100 / UBound($ThreadArray)) * ($i + 1))
$TestExists = True
EndIf
Next
if $TestExists Then GUICtrlSetData($Progress,100)
EndIf

Sleep(1000)
if $Connect Then WinHttpCloseHandle($Connect)
if $HIntOpen Then WinHttpCloseHandle($HIntOpen)
$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$DwnhFile = 0

GUICtrlSetData($Label2,"")
GUICtrlSetData($Progress,0)
$ThreadArray = 0
GUICtrlSetState($Combo1,$GUI_ENABLE)

EndIf

GUICtrlSetState($Combo1,$GUI_ENABLE)

EndFunc


Func CloseAllThreadA()

GUICtrlSetState($Combo1,$GUI_DISABLE)

if IsArray($ThreadArray) Then

GUICtrlSetData($Progress,0)

For $i = 0 To UBound($ThreadArray) - 1

$OpenRequest = $ThreadArray[$i][1]
$hThread = $ThreadArray[$i][8]
$InfoStruct = $ThreadArray[$i][6]
$hFile = $ThreadArray[$i][5]

WatNextB(" The multiple download process is completing ")

if $hThread Then

DllStructSetData($InfoStruct,"Cancel",1)
While DllStructGetData($InfoStruct,"Complete") = 0

WatNextB(" The multiple download process is completing ")

WEnd

_WinAPI_CloseHandle($hThread)

Else

if $hFile Then _WinAPI_CloseHandle($hFile)
if $OpenRequest Then WinHttpCloseHandle($OpenRequest)

EndIf

GUICtrlSetData($Progress,(100 / UBound($ThreadArray)) * ($i + 1))

Next

Sleep(1000)
GUICtrlSetData($Progress,0)
Local $TestExists = False
For $i = 0 To UBound($ThreadArray) - 1
$FileA = $ThreadArray[$i][4]
if FileExists($FileA) Then
WatNextB(" Deleting the temporary files ")
FileDelete($FileA)
GUICtrlSetData($Progress,(100 / UBound($ThreadArray)) * ($i + 1))
$TestExists = True
EndIf
Next
if $TestExists Then GUICtrlSetData($Progress,100)
Sleep(1000)

if $Connect Then WinHttpCloseHandle($Connect)
if $HIntOpen Then WinHttpCloseHandle($HIntOpen)

$HIntOpen = 0
$Connect = 0
$lpszHostName = 0
$szPath = 0
$DwnhFilePatch = ""
$DwnhFile = 0

GUICtrlSetData($Label2,"")
GUICtrlSetData($Progress,0)
$ThreadArray = 0
GUICtrlSetState($Combo1,$GUI_ENABLE)

EndIf

GUICtrlSetState($Combo1,$GUI_ENABLE)

EndFunc

Func ProgressLoopB()
GUICtrlSetState($Combo1,$GUI_ENABLE)
$ProgressLoop = False
if IsArray($ThreadArray) Then
While 1
Local $CompleteAll = True , $MovePosAll = 0
For $i = 0 To UBound($ThreadArray) - 1
if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
$InfoStruct = $ThreadArray[$i][6]
$TimeNuPos = DllStructGetData($InfoStruct,"TimeNuPos")
$Complete = DllStructGetData($InfoStruct,"Complete")
$MovePos = DllStructGetData($InfoStruct,"MovePos")
$MovePosAll += $MovePos + ($TimeNuPos * $MaxInt)
$Error = DllStructGetData($InfoStruct,"Error")
if $Error Then
$ProgressLoop = True
Return SetError(10,0,False)
EndIf
if Not ($Complete) Then $CompleteAll = False

if Not $Complete Then
$FreeSpace = DriveSpaceFree ($DownloadDir)
if $FreeSpace <= ($MovePosAll / 1048576) + ($NewSize1 / 1048576) Then
if @error Then Return SetError(14,0,False)
Return SetError(12,0,False)
EndIf
$FreeSpace = DriveSpaceFree (@SystemDir)
if $FreeSpace <= ($MovePosAll / 1048576) + ($NewSize1 / 1048576) Then Return SetError(13,0,False)
EndIf

Next
Sleep(75)
Local $Text = ""
Select
Case $MovePosAll < 1024
$Text = "" & StringLeft(($MovePosAll / 1024),7) & " Byte From "  &  " Unknown size "
Case $MovePosAll < (1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024,7) & " Kilo Byte From "  &  " Unknown size "
Case $MovePosAll < (1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024,7) & " Mega Byte From "  &  " Unknown size "
Case $MovePosAll < (1024 * 1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024 / 1024,7) & " Giga Byte From " &  " Unknown size "
Case Else
$Text = "" & StringLeft($MovePosAll / 1024 / 1024 / 1024 / 1024,7) & " Terra Byte From " &  " Unknown size "
EndSelect
GUICtrlSetData($Progress,100)
GUICtrlSetData($idLabe3,$Text)
Sleep(75)
$Text =   " Download percentage is unknown "
GUICtrlSetData($idLabe4,$Text)
if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
if $ProgressLoop Then Return SetError(11,0,False)
if $CompleteAll Then ExitLoop
WEnd
EndIf
Return SetError(0,0,True)
EndFunc

Func ProgressLoopA()
$ProgressLoop = False
GUICtrlSetState($Combo1,$GUI_ENABLE)
if IsArray($ThreadArray) Then
While 1
Local $CompleteAll = True , $MovePosAll = 0
For $i = 0 To UBound($ThreadArray) - 1
if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
$InfoStruct = $ThreadArray[$i][6]
$TimeNuPos = DllStructGetData($InfoStruct,"TimeNuPos")
$Complete = DllStructGetData($InfoStruct,"Complete")
$MovePos = DllStructGetData($InfoStruct,"MovePos")
$MovePosAll += $MovePos + ($TimeNuPos * $MaxInt)
$Error = DllStructGetData($InfoStruct,"Error")
if $Error Then
$ProgressLoop = True
Return SetError(10,0,False)
EndIf
if Not ($Complete) Then $CompleteAll = False
Next
Sleep(75)
Local $Text = ""
Select
Case $FileSize >= (1024 * 1024 * 1024 * 1024)
Select
Case $MovePosAll < 1024
$Text = "" & StringLeft($MovePosAll,7) & " Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $MovePosAll < (1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024,7) & " Kilo Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $MovePosAll < (1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case $MovePosAll < (1024 * 1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024 / 1024,7) & " Giga Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
Case Else
$Text = "" & StringLeft($MovePosAll / 1024 / 1024 / 1024 / 1024,7) & " Terra Byte From " & StringLeft($FileSize  / 1024 / 1024 / 1024 / 1024,7) &  " Terra Byte "
EndSelect
Case $FileSize >= (1024 * 1024 * 1024)
Select
Case $MovePosAll < 1024
$Text = "" & StringLeft($MovePosAll,7) & " Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $MovePosAll < (1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $MovePosAll < (1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
Case $MovePosAll < (1024 * 1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024 / 1024,7) & " Giga Byte From " & StringLeft($FileSize / 1024 / 1024 / 1024,7) &  " Giga Byte "
EndSelect
Case $FileSize >= (1024 * 1024)
Select
Case $MovePosAll < 1024
$Text = "" & StringLeft($MovePosAll,7) & " Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
Case $MovePosAll < (1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
Case $MovePosAll < (1024 * 1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024 / 1024,7) & " Mega Byte From " & StringLeft($FileSize / 1024 / 1024,7) &  " Mega Byte "
EndSelect
Case $FileSize >= (1024)
Select
Case $MovePosAll < 1024
$Text = "" & StringLeft($MovePosAll,7) & " Byte From " & StringLeft($FileSize / 1024,7) &  " Kilo Byte "
Case $MovePosAll < (1024 * 1024)
$Text = "" & StringLeft($MovePosAll / 1024,7) & " Kilo Byte From " & StringLeft($FileSize / 1024,7) &  " Kilo Byte "
EndSelect
Case $FileSize >= 1
$Text = "" & StringLeft($MovePosAll,7) & " Byte From " & StringLeft($FileSize,7) &  " Byte "
EndSelect
GUICtrlSetData($Progress,(100 / $FileSize) * $MovePosAll)
GUICtrlSetData($idLabe3,$Text)
Sleep(75)
$Text = StringLeft((($MovePosAll / $FileSize) * 100),4)
$Text = " downloaded "  & $Text & "%"
GUICtrlSetData($idLabe4,$Text)
if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
if $ProgressLoop Then Return SetError(11,0,False)
if $CompleteAll Then
ExitLoop
Else
$FreeSpace = DriveSpaceFree ($DownloadDir)
if $FreeSpace <= ($MovePosAll / 1048576) + ($NewSize1 / 1048576) Then
if @error Then Return SetError(14,0,False)
Return SetError(12,0,False)
EndIf
$FreeSpace = DriveSpaceFree (@SystemDir)
if $FreeSpace <= ($MovePosAll / 1048576) + ($NewSize1 / 1048576) Then Return SetError(13,0,False)
EndIf

WEnd
EndIf
Return SetError(0,0,True)
EndFunc

Func ErrorFunc($Error,$Flag)
if $Error = 1 Then MsgBox(16,"Error","The device is not connected to the network",0,$HGui)
if $Error = 2 Then MsgBox(16,"Error","Could not open Url",0,$HGui)
if $Error = 3 Then MsgBox(16,"Error","A link to the Internet could not be opened",0,$HGui)
if $Error = 4 Then MsgBox(16,"Error","Unable to connect to the server",0,$HGui)
if $Error = 5 Then MsgBox(16,"Error","Could not open Url",0,$HGui)
if $Error = 6 Then MsgBox(16,"Error","File size could not be obtained",0,$HGui)
if $Error = 7 Then MsgBox(16,"Error","Unable to make settings on the Url",0,$HGui)
if $Error = 8 Then MsgBox(16,"Error","The request could not be sent to the server",0,$HGui)
if $Error = 9 Then MsgBox(16,"Error","A file in the temporary files folder could not be opened",0,$HGui)
if $Error = 10 Then MsgBox(16,"Error","The download process failed",0,$HGui)
if $Error = 12 Then MsgBox(48,"Notice","There is no space for downloaded files on the Download folder partition",0,$HGui)
if $Error = 13 Then MsgBox(48,"Notice","There is no space for the download process on the system partition",0,$HGui)
if $Error = 14 Then MsgBox(48,"Notice","The download folder partition could not be accessed",0,$HGui)
EndFunc

Func NewThreadB($lpszUrl)

if Not($Winhttp) Then $Winhttp = DllOpen("Winhttp.dll")

if $ProgressLoop Then Return SetError(11,0,False)

if Not InternetGetConnectedState() Then Return SetError(1,0,False)

if Not IsDllStruct($lpszHostName) Then
$URL_COMPONENTS = WinHttpCrackUrl($lpszUrl,StringLen($lpszUrl),0)
if @error Then Return SetError(2,0,False)
EndIf

if Not($HIntOpen) Then $HIntOpen = WinHttpOpen("OPEN")
if Not($HIntOpen) Then Return SetError(3,0,False)

if Not IsArray($ThreadArray) Then
Dim $IThreadArray[1][12]
$ThreadArray = $IThreadArray
Else
ReDim $ThreadArray[UBound($ThreadArray) + 1][12]
EndIf

if Not $Connect Then $Connect = WinHttpConnect($HIntOpen,DllStructGetData($lpszHostName,1),0)
if Not $Connect Then Return SetError(4,0,False)

$ThreadArray[UBound($ThreadArray) - 1][0] = $Connect

$OpenRequest = WinHttpOpenRequest($Connect,"GET",DllStructGetData($szPath,1))
if Not $OpenRequest Then Return SetError(5,0,False)

$ThreadArray[UBound($ThreadArray) - 1][1] = $OpenRequest

$Return = WinHttpSendRequest($OpenRequest)
if Not $Return Then Return SetError(8,0,False)

$Return = WinHttpReceiveResponse($OpenRequest)
if Not $Return Then Return SetError(8,0,False)

Local $vFileName = ""
if StringLen($DISPOSITION) Then
$zFileName = $DISPOSITION
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,StringLen($zFileName) - StringLen($Extension))
$vFileName = StringLeft($nFileName,30)
Else
$zFileName = StringSplit($OriginalUrl,"/")
$zFileName = $zFileName[$zFileName[0]]
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,StringLen($zFileName) - StringLen($Extension))
$vFileName = StringLeft($nFileName,30)
EndIf

DirCreate($DownloadDir)
Local $i = 1
$FileA = $DownloadDir & "\" & $vFileName & $Extension
While FileExists($FileA)
$FileA = $DownloadDir & "\" & $vFileName & "(" & $i & ")" & $Extension
if $ProgressLoop Then Return SetError(11,0,False)
$i += 1
WEnd

$hFile = _WinAPI_CreateFile($FileA,0)
if Not($hFile) Then Return SetError(9,0,False)

$ThreadArray[UBound($ThreadArray) - 1][4] = $FileA
$ThreadArray[UBound($ThreadArray) - 1][5] = $hFile

Local $InfoStruct = DllStructCreate($tagInfoSt)
$ThreadArray[UBound($ThreadArray) - 1][6] = $InfoStruct

if Not $WinhttphModule Then
$WinhttphModule = _WinAPI_LoadLibrary("Winhttp.dll")
$WriteFile = _WinAPI_GetProcAddress($Kernel32dll,"WriteFile")
$CloseHandle = _WinAPI_GetProcAddress($Kernel32dll,"CloseHandle")
$WinHttpReadData = _WinAPI_GetProcAddress($WinhttphModule,"WinHttpReadData")
$WinHttpCloseHandle = _WinAPI_GetProcAddress($WinhttphModule,"WinHttpCloseHandle")
EndIf

$hLockDataSt = DllStructCreate("BYTE[1048576]")
$hLockDataPtr = DllStructGetPtr( $hLockDataSt )
DllStructSetData($InfoStruct,"BytesAtaTime" ,$BytesAtaTime)
DllStructSetData($InfoStruct,"vBytesAtaTime",$BytesAtaTime)
DllStructSetData($InfoStruct,"FileSize",$MaxInt)
$ThreadArray[UBound($ThreadArray) - 1][9] = $hLockDataSt
$ThreadArray[UBound($ThreadArray) - 1][7] = LoadFileDownLoad2()

if $ProgressLoop Then Return SetError(11,0,False)

$LoadFileDownLoad = $ThreadArray[UBound($ThreadArray) - 1][7]
$ThreadArray[UBound($ThreadArray) - 1][8] = CreateThread(DllStructGetPtr($LoadFileDownLoad),DllStructGetPtr($InfoStruct))

Return SetError(0,0,True)

EndFunc


Func NewThreadA($lpszUrl,$Pointer = 0,$nFileSize = 0)

if Not($Winhttp) Then $Winhttp = DllOpen("Winhttp.dll")

if $nFileSize = 0 Then
WatNextB(" Open Url ")
Else
WatNextB(" Set up the multiple download process")
EndIf

if $ProgressLoop Then Return SetError(11,0,False)

if Not InternetGetConnectedState() Then Return SetError(1,0,False)

if Not IsDllStruct($lpszHostName) Then
$URL_COMPONENTS = WinHttpCrackUrl($lpszUrl,StringLen($lpszUrl),0)
if @error Then Return SetError(2,0,False)
EndIf

if Not($HIntOpen) Then $HIntOpen = WinHttpOpen("OPEN")
if Not($HIntOpen) Then Return SetError(3,0,False)

if Not IsArray($ThreadArray) Then
Dim $IThreadArray[1][12]
$ThreadArray = $IThreadArray
Else
ReDim $ThreadArray[UBound($ThreadArray) + 1][12]
EndIf

if Not $Connect Then $Connect = WinHttpConnect($HIntOpen,DllStructGetData($lpszHostName,1),0)
if Not $Connect Then Return SetError(4,0,False)

$ThreadArray[UBound($ThreadArray) - 1][0] = $Connect

$OpenRequest = WinHttpOpenRequest($Connect,"GET",DllStructGetData($szPath,1))
if Not $OpenRequest Then Return SetError(5,0,False)

$ThreadArray[UBound($ThreadArray) - 1][1] = $OpenRequest

Local $Range = ""
if $Pointer Then $Range = "Range: bytes=" & $Pointer & "-"
$Return = WinHttpSendRequest($OpenRequest,$Range,StringLen($Range))
if Not $Return Then Return SetError(8,0,False)

$Return = WinHttpReceiveResponse($OpenRequest)
if Not $Return Then Return SetError(8,0,False)

if $nFileSize = 0 Then

$DISPOSITION = WinHttpQueryHeaders($OpenRequest,47)
if Not @error And IsString($DISPOSITION) Then
$DISPOSITION = StringSplit($DISPOSITION,";")
$DISPOSITION = $DISPOSITION[$DISPOSITION[0]]
$DISPOSITION = StringSplit($DISPOSITION,"=")
$DISPOSITION = $DISPOSITION[$DISPOSITION[0]]
$DISPOSITION = StringReplace($DISPOSITION,'"',"")
$DISPOSITION = StringReplace($DISPOSITION,"'","")
if Not StringInStr($DISPOSITION,".") Then $DISPOSITION = ""
Else
$DISPOSITION = ""
EndIf

$OriginalUrl = WinHttpQueryOption($OpenRequest,34)
if @error Then Return SetError(7,0,False)

$FileSize = WinHttpQueryHeaders($OpenRequest,5)
$FileSize = Abs(int($FileSize))
if Not($FileSize) Then Return SetError(6,0,False)

$ThreadArray[UBound($ThreadArray) - 1][2] = $FileSize
$ThreadArray[UBound($ThreadArray) - 1][3] = $OriginalUrl

Return SetError(0,0,True)

Else

$ThreadArray[UBound($ThreadArray) - 1][2] = $nFileSize

EndIf

Local $vFileName = ""
if StringLen($DISPOSITION) Then
$zFileName = $DISPOSITION
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,StringLen($zFileName) - StringLen($Extension))
$vFileName = StringLeft($nFileName,30)
Else
$zFileName = StringSplit($OriginalUrl,"/")
$zFileName = $zFileName[$zFileName[0]]
$Extension = StringSplit($zFileName,".")
$Extension = "." & $Extension[$Extension[0]]
$nFileName = StringLeft($zFileName,StringLen($zFileName) - StringLen($Extension))
$vFileName = StringLeft($nFileName,30)
EndIf

DirCreate(@TempDir & "\DownloadTool\" & $vFileName)
Local $i = 1
$FileA = @TempDir & "\DownloadTool\" & $vFileName & "\" & $vFileName & "(" & $i & ").Data"
While FileExists($FileA)
$FileA = @TempDir & "\DownloadTool\" & $vFileName & "\" & $vFileName & "(" & $i & ").Data"
if $ProgressLoop Then Return SetError(11,0,False)
$i += 1
WEnd

$hFile = _WinAPI_CreateFile($FileA,0)
if Not($hFile) Then Return SetError(9,0,False)

$ThreadArray[UBound($ThreadArray) - 1][4] = $FileA
$ThreadArray[UBound($ThreadArray) - 1][5] = $hFile

Local $InfoStruct = DllStructCreate($tagInfoSt)
$ThreadArray[UBound($ThreadArray) - 1][6] = $InfoStruct

if ($nFileSize > $MaxInt) Then
Local $Remainder = Mod($nFileSize,$MaxInt)
DllStructSetData($InfoStruct,"FileSize",$MaxInt)
DllStructSetData($InfoStruct,"Remder",$Remainder)
DllStructSetData($InfoStruct,"TimeNu",(($nFileSize - $Remainder) / $MaxInt))
Else
DllStructSetData($InfoStruct,"FileSize",$nFileSize)
EndIf

if Not $WinhttphModule Then
$WinhttphModule = _WinAPI_LoadLibrary("Winhttp.dll")
$WriteFile = _WinAPI_GetProcAddress($Kernel32dll,"WriteFile")
$CloseHandle = _WinAPI_GetProcAddress($Kernel32dll,"CloseHandle")
$WinHttpReadData = _WinAPI_GetProcAddress($WinhttphModule,"WinHttpReadData")
$WinHttpCloseHandle = _WinAPI_GetProcAddress($WinhttphModule,"WinHttpCloseHandle")
EndIf

$hLockDataSt = DllStructCreate("BYTE[1048576]")
$hLockDataPtr = DllStructGetPtr( $hLockDataSt )
DllStructSetData($InfoStruct,"BytesAtaTime" ,$BytesAtaTime)
DllStructSetData($InfoStruct,"vBytesAtaTime",$BytesAtaTime)
$ThreadArray[UBound($ThreadArray) - 1][9] = $hLockDataSt
$ThreadArray[UBound($ThreadArray) - 1][7] = LoadFileDownLoad()

if $ProgressLoop Then Return SetError(11,0,False)

$LoadFileDownLoad = $ThreadArray[UBound($ThreadArray) - 1][7]
$ThreadArray[UBound($ThreadArray) - 1][8] = CreateThread(DllStructGetPtr($LoadFileDownLoad),DllStructGetPtr($InfoStruct))

Return SetError(0,0,True)

EndFunc


Func LoadFileDownLoad2()

Local $OffSetInetHandle = $DwordSize
Local $OffSetCancel = ($DwordSize * 9)
Local $OffSetNuOfBytesRead = ($DwordSize * 19)
Local $OffSetByteAtaTime =  ($DwordSize * 7)
Local $OffSetNuOfBytesWn = ($DwordSize * 20)
Local $OffSetMovePos = ($DwordSize * 6)
Local $OffSetComplete = ($DwordSize * 3)
Local $OffSetFileSize = ($DwordSize * 8)
Local $OffsetError = ($DwordSize * 5)
Local $OffsetTimeNu = ($DwordSize * 12)
Local $OffsetRemder = ($DwordSize * 13)
Local $OffsetTimeNuPos = ($DwordSize * 14)
Local $OffSetvByteAtaTime = ($DwordSize * 21)
Local $OffSetControlThread = ($DwordSize * 22)
Local $vOffSetControlThread = ($DwordSize * 23)

Local $Complete,$JZCancel,$JZComplete,$JMPStart,$Start,$JZJMPStart,$Next,$JZNext,$JZComplete2,$JL2Next2,$Add,$JZAdd
Local $Error,$JZError,$JMPStart2 , $Next2 , $JLNext2 ,  $JZError2 , $JMPEnd ,  $End ,  $JMPStart4 ,  $XComplete
Local $Add , $JGAdd , $Add2 , $JGAdd2 , $JMPStart3 , $JMPStart4 , $Out , $JZOut , $Next3 , $JZNext3 , $JMPXComplete


For $i = 1 To 2

$_ASMCode =  "0x"

; $Start: //
$Start = BinaryLen($_ASMCode)

$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "8B43" & Hex($OffSetControlThread,2) ;mov eax,[ebx + $OffSetFileSize]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Next3 - $JZNext3),2) ;JZ Next3
$JZNext3 = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($vOffSetControlThread,2) & Hex(1,2) ;mov [ebx + $vOffSetControlThread],1

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$JMPStart4 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart4 - $Start) + 5)) ;JMP $Start

; $Next3: //
$Next3 = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetFileSize,2) ;mov eax,[ebx + $OffSetFileSize]
$_ASMCode &= "2B43" & Hex($OffSetMovePos,2) ;sub eax,[ebx + $OffSetMovePos]
$_ASMCode &= "3B43" & Hex($OffSetByteAtaTime,2) ;CMP eax,[ebx + $OffSetByteAtaTime]
$_ASMCode &= "7C" & Hex(($Next2 - $JLNext2),2) ;JL Next2
$JLNext2 = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;mov [ebx + $OffSetNuOfBytesRead],0
$_ASMCode &= "83C3" & Hex($OffSetNuOfBytesRead,2) ;add ebx,$OffSetNuOfBytesRead
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle + $PtrSize,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "FF73" & Hex($OffSetByteAtaTime,2) ;push [ebx + $OffSetByteAtaTime]
$_ASMCode &= "68" & HexBinary($hLockDataPtr) ;push $hLockDataPtr
$_ASMCode &= "68" & HexBinary($OpenRequest) ;push $OpenRequest
$_ASMCode &= "B8" & HexBinary($WinHttpReadData) ;mov eax,$WinHttpReadData
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Error - $JZError),2) ;JZ Error
$JZError = BinaryLen($_ASMCode)

$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "8B43" & Hex($OffSetNuOfBytesRead,2) ;mov eax,[ebx + $OffSetNuOfBytesRead]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Complete - $JZComplete),2) ;JZ Complete
$JZComplete = BinaryLen($_ASMCode)

$_ASMCode &= "68" & HexBinary(0) ;push lpOverlapped = 0
$_ASMCode &= "83C3" & Hex($OffSetNuOfBytesWn,2) ;add ebx,$OffSetNuOfBytesWn
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle + $PtrSize + $PtrSize,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "FF73" & Hex($OffSetNuOfBytesRead,2) ;push [ebx + $OffSetNuOfBytesRead]
$_ASMCode &= "68" & HexBinary($hLockDataPtr) ;push $hLockDataPtr
$_ASMCode &= "68" & HexBinary($hFile) ;push $hFile
$_ASMCode &= "B8" & HexBinary($WriteFile) ;mov eax,$WriteFile
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "8B43" & Hex($OffSetNuOfBytesRead,2) ;mov eax,[ebx + $OffSetNuOfBytesRead]
$_ASMCode &= "0143" & Hex($OffSetMovePos,2) ;add [ebx + $OffSetMovePos],eax

$_ASMCode &= "8B43" & Hex($OffSetMovePos ,2) ;mov eax,[ebx + $OffSetMovePos]
$_ASMCode &= "3B43" & Hex($OffSetFileSize,2) ;CMP eax,[ebx + $OffSetFileSize]
$_ASMCode &= "74" & Hex(($Add - $JZAdd),2) ;JZ Add
$JZAdd = BinaryLen($_ASMCode)

$_ASMCode &= "807B" & Hex($OffSetCancel,2) & Hex(1,2) ;CMP [ebx + $OffSetCancel],1 // Cancel
$_ASMCode &= "74" & Hex(($Complete - $JZCancel),2) ;JZ $Complete;
$JZCancel = BinaryLen($_ASMCode)

$JMPStart2 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart2 - $Start) + 5)) ;JMP $Start

;$Next2: //
$Next2 = BinaryLen($_ASMCode)
$_ASMCode &= "8943" & Hex($OffSetByteAtaTime,2) ;mov [ebx + $OffSetByteAtaTime],eax
$JMPStart = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart - $Start) + 5)) ;JMP $Start

; Add: //
$Add = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "8943" & Hex($OffSetMovePos,2) ;mov [ebx + $OffSetMovePos],eax
$_ASMCode &= "B8" & HexBinary(1) ;mov eax,1
$_ASMCode &= "0143" & Hex($OffsetTimeNuPos,2) ;add [ebx + $OffsetTimeNuPos],eax
$_ASMCode &= "8B43" & Hex($OffSetvByteAtaTime,2) ;mov eax,[ebx + $OffSetvByteAtaTime]
$_ASMCode &= "8943" & Hex($OffSetByteAtaTime,2) ;mov [ebx + $OffSetByteAtaTime],eax
$JMPStart3 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart3 - $Start) + 5)) ;JMP $Start

; Error: //
$Error = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "C643" & Hex($OffsetError,2) & Hex(8,2) ;mov [ebx + $OffsetError],8

; Complete: //
$Complete = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1
$_ASMCode &= "68" & HexBinary($OpenRequest) ;push $OpenRequest
$_ASMCode &= "B8" & HexBinary($WinHttpCloseHandle) ;mov eax,$WinHttpCloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "68" & HexBinary($hFile) ;push $hFile
$_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size

Next

$AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($AddressSt,1,$_ASMCode)
Return $AddressSt

EndFunc


Func LoadFileDownLoad()

Local $OffSetInetHandle = $DwordSize
Local $OffSetCancel = ($DwordSize * 9)
Local $OffSetNuOfBytesRead = ($DwordSize * 19)
Local $OffSetByteAtaTime =  ($DwordSize * 7)
Local $OffSetNuOfBytesWn = ($DwordSize * 20)
Local $OffSetMovePos = ($DwordSize * 6)
Local $OffSetComplete = ($DwordSize * 3)
Local $OffSetFileSize = ($DwordSize * 8)
Local $OffsetError = ($DwordSize * 5)
Local $OffsetTimeNu = ($DwordSize * 12)
Local $OffsetRemder = ($DwordSize * 13)
Local $OffsetTimeNuPos = ($DwordSize * 14)
Local $OffSetvByteAtaTime = ($DwordSize * 21)
Local $OffSetControlThread = ($DwordSize * 22)
Local $vOffSetControlThread = ($DwordSize * 23)

Local $Complete , $JZCancel,$JZComplete,$JMPStart,$Start,$JZJMPStart,$Next,$JZNext,$JZComplete2,$JL2Next2,$JZNext4
Local $Error , $JZError ,$JMPStart2,$Next2,$JLNext2,$JZError2,$JMPEnd,$End,$JMPStart4,$XComplete,$Next4,$JMPStart5
Local $Add , $JGAdd , $Add2 , $JGAdd2 , $JMPStart3 , $JMPStart4 , $Out , $JZOut , $Next3 , $JZNext3 , $JMPXComplete


For $i = 1 To 2

$_ASMCode =  "0x"

; $Start: //
$Start = BinaryLen($_ASMCode)

$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "8B43" & Hex($OffSetControlThread,2) ;mov eax,[ebx + $OffSetFileSize]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Next4 - $JZNext4),2) ;JZ Next4
$JZNext4 = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($vOffSetControlThread,2) & Hex(1,2) ;mov [ebx + $vOffSetControlThread],1

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$JMPStart5 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart5 - $Start) + 5)) ;JMP $Start

; $Next4: //
$Next4 = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "8B43" & Hex($OffSetFileSize,2) ;mov eax,[ebx + $OffSetFileSize]
$_ASMCode &= "2B43" & Hex($OffSetMovePos,2) ;sub eax,[ebx + $OffSetMovePos]
$_ASMCode &= "3B43" & Hex($OffSetByteAtaTime,2) ;CMP eax,[ebx + $OffSetByteAtaTime]
$_ASMCode &= "7C" & Hex(($Next2 - $JLNext2),2) ;JL Next2
$JLNext2 = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetNuOfBytesRead,2) & Hex(0,2) ;mov [ebx + $OffSetNuOfBytesRead],0
$_ASMCode &= "83C3" & Hex($OffSetNuOfBytesRead,2) ;add ebx,$OffSetNuOfBytesRead
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle + $PtrSize,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "FF73" & Hex($OffSetByteAtaTime,2) ;push [ebx + $OffSetByteAtaTime]
$_ASMCode &= "68" & HexBinary($hLockDataPtr) ;push $hLockDataPtr
$_ASMCode &= "68" & HexBinary($OpenRequest) ;push $OpenRequest
$_ASMCode &= "B8" & HexBinary($WinHttpReadData) ;mov eax,$WinHttpReadData
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Error - $JZError),2) ;JZ Error
$JZError = BinaryLen($_ASMCode)

$_ASMCode &= "68" & HexBinary(0) ;push lpOverlapped = 0
$_ASMCode &= "83C3" & Hex($OffSetNuOfBytesWn,2) ;add ebx,$OffSetNuOfBytesWn
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle + $PtrSize + $PtrSize,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "FF73" & Hex($OffSetNuOfBytesRead,2) ;push [ebx + $OffSetNuOfBytesRead]
$_ASMCode &= "68" & HexBinary($hLockDataPtr) ;push $hLockDataPtr
$_ASMCode &= "68" & HexBinary($hFile) ;push $hFile
$_ASMCode &= "B8" & HexBinary($WriteFile) ;mov eax,$WriteFile
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "8B43" & Hex($OffSetNuOfBytesRead,2) ;mov eax,[ebx + $OffSetNuOfBytesRead]
$_ASMCode &= "0143" & Hex($OffSetMovePos,2) ;add [ebx + $OffSetMovePos],eax

$_ASMCode &= "8B43" & Hex($OffSetFileSize,2) ;mov eax,[ebx + $OffSetFileSize]
$_ASMCode &= "3B43" & Hex($OffSetMovePos,2) ;CMP eax,[ebx + $OffSetMovePos]
$_ASMCode &= "74" & Hex(($Complete - $JZComplete),2) ;JZ Complete
$JZComplete = BinaryLen($_ASMCode)

$_ASMCode &= "807B" & Hex($OffSetCancel,2) & Hex(1,2) ;CMP [ebx + $OffSetCancel],1 // Cancel
$_ASMCode &= "74" & Hex(($XComplete - $JZCancel),2) ;JZ $XComplete;
$JZCancel = BinaryLen($_ASMCode)

$JMPStart2 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart2 - $Start) + 5)) ;JMP $Start

; $Next2: //
$Next2 = BinaryLen($_ASMCode)
$_ASMCode &= "8943" & Hex($OffSetByteAtaTime,2) ;mov [ebx + $OffSetByteAtaTime],eax
$JMPStart = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart - $Start) + 5)) ;JMP $Start

; Error: //
$Error = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "C643" & Hex($OffsetError,2) & Hex(8,2) ;mov [ebx + $OffsetError],8
$_ASMCode &= "EB" & Hex(($XComplete - $JMPXComplete),2) ;JMP $XComplete
$JMPXComplete = BinaryLen($_ASMCode)

; Complete: //
$Complete = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffsetTimeNuPos,2) ;mov eax,[ebx + $OffsetTimeNuPos]
$_ASMCode &= "3943" & Hex($OffsetTimeNu,2) ;CMP [ebx + $OffsetTimeNu],eax
$_ASMCode &= "7F" & Hex(($Add - $JGAdd),2) ;JG Add
$JGAdd = BinaryLen($_ASMCode)

; XComplete: //
$XComplete = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1
$_ASMCode &= "68" & HexBinary($OpenRequest) ;push $OpenRequest
$_ASMCode &= "B8" & HexBinary($WinHttpCloseHandle) ;mov eax,$WinHttpCloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "68" & HexBinary($hFile) ;push $hFile
$_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size

; Add: //
$Add = BinaryLen($_ASMCode)
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "8943" & Hex($OffSetMovePos,2) ;mov [ebx + $OffSetMovePos],eax
$_ASMCode &= "B8" & HexBinary(1) ;mov eax,1
$_ASMCode &= "0143" & Hex($OffsetTimeNuPos,2) ;add [ebx + $OffsetTimeNuPos],eax
$_ASMCode &= "8B43" & Hex($OffSetvByteAtaTime,2) ;mov eax,[ebx + $OffSetvByteAtaTime]
$_ASMCode &= "8943" & Hex($OffSetByteAtaTime,2) ;mov [ebx + $OffSetByteAtaTime],eax
$_ASMCode &= "8B43" & Hex($OffsetTimeNuPos,2) ;mov eax,[ebx + $OffsetTimeNuPos]
$_ASMCode &= "3943" & Hex($OffsetTimeNu,2) ;CMP [ebx + $OffsetTimeNu],eax
$_ASMCode &= "74" & Hex(($Next3 - $JZNext3),2) ;JZ Next3
$JZNext3 = BinaryLen($_ASMCode)

$JMPStart3 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart3 - $Start) + 5)) ;JMP $Start

; Next3: //
$Next3 = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffsetRemder,2) ;mov eax,[ebx + $OffsetRemder]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($Out - $JZOut),2) ;JZ Out
$JZOut = BinaryLen($_ASMCode)

$_ASMCode &= "8943" & Hex($OffSetFileSize,2) ;mov [ebx + $OffSetFileSize],eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "8943" & Hex($OffsetRemder,2) ;mov [ebx + $OffsetRemder],eax

$JMPStart4 = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPStart4 - $Start) + 5)) ;JMP $Start

; Out: //
$Out = BinaryLen($_ASMCode)
$_ASMCode &= "8B5C24" & Hex($OffSetInetHandle,2) ;mov ebx,[esp + $OffSetInetHandle]
$_ASMCode &= "C643" & Hex($OffSetComplete,2) & Hex(1,2) ;mov [ebx + $OffSetComplete],1
$_ASMCode &= "68" & HexBinary($OpenRequest) ;push $OpenRequest
$_ASMCode &= "B8" & HexBinary($WinHttpCloseHandle) ;mov eax,$WinHttpCloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "68" & HexBinary($hFile) ;push $hFile
$_ASMCode &= "B8" & HexBinary($CloseHandle) ;mov eax,$CloseHandle
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "C2" & Hex($PtrSize,2) & Hex(0,2) ;ret ($PtrSize) & "00" // Args Size

Next

$AddressSt = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($AddressSt,1,$_ASMCode)
Return $AddressSt

EndFunc

Func CreateThread($lpStartAddress,$lpParameter)
Local $HANDLE = DllCall("Kernel32.dll","ptr","CreateThread","ptr",0,"int",0,"ptr", _
$lpStartAddress,"ptr",$lpParameter,"DWORD",0,"DWORD*",0)
if @error Or $HANDLE[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,$HANDLE[0])
EndFunc

Func InternetGetConnectedState()
$BOOL = DllCall("Wininet.dll","DWORD","InternetGetConnectedState","DWORD*",0,"DWORD",0)
if @error Then Return SetError(1,0,0)
Return $BOOL[0]
EndFunc

Func WinHttpQueryOption($hInternet,$dwOption)
Local $lpdwBufferLength = 10000
$DLLSDWORD = DllStructCreate("DWORD")
DllStructSetData($DLLSDWORD,1,$lpdwBufferLength)
$LPDWORDLENGTH = DllStructGetPtr($DLLSDWORD)
$DLLSlpvBuffer = DllStructCreate("WCHAR[" & $lpdwBufferLength & "]")
$lpvBuffer = DllStructGetPtr($DLLSlpvBuffer)
$BOOL = DllCall($Winhttp,"BOOL","WinHttpQueryOption","HANDLE",$hInternet _
,"DWORD",$dwOption,"ptr",$lpvBuffer,"ptr",$LPDWORDLENGTH)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,DllStructGetData($DLLSlpvBuffer,1))
EndFunc

Func WinHttpQueryHeaders($hRequest,$dwInfoLevel,$lpdwIndex = 0)
Local $lpdwBufferLength = 1000
$DLLSDWORD = DllStructCreate("DWORD")
DllStructSetData($DLLSDWORD,1,$lpdwBufferLength)
$LPDWORDLENGTH = DllStructGetPtr($DLLSDWORD)
$DLLSlpvBuffer = DllStructCreate("WCHAR[" & $lpdwBufferLength & "]")
$lpvBuffer = DllStructGetPtr($DLLSlpvBuffer)
$BOOL = DllCall($Winhttp,"BOOL","WinHttpQueryHeaders","HANDLE",$hRequest,"DWORD",$dwInfoLevel, _
"wstr","","ptr",$lpvBuffer,"ptr",$LPDWORDLENGTH,"DWORD",0)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,DllStructGetData($DLLSlpvBuffer,1))
EndFunc

Func WinHttpOpen($pwszUserAgent,$dwAccessType = 0,$lpszProxyName = "",$lpszProxyBypass = "",$dwFlags = 0)
$HINTERNET = DllCall($Winhttp,"HANDLE","WinHttpOpen","wstr",$pwszUserAgent,"DWORD",$dwAccessType, _
"wstr",$lpszProxyName,"wstr",$lpszProxyBypass,"DWORD",$dwFlags)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func WinHttpConnect($hSession,$pswzServerName,$INTERNET_PORT,$dwReserved = 0)
$HINTERNET = DllCall($Winhttp,"HANDLE","WinHttpConnect","HANDLE",$hSession,"wstr",$pswzServerName, _
"DWORD",$INTERNET_PORT,"DWORD",$dwReserved)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func WinHttpOpenRequest($hConnect,$pwszVerb,$pwszObjectName,$pwszVersion = "",$pwszReferrer = "",$ppwszAcceptTypes = 0,$dwFlags = 0)
$HINTERNET = DllCall($Winhttp,"HANDLE","WinHttpOpenRequest","HANDLE",$hConnect,"wstr",$pwszVerb, _
"wstr",$pwszObjectName,"wstr",$pwszVersion,"wstr",$pwszReferrer,"ptr",$ppwszAcceptTypes,"DWORD",$dwFlags)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func WinHttpSendRequest($hRequest,$pwszHeaders = "",$dwHeadersLength = 0,$lpOptional = 0, _
$dwOptionalLength = 0,$dwTotalLength = 0,$dwContext = 0)
$HINTERNET = DllCall($Winhttp,"HANDLE","WinHttpSendRequest","HANDLE",$hRequest,"wstr",$pwszHeaders, _
"DWORD",$dwHeadersLength,"ptr",$lpOptional,"DWORD",$dwOptionalLength,"DWORD",$dwTotalLength,"ptr",$dwContext)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func WinHttpReceiveResponse($hRequest)
$HINTERNET = DllCall($Winhttp,"BOOL","WinHttpReceiveResponse","HANDLE",$hRequest,"ptr",0)
if @error Or Not ($HINTERNET[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$HINTERNET[0])
EndFunc

Func WinHttpCrackUrl($lpszUrl,$dwUrlLength,$dwFlags)
$tagURL_COMPONENTS = "DWORD dwStructSize;ptr lpszScheme;DWORD dwSchemeLength;DWORD nScheme;ptr lpszHostName;" & _
"DWORD dwHostNameLength;DWORD nPort;ptr lpszUserName;DWORD dwUserNameLength;ptr lpszPassword;" & _
"DWORD dwPasswordLength;ptr lpszUrlPath;DWORD dwUrlPathLength;ptr lpszExtraInfo;DWORD dwExtraInfoLength"
$URL_COMPONENTS = DllStructCreate($tagURL_COMPONENTS)
$lpszHostName = DllStructCreate("WCHAR[1024]")
$szPath = DllStructCreate("WCHAR[1024]")
DllStructSetData($URL_COMPONENTS,"dwStructSize",DllStructGetSize($URL_COMPONENTS))
DllStructSetData($URL_COMPONENTS,"lpszHostName",DllStructGetPtr($lpszHostName))
DllStructSetData($URL_COMPONENTS,"lpszUrlPath",DllStructGetPtr($szPath))
DllStructSetData($URL_COMPONENTS,"dwUrlPathLength",1024)
DllStructSetData($URL_COMPONENTS,"dwHostNameLength",1024)
$Return = DllCall($Winhttp,"BOOL","WinHttpCrackUrl","wstr",$lpszUrl,"DWORD",$dwUrlLength _
,"DWORD",$dwFlags,"ptr",DllStructGetPtr($URL_COMPONENTS))
if @error Or Not ($Return[0]) Then Return SetError(1,0,0)
Return SetError(0,0,$URL_COMPONENTS)
EndFunc

Func WinHttpCloseHandle($hInternet)
$BOOL = DllCall($Winhttp,"BOOL","WinHttpCloseHandle","HANDLE",$hInternet)
if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,$BOOL[0])
EndFunc

Func HexBinary($Value)
Return Hex(Binary($Value))
EndFunc

Func GUICtrlSetOnEventEx($Control_ID_HWnd,$NotificationCode,$Function)
$handle = DLLCallbackRegister($Function,"none","int;int")
if $handle = 0 Then Return False
DllCallbackFree($handle)
if IsHWnd($Control_ID_HWnd) Then
$hWnd = $Control_ID_HWnd
$ControlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd)
If @error Then Return False
$ControlID = $ControlID[0]
if Not ($ControlID) Then Return False
Else
$ControlID = $Control_ID_HWnd
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
EndIf
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
if Not IsDllStruct($NotifyStruct) Then
Local $count = 1
$Len = StringLen($Function)
$TagNotifyStruct = _
"int count;WPARAM WPARAM;LPARAM LPARAM;int Test;int " & String($hWnd & $iNotificationCode) &  _
";HWND HWND" & String($count) &  ";int ControlID" & String($count) & ";int NotificationCode" & _
String($count) & ";char Function" & String($count) & "[" & String($Len) & "]"
$NotifyStruct = DllStructCreate($TagNotifyStruct)
DllStructSetData($NotifyStruct,"count",$count)
DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count)
DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd)
DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID)
DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode)
DllStructSetData($NotifyStruct,"Function" & String($count),$Function)
Else
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if ($count) Then Return False
Local $count = DllStructGetData($NotifyStruct,"count") + 1
$Len = StringLen($Function)
$TagNotifyStruct &= _
";int " & String($hWnd & $iNotificationCode) & ";HWND HWND" & String($count) & _
";int NotificationCode" & String($count) & ";int ControlID" & String($count) & _
";char Function" & String($count) & "[" & String($Len) & "]"
$iLength = DllStructGetSize($NotifyStruct)
$iNotifyStruct = DllStructCreate($TagNotifyStruct)
DllCall("kernel32.dll","none","RtlMoveMemory","ptr",DllStructGetPtr($iNotifyStruct) _
,"ptr",DllStructGetPtr($NotifyStruct),"ulong_ptr",$iLength)
$NotifyStruct = $iNotifyStruct
DllStructSetData($NotifyStruct,"count",$count)
DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count)
DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd)
DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID)
DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode)
DllStructSetData($NotifyStruct,"Function" & String($count),$Function)
EndIf
GUIRegisterMsg($WM_NOTIFY,"OnEventExProc")
GUIRegisterMsg($WM_COMMAND,"OnEventExProc")
Return True
EndFunc

Func OnEventExProc($hWnd,$Msg,$wParam,$lParam)
Select
Case $Msg = $WM_NOTIFY
Local $OnEventExtagNMHDR = "hwnd hWndFrom;uint_ptr IDFrom;INT Code"
$tNMHDR = DllStructCreate($OnEventExtagNMHDR, $lParam)
$MsgHwnd = DllStructGetData($tNMHDR, "hWndFrom")
$MsgCode = DllStructGetData($tNMHDR, "Code")
Case $Msg = $WM_COMMAND
$MsgHwnd = $lParam
$MsgCode = BitShift($wParam, 16)
EndSelect
$iMsgCode = $MsgCode
if StringInStr($MsgCode,"-") Then _
$iMsgCode = StringReplace($MsgCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($MsgHwnd & $iMsgCode))
if Not ($count) Then Return $GUI_RUNDEFMSG
DllStructSetData($NotifyStruct,"WPARAM",$wParam)
DllStructSetData($NotifyStruct,"LPARAM",$lParam)
$OnEvHWND = DllStructGetData($NotifyStruct,"HWND" & String($count))
$ControlID = DllStructGetData($NotifyStruct,"ControlID" & String($count))
$OnEvNotificationCode = DllStructGetData($NotifyStruct,"NotificationCode" & String($count))
$OnEvFunction = DllStructGetData($NotifyStruct,"Function" & String($count))
DllStructSetData($NotifyStruct,"Test",1)
if ($MsgHwnd = $OnEvHWND And $MsgCode = $OnEvNotificationCode) Then _
Call($OnEvFunction,$ControlID,$OnEvNotificationCode)
DllStructSetData($NotifyStruct,"Test",0)
Return $GUI_RUNDEFMSG
EndFunc

Func OnEventExGetWParam($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"WPARAM")
EndFunc

Func OnEventExGetLParam($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"LPARAM")
EndFunc

Func OnEventExGetHWND($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"HWND" & String($count))
EndFunc

Func _WinAPI_CloseHandle($hObject)
    Local $aResult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject)
    If @error Then Return SetError(@error, @extended, False)

    Return $aResult[0]
EndFunc

Func _WinAPI_CreateFile($sFileName, $iCreation, $iAccess = 4, $iShare = 0, $iAttributes = 0, $pSecurity = 0)
    Local $iDA = 0, $iSM = 0, $iCD = 0, $iFA = 0

    If BitAND($iAccess, 1) <> 0 Then $iDA = BitOR($iDA, $GENERIC_EXECUTE)
    If BitAND($iAccess, 2) <> 0 Then $iDA = BitOR($iDA, $GENERIC_READ)
    If BitAND($iAccess, 4) <> 0 Then $iDA = BitOR($iDA, $GENERIC_WRITE)

    If BitAND($iShare, 1) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_DELETE)
    If BitAND($iShare, 2) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_READ)
    If BitAND($iShare, 4) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_WRITE)

    Switch $iCreation
        Case 0
            $iCD = $CREATE_NEW
        Case 1
            $iCD = $CREATE_ALWAYS
        Case 2
            $iCD = $OPEN_EXISTING
        Case 3
            $iCD = $OPEN_ALWAYS
        Case 4
            $iCD = $TRUNCATE_EXISTING
    EndSwitch

    If BitAND($iAttributes, 1) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_ARCHIVE)
    If BitAND($iAttributes, 2) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_HIDDEN)
    If BitAND($iAttributes, 4) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_READONLY)
    If BitAND($iAttributes, 8) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_SYSTEM)

    Local $aResult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sFileName, "dword", $iDA, "dword", $iSM, _
            "ptr", $pSecurity, "dword", $iCD, "dword", $iFA, "ptr", 0)
    If @error Or ($aResult[0] = $INVALID_HANDLE_VALUE) Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc   ;==>_WinAPI_CreateFile

Func _WinAPI_ReadFile($hFile, $pBuffer, $iToRead, ByRef $iRead, $pOverlapped = 0)
    Local $aResult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hFile, "ptr", $pBuffer, "dword", $iToRead, _
            "dword*", 0, "ptr", $pOverlapped)
    If @error Then Return SetError(@error, @extended, False)

    $iRead = $aResult[4]
    Return $aResult[0]
EndFunc

Func _WinAPI_WriteFile($hFile, $pBuffer, $iToWrite, ByRef $iWritten, $pOverlapped = 0)
    Local $aResult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hFile, "ptr", $pBuffer, "dword", $iToWrite, _
            "dword*", 0, "ptr", $pOverlapped)
    If @error Then Return SetError(@error, @extended, False)

    $iWritten = $aResult[4]
    Return $aResult[0]
EndFunc


Func _WinAPI_LoadLibrary($sFileName)
    Local $aResult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sFileName)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc

Func _WinAPI_GetProcAddress($hModule, $vName)
    Local $sType = "str"
    If IsNumber($vName) Then $sType = "word" ; if ordinal value passed
    Local $aResult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hModule, $sType, $vName)
    If @error Or Not $aResult[0] Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc



Func CreateButtonHover($Text,$L,$T,$W,$H,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR = 0,$Font = True)

Local $tagButtonHover = "HWND HWNDA;HWND HWNDB;INT TPRESS;INT THOVER;PTR NORMAL;PTR OVER;PTR PRESS;INT MSGLOG"
Local $STM_SETIMAGE_HOVER = 0x0172 , $SS_BITMAP_HOVER = 0x0000000E _
 , $SS_REALSIZECONTROL_HOVER  =  0x00000040  ,  $STN_CLICKED  =  0

Local $SS_CENTERIMAGE = 0x0200 , $SS_CENTER = 0x01
$controlID1 = GUICtrlCreateLabel("",$L,$T,$W,$H,BitOR($SS_REALSIZECONTROL_HOVER,$SS_BITMAP_HOVER))
if @error Then Return SetError(1,0,0)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$hWndA = GUICtrlGetHandle($controlID1)

$controlID2 = GUICtrlCreateLabel($Text,$L,$T,$W,$H,BitOR($SS_CENTERIMAGE,$SS_CENTER))
if @error Then
GUICtrlDelete($controlID1)
Return SetError(2,0,0)
EndIf

$hWndB = GUICtrlGetHandle($controlID2)
$MSGLOG  = _WinAPI_MakeLong($controlID2,$STN_CLICKED)
GUICtrlSetBkColor (  -1 ,   $GUI_BKCOLOR_TRANSPARENT)
if ($TEXTCOLOOR) Then GUICtrlSetColor(-1,$TEXTCOLOOR)


if Not(DllStructGetData($StructBHover,"COUNT")) Then

$StructButtonHover = DllStructCreate($tagButtonHover)

DllStructSetData($StructButtonHover,"NORMAL",$NORMAL_hBMP)
DllStructSetData($StructButtonHover , "OVER" , $OVER_hBMP)
DllStructSetData($StructButtonHover ,"PRESS", $PRESS_hBMP)
DllStructSetData($StructButtonHover  , "HWNDA"  ,  $hWndA)
DllStructSetData($StructButtonHover  , "HWNDB"  ,  $hWndB)
DllStructSetData($StructButtonHover , "MSGLOG"  , $MSGLOG)

$ButtonHoverPtr  = DllStructGetPtr( $StructButtonHover )
DllStructSetData($StructBHover,"BHOVER",$ButtonHoverPtr)
DllStructSetData($StructBHover,"COUNT",1)

Else

ControlThread(1,True,True)

$COUNT = DllStructGetData($StructBHover,"COUNT")
$NewtagButtonHover = "BYTE [" & ($COUNT * $StructBHSize) & "];" & $tagButtonHover
$NewStructButtonHover = DllStructCreate($NewtagButtonHover)

$NewStructButtonHoverPtr    =    DllStructGetPtr(    $NewStructButtonHover   )
DllCall("kernel32.dll","none","RtlMoveMemory","ptr", $NewStructButtonHoverPtr, _
"ptr",DllStructGetPtr($StructButtonHover),"ulong_ptr",($COUNT * $StructBHSize))

DllStructSetData($NewStructButtonHover,"NORMAL",$NORMAL_hBMP)
DllStructSetData($NewStructButtonHover , "OVER" , $OVER_hBMP)
DllStructSetData($NewStructButtonHover ,"PRESS", $PRESS_hBMP)
DllStructSetData($NewStructButtonHover  , "HWNDA"  ,  $hWndA)
DllStructSetData($NewStructButtonHover  , "HWNDB"  ,  $hWndB)
DllStructSetData($NewStructButtonHover , "MSGLOG"  , $MSGLOG)

DllStructSetData($StructBHover,"BHOVER",$NewStructButtonHoverPtr)
DllStructSetData($StructBHover,"COUNT",$COUNT + 1)

$StructButtonHover = $NewStructButtonHover
$NewStructButtonHover = 0

ControlThread(1,False)

EndIf

_SendMessage($hWndA,$STM_SETIMAGE_HOVER,0,$NORMAL_hBMP)

if Not($ThreadPtr) Then
$ThreadPtr = DllStructGetPtr($ThreadAdd)
CreateThread($ThreadPtr,0)
EndIf

Return SetError (0,$controlID1,$controlID2)

EndFunc

Func DeleteButtonHover($controlID)

Local $tagButtonHover = "HWND  HWNDA;HWND  HWNDB;INT  TPRESS;INT  THOVER;PTR  NORMAL;PTR OVER;PTR PRESS;INT MSGLOG"
Local $ZStructButtonHoverPtr = DllStructGetPtr($StructButtonHover) , $FindTest = False, $YStructButtonHover,$YhWndB

Local $XhWndB = GUICtrlGetHandle($controlID)
if @error Then Return SetError(1,0,False)

Local $COUNT = DllStructGetData($StructBHover,"COUNT")
if @error Then Return SetError(2,0,False)

if $COUNT = 1 Then
$YStructButtonHover = DllStructCreate($tagButtonHover,$ZStructButtonHoverPtr)
$YhWndB = DllStructGetData($YStructButtonHover,"HWNDB")
if $YhWndB = $XhWndB Then
ControlThread(1,True,True)
DllStructSetData($StructBHover,"BHOVER",0)
DllStructSetData($StructBHover,"COUNT",0)
$StructButtonHover = 0
GUICtrlDelete($controlID - 1)
GUICtrlDelete($controlID)
ControlThread(1,False)
Return SetError(0,0,True)
EndIf
Return SetError(3,0,False)
EndIf

For $Offset = 0 To ($COUNT - 1)
$YStructButtonHover = DllStructCreate($tagButtonHover,$ZStructButtonHoverPtr + ($Offset * $StructBHSize))
$YhWndB = DllStructGetData($YStructButtonHover,"HWNDB")
if $YhWndB = $XhWndB Then
$FindTest = True
ExitLoop
EndIf
Next

if $FindTest = False Then Return SetError(4,0,False)

ControlThread(1,True,True)

Local $XStructButtonHover = DllStructCreate("BYTE [" & (($COUNT - 1) * $StructBHSize) & "]")
Local $XStructButtonHoverPtr = DllStructGetPtr($XStructButtonHover)

DllCall("kernel32.dll","none","RtlMoveMemory","ptr",$XStructButtonHoverPtr, _
"ptr" ,$ZStructButtonHoverPtr,"ulong_ptr" , ($Offset * $StructBHSize))

DllCall("kernel32.dll","none","RtlMoveMemory","ptr",$XStructButtonHoverPtr + ($Offset * $StructBHSize),"ptr", _
$ZStructButtonHoverPtr + (($Offset + 1) * $StructBHSize) ,"ulong_ptr",((($COUNT - ($Offset + 1))) * $StructBHSize))

DllStructSetData($StructBHover,"BHOVER",$XStructButtonHoverPtr)
DllStructSetData($StructBHover,"COUNT",$COUNT - 1)

$StructButtonHover = $XStructButtonHover

GUICtrlDelete($controlID - 1)
GUICtrlDelete($controlID)

ControlThread(1,False)

Return SetError(0,0,True)

EndFunc


Func _WinAPI_MakeLong($iLo, $iHi)
    Return BitOR(BitShift($iHi, -16), BitAND($iLo, 0xFFFF))
EndFunc

Func LoadThread()

Local $IntSize = 4 ,$JZEnd , $JZTA ,$CThread
Local $OffSelpParameter = $PointerSize,$LOOPA,$End,$TA,$OffSetHwndA = 0,$TB,$JMPEND
Local $JZEnd , $JMPTB , $LOOPB , $AsmVarPtr = DllStructGetPtr($AsmVar) , $JZCThread

For $i = 1 To 2

$_ASMCode =  "0x"

$LOOPA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "BF" & HexBinary($AsmVarPtr) ;mov edi,$AsmVarPtr
$_ASMCode &= "BB" & HexBinary($StructBHoverPtr) ;mov ebx,$StructBHoverPtr
$_ASMCode &= "8B13" ;mov edx,[ebx]
$_ASMCode &= "8917" ;mov [edi],edx
$_ASMCode &= "8B5B" & Hex($IntSize,2) ;mov ebx,[ebx + $IntSize]
$_ASMCode &= "895F" & Hex($IntSize,2) ;mov [edi + $IntSize],ebx

$_ASMCode &= "B8" & HexBinary($PositionsStPtr) ;mov eax,$PositionsStPtr
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($G_CP) ;mov eax,GetCursorPos
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary($PositionsStPtr) ;mov eax,$PositionsStPtr
$_ASMCode &= "FF70" & Hex($IntSize,2) ;push [eax + $IntSize]
$_ASMCode &= "FF30" ;push [eax]
$_ASMCode &= "B8" & HexBinary($_WnFPos) ;mov eax,WindowFromPoint
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "8947" & Hex(($IntSize + $PointerSize),2) ;mov [edi + ($IntSize + $PointerSize)],eax

$LOOPB = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8038" & Hex(0,2) ;CMP [eax],0
$_ASMCode &= "74" & Hex(($End - $JZEnd),2) ;JZ $End;
$JZEnd = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "8B3B" ;mov edi,[ebx] ; // Get HWNDA
$_ASMCode &= "8B40" & Hex(($IntSize + $PointerSize),2) ;mov eax,[eax + ($IntSize + $PointerSize)] // Get CurrentHwnd

$_ASMCode &= "3BF8" ;CMP edi,eax
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "B8" & HexBinary($MNHoverPtr) ;mov eax,$MNHoverPtr
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $TB
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "B8" & HexBinary($MHoverPtr) ;mov eax,$MHoverPtr
$_ASMCode &= "FFD0" ;call eax

$TB = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8028" & Hex(1,2) ;sub [eax],1
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "83C3" & Hex($StructBHSize,2) ;add ebx,$StructBHSize
$_ASMCode &= "8958" & Hex($IntSize,2) ;mov [eax + $IntSize],ebx

$JMPLOOPB = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPLOOPB - $LOOPB) + 5)) ;JMP $LOOPB

$End = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(DllStructGetPtr($ControlThread)) ;mov eax,$ControlThread
$_ASMCode &= "8038" & Hex(1,2) ;CMP [eax],1
$_ASMCode &= "74" & Hex(($CThread - $JZCThread),2) ;JZ $CThread
$JZCThread = BinaryLen($_ASMCode)

$JMPLOOPA = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPLOOPA - $LOOPA) + 5)) ;JMP LOOPA

$CThread = BinaryLen($_ASMCode)

$_ASMCode &= "C640" & Hex($IntSize,2) & Hex(1,2) ;mov [eax + $IntSize],1

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$JMPEND = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPEND - $End) + 5)) ;JMP End

$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LMHover() ;Mouse Hover

Local $OffSetTpress = 8 , $TA    ,  $JZTA  ,  $TB  ,  $JMPTB  ,   $OffSetStructBHoverPtr  =  $PointerSize

For $i = 1 To 2

$_ASMCode =  "0x"
$_ASMCode &= "B8" & HexBinary(0x01) ;mov eax,$VK_LBUTTON
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($GKYState) ;mov eax,GetKeyState
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "25" & HexBinary(0x8000) ; and eax,0x8000 // bitwise AND // eax = BitAND(eax,0x8000)
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "FF7424" & Hex($OffSetStructBHoverPtr,2) ;push [esp + $OffSetStructBHoverPtr]
$_ASMCode &= "B8" & HexBinary($IsPssPtr) ;mov eax,$IsPssPtr
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $JMPTD
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)
$_ASMCode &= "FF7424" & Hex($OffSetStructBHoverPtr,2) ;push [esp + $OffSetStructBHoverPtr]
$_ASMCode &= "B8" & HexBinary($IsNPssPtr) ;mov eax,$IsNPssPtr
$_ASMCode &= "FFD0" ;call eax

$TB = BinaryLen($_ASMCode)
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //--------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LIsPress()

Local $OffSetTpress = 8 ,  $OffSetStructBHoverPtr = $PointerSize , $OffSetPBmp = 24
Local $STM_SETIMAGE_HOVER=0x0172,$OffSetThover=12,$OffSetHwndA = 0,$OffSetHBmp = 20
Local $TA , $JZTA , $TB , $JZTB , $JMPTC1 , $TC , $JMPTC2 , $TC  , $OffSetHwndB = 4

For $i = 1 To 2

$_ASMCode =  "0x"

$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TB - $JZTB),2) ;JZ $JZTB;
$JZTB = BinaryLen($_ASMCode)

$_ASMCode &= "EB" & Hex(($TC - $JMPTC1),2) ;JMP $JMPTC1
$JMPTC1 = BinaryLen($_ASMCode)

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetHBmp,2) ;mov eax,[ebx + $OffSetHBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(1,2) ;mov [ebx + $OffSetThover],1
$_ASMCode &= "EB" & Hex(($TC - $JMPTC2),2) ;JMP $JMPTC2
$JMPTC2 = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetPBmp,2) ;mov eax,[ebx + $OffSetPBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(1,2) ;mov [ebx + $OffSetTpress],1

$TC = BinaryLen($_ASMCode)
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LIsNotPress()

Local $OffSetPBmp = 24 , $OffSetTpress = 8  ,  $OffSetStructBHoverPtr = $PointerSize
Local $STM_SETIMAGE_HOVER = 0x0172 , $OffSetThover = 12 , $SSenMsg , $IntSize = 4,$TC,$TD,$JZTD,$JZStopSendMsg
Local $OffSetHwndB = 4 , $OffSetHBmp = 20 , $OffsetMsgLog = 28 , $OffSetHwndA = 0 , $TA,$JZTA,$JMPTB,$TB,$JZTC

For $i = 1 To 2

$_ASMCode =  "0x"
$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(1,2) ;CMP eax,1
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $JMPTB
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(DllStructGetPtr($ControlThread)) ;mov eax,$ControlThread
$_ASMCode &= "8078" & Hex(($IntSize * 2),2) & Hex(1,2) ;CMP [eax + ($IntSize * 2)],1
$_ASMCode &= "74" & Hex(($SSenMsg - $JZStopSendMsg),2) ;JZ $StopSendMsg
$JZStopSendMsg = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($_GtPt) ;mov eax,GetParent
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "8BF8" ;mov edi,eax

$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffsetMsgLog,2) ;mov eax,[ebx + $OffsetMsgLog]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($WM_COMMAND) ;mov eax,$WM_COMMAND
$_ASMCode &= "50" ;push eax
$_ASMCode &= "57" ;push edi
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$SSenMsg = BinaryLen($_ASMCode) ; StopSendMsg
$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(0,2) ;mov [ebx + $OffSetThover],0
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(1,2) ;CMP eax,1
$_ASMCode &= "74" & Hex(($TC - $JZTC),2) ;JZ $JZTC;
$JZTC = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(1,2) ;mov [ebx + $OffSetThover],1
$_ASMCode &= "8B43" & Hex($OffSetHBmp,2) ;mov eax,[ebx + $OffSetHBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$TC = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(3,2) ;CMP eax,3
$_ASMCode &= "74" & Hex(($TD - $JZTD),2) ;JZ $JZTD;
$JZTD = BinaryLen($_ASMCode)

;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

$TD = BinaryLen($_ASMCode)
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LMNHover() ;Mouse Not Hover

Local $OffSetNBmp  =  16 , $OffSetThover = 12 , $OffSetHwndA = 0 , $OffSetTpress = 8 , $STM_SETIMAGE_HOVER = 0x0172
Local $OffSetStructBHoverPtr = $PointerSize,$TA  ,  $JZTA    ,   $TB    ,  $JZTB  , $TC  ,  $JMPTC,$OffSetHwndB = 4

For $i = 1 To 2

$_ASMCode =  "0x"

$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetNBmp,2) ;mov eax,[ebx + $OffSetNBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(0,2) ;mov [ebx + $OffSetThover],0

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(0x01) ;mov eax,$VK_LBUTTON
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($GKYState) ;mov eax,GetKeyState
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "25" & HexBinary(0x8000) ; and eax,0x8000 // bitwise AND // eax = BitAND(eax,0x8000)
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TB - $JZTB),2) ;JZ $JZTB;
$JZTB = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(3,2) ;mov [ebx + $OffSetTpress],3
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func ControlThread($Flag = 1,$BOOL = True , $Wait = False)

; $Flag = 1 Continue Thread Loop // $BOOL = True Or $BOOL = False
; $Flag = 2 Stop Msg Send // // $BOOL = True Or $BOOL = False
; $Wait True Or False Wait Start Continue Of Thread Loop

Switch $Flag
Case 1
DllStructSetData($ControlThread, "TA" , 0 )
DllStructSetData($ControlThread, "TB" , 0 )
if ($BOOL) Then
DllStructSetData($ControlThread, "TA" , 1 )
if ($Wait) Then
While DllStructGetData($ControlThread,"TB") == 0
WEnd
Return True
Else
Return True
EndIf
Else
DllStructSetData($ControlThread, "TA" , 0 )
DllStructSetData($ControlThread, "TB" , 0 )
Return True
EndIf
Case 2
if ($BOOL) Then
DllStructSetData($ControlThread, "TC" , 1 )
Else
DllStructSetData($ControlThread, "TC" , 0 )
EndIf
Return True
Case Else
Return False
EndSwitch

EndFunc

Func LoadBitmap_FromFile($sFileName)
Return _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0),$sFileName,0 ,0,0,0x0010)
EndFunc

Func LoadBitmap_FromResources($resource_Name)
Return _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(0), $resource_Name)
EndFunc

Func _WinAPI_LoadBitmap($hInstance, $sBitmap)
    Local $sBitmapType = "int"
    If IsString($sBitmap) Then $sBitmapType = "wstr"
    Local $aResult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hInstance, $sBitmapType, $sBitmap)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc

Func _WinAPI_GetModuleHandle($sModuleName)
    Local $sModuleNameType = "wstr"
    If $sModuleName = "" Then
        $sModuleName = 0
        $sModuleNameType = "ptr"
    EndIf

    Local $aResult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $sModuleNameType, $sModuleName)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc

Func _WinAPI_LoadImage($hInstance, $sImage, $iType, $iXDesired, $iYDesired, $iLoad)
    Local $aResult, $sImageType = "int"
    If IsString($sImage) Then $sImageType = "wstr"
    $aResult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hInstance, $sImageType, $sImage, "uint", $iType, _
            "int", $iXDesired, "int", $iYDesired, "uint", $iLoad)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc   ;==>_WinAPI_LoadImage



Func _WinAPI_RedrawWindow($hWnd, $tRect = 0, $hRegion = 0, $iFlags = 5)
    Local $aResult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hWnd, "struct*", $tRect, "handle", $hRegion, _
            "uint", $iFlags)
    If @error Then Return SetError(@error, @extended, False)

    Return $aResult[0]
EndFunc

Func _WinAPI_CreateCompatibleDC($hDC)
    Local $aResult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hDC)
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc

Func _WinAPI_DeleteDC($hDC)
    Local $aResult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hDC)
    If @error Then Return SetError(@error, @extended, False)

    Return $aResult[0]
EndFunc

Func _WinAPI_SelectObject($hDC, $hGDIObj)
    Local $aResult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hGDIObj)
    If @error Then Return SetError(@error, @extended, False)

    Return $aResult[0]
EndFunc

Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
    Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
    If @error Then Return SetError(@error, @extended, "")
    If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
    Return $aResult
EndFunc   ;==>

Func WindowFromDC($hDC)
$HWND = DllCall("User32.dll","ptr","WindowFromDC","ptr",$hdc)
if @error Or $HWND[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,$HWND[0])
EndFunc

 

 

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

This tool was in the Arabic language. I changed the window texts into English and translated the other information. Therefore, errors occurred in the windows texts during the modification, and now everything is correct .. Thank you.

صرح السماء كان هنا

 

Link to comment
Share on other sites

7 hours ago, VIP said:

Use this tool can't download speed >1MB/s !

Use any brower with my internet speed 50Mbps. I get 3~4MB/s

Use IDM i get 5MB/s !

I don’t know, but I have a high download speed with the tool ... Try measuring the download time for an entire file using the tools and using IDM, then compare the time and tell us .. Thanks.

صرح السماء كان هنا

 

Link to comment
Share on other sites

7 hours ago, argumentum said:

54 mb down / 12 up / 19 ms. . This is in Miami. Maybe I'm closer to the server than you all.

You have tested the network. This is good. Your networks are well developed and have high quality. Our networks keep pace with development, but the quality is low.

صرح السماء كان هنا

 

Link to comment
Share on other sites

Quite nice tool.


I would like to sugest you few TODO:

  1. use Tidy in your code
  2. use #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
  3. enclose main code in function
  4. try to create UDF from this function which you are using in your tool and create this Tool as an example of how to use proposed UDF

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

3 hours ago, mLipok said:

Quite nice tool.


I would like to sugest you few TODO:

  1. use Tidy in your code
  2. use #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
  3. enclose main code in function
  4. try to create UDF from this function which you are using in your tool and create this Tool as an example of how to use proposed UDF

 

 

Maybe I will do that later ... Now I have other interests that deserve the tool to be a library ... But the problem with using assembly language code is that this code does not work on Windows server systems, I don’t know why… Anyway thank you and for your concern ... greeting.

صرح السماء كان هنا

 

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...