Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/26/2016 in all areas

  1. When you create an input box you can set the length of characters, digits only, Uppercase, Center like this. GUICtrlCreateInput Style Options $ES_NUMBER == Accepts only digits [0-9] $ES_UPPERCASE == Converts all characters to uppercase $ES_LOWERCASE == Converts all characters to lowercase $ES_CENTER == Centers text GUICtrlSetLimit ( controlID, max , OPTIONAL min ) == so you can set a max and min character length for an input control  $UserInput = GUICtrlCreateInput("", 120, 292, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER,$ES_NUMBER))   GUICtrlSetLimit($UserInput, 10) ; Limit User Input to 10 Characters, can also just use -1 instead of variable of input box if this line is directly under like here
    1 point
  2. A slight optional addition for a better look Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ;.... If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ ($mod = 0 and $char = "-")) Then GUICtrlSetData($input, StringTrimRight($content, 1)) Else GUICtrlSetData($input, StringUpper($content)) EndIf
    1 point
  3. This should work to do it dynamically #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 232, 90) $Label = GUICtrlCreateLabel("Enter MAC address", 22, 8, 163, 17) $input = GUICtrlCreateInput("", 22, 30, 165, 24) GUICtrlSetLimit(-1, 17) GUICtrlSetFont(-1, 12) GUISetState() GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While 1 Sleep(10) WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $id = BitAND($wParam, 0x0000FFFF) Local $code = BitShift($wParam, 16) If $id = $input AND $code = $EN_UPDATE Then Local $content = GUICtrlRead($input) Local $len = StringLen($content) Local $char = StringRight($content, 1) Local $mod = Mod($len, 3) If not (( ($mod = 1 or $mod = 2) and StringRegExp($char, '[[:xdigit:]]') ) OR _ ($mod = 0 and $char = "-")) Then GUICtrlSetData($input, StringTrimRight($content, 1)) EndIf Return $GUI_RUNDEFMSG EndFunc Func _Exit() Exit EndFunc
    1 point
  4. Danyfirex

    If Then Help

    You can handle that based in window control text. You can do something like this. #include <WinAPI.au3> #include <ScreenCapture.au3> Local $sASSSDBenchmarkTitle = "AS SSD Benchmark 1.9.5986.35387" Local $sASSSDBenchmarkFullPath = "AS SSD Benchmark.exe" ShellExecute($sASSSDBenchmarkFullPath) Local $hWindow = WinWaitActive($sASSSDBenchmarkTitle) ControlClick($hWindow, "", _MakeNetClassNN($hWindow, "BUTTON", "6")) Local $sText = "" While Sleep(30) $sText = ControlGetText($hWindow, "", _MakeNetClassNN($hWindow, "STATIC", "21")) If Not WinExists($sASSSDBenchmarkTitle) Then Exit MsgBox(64, "Error", "Cant Find AS SSD Benchmark window. bye bye") $sText = StringReplace($sText, ",", ".") If $sText <> "0.000 ms" Then _ScreenCapture_CaptureWnd(@ScriptDir & "\" & $sText & ".jpg", "AS SSD Benchmark 1.9.5986.35387") MsgBox(64, "Success!!!", "Text Found!!!") ShellExecute(@ScriptDir & "\" & $sText & ".jpg") ExitLoop EndIf WEnd Func _MakeNetClassNN($hwnd, $sControlType, $sIndexNN) Local $sStringClass = _WinAPI_GetClassName($hwnd) Local $sStringWin = StringMid($sStringClass, 1, StringInStr($sStringClass, ".")) Return $sStringWin & $sControlType & StringMid($sStringClass, StringInStr($sStringClass, ".app")) & $sIndexNN EndFunc ;==>_MakeNetClassNN Saludos
    1 point
  5. True fact: You are not making many friends here. And you have already been given the answer. Check this page for some examples that may help you on your journey.
    1 point
  6. The brackets [] denote (optional and default values) parameters. They should not be supplied to a function, just the acceptable input values/types for the given function. edit: in fact, there appear to be other parameters that proceed the visible param. You'll need to set them too. From the help file, " Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all preceding parameters must be specified!For example, consider Run ( "filename", ["workingdir" [, flag]] ). If you wish to specify the flag, you must specify a workingdir. " So, for the _IECreate function _IECreate ( [$sUrl = "about:blank" [, $iTryAttach = 0 [, $iVisible = 1 [, $iWait = 1 [, $iTakeFocus = 1]]]]] ) You would do _IECreate('http://google.com', 0, 0) Do not specify the name of the parameter variable...just the value you want to assign. ;BAD _IECreate ($sUrl = "about:blank", $iTryAttach = 0, $iVisible = 0) ;Good _IECreate("about:blank", 0, 0)
    1 point
  7. You can just remove Case True
    1 point
  8. #include <Array.au3> Example() Func Example() Local $aArray[6][2] For $i = 0 To UBound($aArray) - 1 For $j = 0 To $aArray $aArray[$i][$j] = $i $aArray[$i][1] = $i Next Next _ArrayDisplay($aArray) ; Display the array. EndFunc ;==>Example
    1 point
  9. I'm not sure if this is the cleanest option, but I found confortable doing this trough 2 Switches. Test it and let me know if it works well Local $x,$var Local $color = "0xE62121" Func DoSomething() ConsoleWrite("Doing something..."&@crlf) EndFunc Func DoNothing() ConsoleWrite("Doing nothing..."&@crlf) EndFunc For $x=0 to 4 Switch $x Case 0 ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf) $var = PixelSearch(67, 614, 77, 617,$color,10) Case 1 ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf) $var = PixelSearch(165, 614, 175, 617,$color,10) Case 2 ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf) $var = PixelSearch(265, 614, 275, 617,$color,10) Case 3 ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf) $var = PixelSearch(365, 614, 375, 617,$color,10) Case 4 ConsoleWrite("Searching pixel in area n° "&$x+1&@crlf) $var = PixelSearch(465, 614, 475, 617,$color,10) EndSwitch Switch @error Case True DoNothing() Case False DoSomething() EndSwitch Next
    1 point
  10. argumentum

    Sciter Dll UDF !

    hmmm, the original poster "Last visited September 27, 2010" and that's that. Now v. 1.0.10.10 from 11/11/1012 works. Too big to attach here, so here is a temporary link to it.
    1 point
  11. Danyfirex

    Scite Console Color

    Hello Guys. Recently I had to reinstall Autoit and Scite. But for some reason (I dont know) I got wrong console colors liek this picture. I read in this topic about that. I could not fix that issue. I'm using latest version of AutoIt and SciTE. I reinstalled them and still same issue. Even tried portable version and same issue. I also delete all %appdata% and instalation folder files. Does SciTE support to change this maybe editing something in .properties files? Saludos
    1 point
  12. WHAT This script restarts an executable (the AutoIT script itself called "cantstopme.exe", in this case) if any attempt of closure is done. WHY If you want to preserve critical admin task from potential stop attempts. HOW Pure AutoIT method. No batch file(s) are created. It clones itself and creates a self-protecting triangle in this way: - protector1.exe takes care of cantstopme.exe and protector2.exe - protector2.exe takes care of protector1.exe Its goal is to be unstoppable because thanks to auto-restart tecnique no process-trees exist, so conventional process managers can't kill. Furthermore there are no apparent relationships between involved processes. Executables cannot run more than once, so everything stay stable. CPU effort is very low. You can show an administrator alert message, same like I did in the script. INSTRUCTIONS You can change $Protector1Dir, $Protector1Name, $Protector2Dir, $Protector2Name as you want. You can replace the example loop code in "Your script here" section. Compile and run it. The only way to stop persistent generated 3 processes will be pressing CTRL+ALT+E or restarting your PC. If latter then you should manually delete Protectors to clean. SORRY Because almost no comments in the code. Anyway it's short and simple, and I'm here to explain if needed. SO Please test, comment, rate, enhance. Try to kill it! Do you think it is really bullet-proof? I hope someone can create an UDF (I'm not enough skilled to do it). If you like the topic there is one related by @guinness. #NoTrayIcon If @Compiled = 0 Then MsgBox(1, '"You cant stop it" AutoIT script by MasviL', "You should run it compiled!") Exit EndIf Local $Protector1Dir = @AppDataDir & "\protector1 dir" Local $Protector1Name = "protector1.exe" Local $Protector2Dir = @AppDataDir & "\protector2 dir" Local $Protector2Name = "protector2.exe" Persistent() ; =============================================== ; Your script here While 1 Sleep(1000) WEnd ; =============================================== Func Persistent() If @ScriptDir <> $Protector1Dir And @ScriptDir <> $Protector2Dir Then If $CmdLine[0] = 0 Then Local $aArray = ProcessList(@ScriptName) For $i = 1 To $aArray[0][0] If $aArray[$i][1] = @AutoItPID Then ContinueLoop $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, @ScriptDir) Then Exit EndIf Next FileCopy(@ScriptFullPath, $Protector1Dir & "\" & $Protector1Name, 9) Run($Protector1Dir & "\" & $Protector1Name & ' "' & @ScriptDir & '" ' & @ScriptName & " restart", $Protector1Dir) EndIf If $CmdLine[0] = 1 Then Run(@ScriptFullPath & " 1 2", @ScriptDir) Exit EndIf HotKeySet("^!e", "CloseAll") If FileExists(@ScriptDir & "\stop") Then FileDelete(@ScriptDir & "\stop") ; maybe useless MsgBox(0, '"You cant stop it" AutoIT script by MasviL', 'The only way to stop this script process "' & @ScriptName & '" will be pressing CTRL+ALT+E or restarting your PC.') EndIf If @ScriptDir = $Protector1Dir Then OnAutoItExitRegister("Terminate") ; Maybe useless If $CmdLine[0] = 0 Then Exit If $CmdLine[0] > 1 Then $ExeDir = $CmdLine[1] $ExeName = $CmdLine[2] EndIf If $CmdLine[0] = 3 Then Run(@ScriptFullPath & ' "' & $ExeDir & '" ' & $ExeName, @ScriptDir) Exit EndIf While 1 Sleep(500) If FileExists($ExeDir & "\stop") Then Exit WinKill("AutoIt Error") ; just in case $ExeRunning = 0 Local $aArray = ProcessList($ExeName) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $ExeDir) Then $ExeRunning = 1 EndIf Next If $ExeRunning = 0 Then FileCopy(@ScriptFullPath, $ExeDir & "\" & $ExeName, 9) Run($ExeDir & "\" & $ExeName & " restart", @ScriptDir) EndIf $Protector2Running = 0 Local $aArray = ProcessList($Protector2Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector2Dir) Then $Protector2Running = 1 EndIf Next If $Protector2Running = 0 Then FileCopy(@ScriptFullPath, $Protector2Dir & "\" & $Protector2Name, 9) Run($Protector2Dir & "\" & $Protector2Name & ' "' & $ExeDir & '" ' & $ExeName & " restart", @ScriptDir) EndIf WEnd EndIf If @ScriptDir = $Protector2Dir Then OnAutoItExitRegister("Terminate") ; Maybe useless If $CmdLine[0] = 0 Then Exit If $CmdLine[0] > 1 Then $ExeDir = $CmdLine[1] $ExeName = $CmdLine[2] EndIf If $CmdLine[0] = 3 Then Run(@ScriptFullPath & ' "' & $ExeDir & '" ' & $ExeName, @ScriptDir) Exit EndIf While 1 Sleep(500) If FileExists($ExeDir & "\stop") Then Exit WinKill("AutoIt Error") ; just in case $Protector1Running = 0 Local $aArray = ProcessList($Protector1Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector1Dir) Then $Protector1Running = 1 EndIf Next If $Protector1Running = 0 Then FileCopy(@ScriptFullPath, $Protector1Dir & "\" & $Protector1Name, 9) Run($Protector1Dir & "\" & $Protector1Name & ' "' & $ExeDir & '" ' & $ExeName & " restart", @ScriptDir) EndIf WEnd EndIf EndFunc ;==>Persistent Func Terminate() Exit EndFunc ;==>Terminate Func CloseAll() $Stop = FileOpen(@ScriptDir & "\stop", 1) FileClose($Stop) Local $aArray = ProcessList($Protector1Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector1Dir) Then ProcessWaitClose($aArray[$i][1]) EndIf Next Local $aArray = ProcessList($Protector2Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector2Dir) Then ProcessWaitClose($aArray[$i][1]) EndIf Next FileDelete(@ScriptDir & "\stop") DirRemove($Protector1Dir, 1) DirRemove($Protector2Dir, 1) MsgBox(262144, '"You cant stop it" AutoIT script by MasviL', 'Done! You got rid of it.') Exit EndFunc ;==>CloseAll Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation cantstopme.au3
    1 point
  13. I think the easiest would be to use a global variable: set to True or False depending on actions taken by the user. #include <GUIConstants.au3> Global $g__bEnable = False ; keep track of control status (also works with menu items) Example() Func Example() Local $hGUI = GUICreate("Example", 190, 100) Local $hAction = GUICtrlCreateButton("Enable", 10, 10, 80, 20) Local $hDisable = GUICtrlCreateButton("Disable", 100, 10, 80, 20) GUICtrlSetState(-1, $GUI_DISABLE) ; disable the last control created GUISetState(@SW_SHOW) Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $hAction If Not $g__bEnable Then GUICtrlSetState($hDisable, $GUI_ENABLE) ; check status (simple condition) $g__bEnable = True ; set to True Case $hDisable GUICtrlSetState($hDisable, $GUI_DISABLE) ; here we already know the control is active $g__bEnable = False ; set to False EndSwitch WEnd EndFunc This method works for other controls, including menu items. For multiple controls you should probably use an array of True and False values. This is just a simple example demonstrating how to monitor user interaction with GUI controls. In a real situation you may have a more complex set of conditions to test before enabling or disabling a control. Edit1: In addition, you might want to look at AdlibRegister which you could use to test the status of the global variable (or the control) every however many milliseconds. Edit2: Here's the same code which reads the control status instead of testing a global variable. #include <GUIConstants.au3> Example() Func Example() Local $hGUI = GUICreate("Example", 190, 100) Local $hAction = GUICtrlCreateButton("Enable", 10, 10, 80, 20) Local $hDisable = GUICtrlCreateButton("Disable", 100, 10, 80, 20) GUICtrlSetState(-1, $GUI_DISABLE) ; disable the last control created GUISetState(@SW_SHOW) Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $hAction If BitAnd(GUICtrlGetState($hDisable), $GUI_DISABLE) == $GUI_DISABLE Then GUICtrlSetState($hDisable, $GUI_ENABLE) ; check status (simple condition) Case $hDisable GUICtrlSetState($hDisable, $GUI_DISABLE) ; here we already know the control is active EndSwitch WEnd EndFunc  The second method is probably a bit cleaner, but uses more functions. The first method is a bit easier to write and the global can be more easily tested/modified at any time; after any (or all) user actions.
    1 point
  14. I have already made something like this... Download the XPDF tools (pdfinfo and pdftotext.) and try my script : ; #FUNCTION# ==================================================================================================================== ; Name...........: _XFDF_Info ; Description....: Retrives informations from a PDF file ; Syntax.........: _XFDF_Info ( "File" [, "Info"] ) ; Parameters.....: File - PDF File. ; Info - The information to retrieve ; Return values..: Success - If the Info parameter is not empty, returns the desired information for the specified Info parameter ; - If the Info parameter is empty, returns an array with all available informations ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external programm ; Remarks........: The array returned is two-dimensional and is made up as follows: ; $array[1][0] = Label of the first information (title, author, pages...) ; $array[1][1] = value of the first information ; ... ; =============================================================================================================================== Func _XFDF_Info($sPDFFile, $sInfo = "") Local $sXPDFInfo = @ScriptDir & "\pdfinfo.exe" If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFInfo) Then Return SetError(2, 0, 0) $sXPDFInfo = FileGetShortName($sXPDFInfo) Local $iPid = Run(@ComSpec & ' /c ' & $sXPDFInfo & ' "' & $sPDFFile & '"', @ScriptDir, @SW_HIDE, 2) Local $sResult While 1 $sResult &= StdoutRead($iPid) If @error Then ExitLoop WEnd Local $aInfos = StringRegExp($sResult, "(?m)^(.+?): +(.*)$", 3) If @error Or Mod( UBound($aInfos, 1), 2) = 1 Then Return SetError(3, 0, 0) Local $aResult [ UBound($aInfos, 1) / 2][2] For $i = 0 To UBound($aInfos) - 1 Step 2 If $sInfo <> "" AND $aInfos[$i] = $sInfo Then Return $aInfos[$i + 1] $aResult[$i / 2][0] = $aInfos[$i] $aResult[$i / 2][1] = $aInfos[$i + 1] Next If $sInfo <> "" Then Return "" Return $aResult EndFunc ; ---> _XFDF_Info ; #FUNCTION# ==================================================================================================================== ; Name...........: _XPDF_Search ; Description....: Retrives informations from a PDF file ; Syntax.........: _XFDF_Info ( "File" [, "String" [, Case = 0 [, Flag = 0 [, FirstPage = 1 [, LastPage = 0]]]]] ) ; Parameters.....: File - PDF File. ; String - String to search for ; Case - If set to 1, search is case sensitive (default is 0) ; Flag - A number to indicate how the function behaves. See below for details. The default is 0. ; FirstPage - First page to convert (default is 1) ; LastPage - Last page to convert (default is 0 = last page of the document) ; Return values..: Success - ; Flag = 0 - Returns 1 if the search string was found, or 0 if not ; Flag = 1 - Returns the number of occcurrences found in the whole PDF File ; Flag = 2 - Returns an array containing the number of occurrences found for each page ; (only pages containing the search string are returned) ; $array[0][0] - Number of matching pages ; $array[0][1] - Number of occcurrences found in the whole PDF File ; $array[n][0] - Page number ; $array[n][1] - Number of occcurrences found for the page ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external programm ; =============================================================================================================================== Func _XPDF_Search($sPDFFile, $sSearch, $iCase = 0, $iFlag = 0, $iStart = 1, $iEnd = 0) Local $sXPDFToText = @ScriptDir & "\pdftotext.exe" Local $sOptions = " -layout -f " & $iStart Local $iCount = 0, $aResult[1][2] = [[0, 0]], $aSearch, $sContent, $iPageOccCount If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFToText) Then Return SetError(2, 0, 0) If $iEnd > 0 Then $sOptions &= " -l " & $iEnd Local $iPid = Run($sXPDFToText & $sOptions & ' "' & $sPDFFile & '" -', @ScriptDir, @SW_HIDE, 2) While 1 $sContent &= StdoutRead($iPid) If @error Then ExitLoop WEnd Local $aPages = StringSplit($sContent, chr(12) ) For $i = 1 To $aPages[0] $iPageOccCount = 0 While StringInStr($aPages[$i], $sSearch, $iCase, $iPageOccCount + 1) If $iFlag <> 1 AND $iFlag <> 2 Then $aResult[0][1] = 1 ExitLoop EndIf $iPageOccCount += 1 WEnd If $iPageOccCount Then Redim $aResult[ UBound($aResult, 1) + 1][2] $aResult[0][1] += $iPageOccCount $aResult[0][0] = UBound($aResult) - 1 $aResult[ UBound($aResult, 1) - 1 ][0] = $i + $iStart - 1 $aResult[ UBound($aResult, 1) - 1 ][1] = $iPageOccCount EndIf Next If $iFlag = 2 Then Return $aResult Return $aResult[0][1] EndFunc ; ---> _XPDF_Search ; #FUNCTION# ==================================================================================================================== ; Name...........: _XPDF_ToText ; Description....: Converts a PDF file to plain text. ; Syntax.........: _XPDF_ToText ( "PDFFile" , "TxtFile" [ , FirstPage [, LastPage [, Layout ]]] ) ; Parameters.....: PDFFile - PDF Input File. ; TxtFile - Plain text file to convert to ; FirstPage - First page to convert (default is 1) ; LastPage - Last page to convert (default is last page of the document) ; Layout - If true, maintains (as best as possible) the original physical layout of the text ; If false, the behavior is to 'undo' physical layout (columns, hyphenation, etc.) ; and output the text in reading order. ; Default is True ; Return values..: Success - 1 ; Failure - 0, and sets @error to : ; 1 - PDF File not found ; 2 - Unable to find the external program ; =============================================================================================================================== Func _XPDF_ToText($sPDFFile, $sTXTFile, $iFirstPage = 1, $iLastPage = 0, $bLayout = True) Local $sXPDFToText = @ScriptDir & "\pdftotext.exe" Local $sOptions If NOT FileExists($sPDFFile) Then Return SetError(1, 0, 0) If NOT FileExists($sXPDFToText) Then Return SetError(2, 0, 0) If $iFirstPage <> 1 Then $sOptions &= " -f " & $iFirstPage If $iLastPage <> 0 Then $sOptions &= " -l " & $iLastPage If $bLayout = True Then $sOptions &= " -layout" Local $iReturn = ShellExecuteWait ( $sXPDFToText , $sOptions & ' "' & $sPDFFile & '" "' & $sTXTFile & '"', @ScriptDir, "", @SW_HIDE) If $iReturn = 0 Then Return 1 Return 0 EndFunc ; ---> _XPDF_ToText Original post on the french forum
    1 point
  15. See this example: #include <guiconstantsex.au3> #include <windowsconstants.au3> #include <buttonconstants.au3> _Example() ; example Func _Example() Local $iMsg, $iButton1 GUICreate("My GUI", 320, 240) ; will create a dialog box that when displayed is centered $iButton1 = GUICtrlCreateButton("Start", 105, 100, 100, -1, $BS_FLAT) ; Disable Win Theme in button... DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($iButton1), "wstr", 0, "wstr", 0) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $iMsg = GUIGetMsg() If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>_Example Regards, João Carlos.
    1 point
  16. Here your full code that is working for me (I deactivated some lines to get it run)! #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\_resources\images\App_updater.ico #AutoIt3Wrapper_outfile=RS_Updater.exe #AutoIt3Wrapper_Res_Fileversion=1.0.0.3 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Francisca Carstens Script Function: Check if RapidStudio Windows Client installed version corresponds to newest upgrade available on www.rapidstudio.co.za UPDATER Changes from version 1.0.0.1 to 1.0.0.2 - In previous version more than one updater could run at one time. Changed so that only one process may exist. added #include <Misc.au3> with user defined function _Singleton() - Now including images using fileinstall() in the setup.exe - Royalty text not displaying. Now including with fileinstall() function. - fran@bowens.co.za email address pre filled in, text changed to email address entered into the registry at setup time. Changes from version 1.0.0.2 to 1.0.0.3 BUGS: - Royalty text and images still not displaying. $rgApp was declared incorrectly. FEATURE REQUESTS: - After install launch updater GUI (not only in system tray) - get variable $fromsetup = 1 Prompts with message boxes instead of just the TrayTips. - Auto download after 10 seconds >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - Add button on download screen 'Minimise to Tray' ('back' button) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #ce ---------------------------------------------------------------------------- #Region -> Includes #include <Constants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <Timers.au3> #include <GuiButton.au3> #include <Misc.au3> #include <Date.au3> #EndRegion -> Includes If _Singleton("RS_Updater", 1) = 0 Then Exit ;make sure only one copy of the script is running #Region -> Options Opt("TrayAutoPause", 0) Opt("TrayIconHide", 0) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 3) #EndRegion -> Options #Region -> Declarations $min = 0 $fromsetup = 0 For $x = 1 to $CmdLine[0] $fromsetup = $CmdLine[1] Next $instProgram = 'RapidStudio Software Updater' $instLicense = FileRead(@ScriptDir & "\resources\license.txt") Local $appath, $verl, $verr, $App = 'RapidStudio', $numRP = 10 Local $vStatus ; Version Status... 1=up to date, 2=not newest, 3=version 5 (not upgradable) Local $message Local $goto = 2, $backto, $finish = 0, $downloadfinish = 0 Local $StatusBar, $hDownload, $nBytes, $nRead, $nSize, $calc, $file = @TempDir & '\RapidStudio_rsupdate', $url = 'http://update.rapidstudio.co.za' Local $starttime, $speed Local $prog = 0 Local $stop = 0 Global $silent = 1 ;~ _RegRead() ;does RapidStudio installation exist on user PC? $program = $appath & "\MPR500 Pro 5\AlbumMaker.exe" $verl = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RapidStudio_RapidStudio", "AppVersion") $useremail = RegRead("HKEY_CURRENT_USER\Software\RapidStudio_Updater\", "Email") $AppFolderUpdater = RegRead("HKEY_CURRENT_USER\Software\RapidStudio_Updater\", "AppFolder") $rgApp = 'RS Updater' $AppConfigFolder = $AppFolderUpdater & "\" & $rgApp & "\config" ;~ ShellExecuteWait (@scriptdir & "\test.exe",$silent) ; to execute upgrade in silent mode #EndRegion -> Declarations #Region -> Tray Items TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_On_Exit") #EndRegion -> Tray Items #Region -> GUI Items $gui = GUICreate($instProgram, 500, 361, -1, -1, $GUI_SS_DEFAULT_GUI) GUISetFont("", 400, "", "Tahoma", "", 5) #Region -> Screen 1: Welcome Screen $bkg1 = GUICtrlCreateGraphic(0, 0, 500, 314) GUICtrlSetBkColor(-1, 0xFFFFFF) $pic1 = GUICtrlCreatePic($AppConfigFolder & "\images\setup_leftpic1.jpg", 0, 0, 163, 314) $tWelcomeHead = GUICtrlCreateLabel("Welcome to the " & $instProgram & " Wizard", 180, 18, 300, 50) GUICtrlSetFont(-1, 13.2, 700, "", "Arial", 5) GUICtrlSetBkColor(-1, 0xFFFFFF) $tWelcomeBody = GUICtrlCreateLabel("This wizard will guide you through the download and installation of the newest RapidStudio software update available." & @LF & @LF & "It is recommended that you close all other applications before you continue. This will make it possible to update relevant system files without having to reboot your computer." & @LF & @LF & "Click Next to continue.", 180, 68, 300, 200) GUICtrlSetBkColor(-1, 0xFFFFFF) $but1 = GUICtrlCreateButton("&Next >", 326, 325, 74, 23, $BS_DEFPUSHBUTTON) $but2 = GUICtrlCreateButton("&Cancel", 412, 325, 74, 23) $divBottom1 = GUICtrlCreateGraphic(0, 314, 510, 1, $SS_ETCHEDHORZ) $but3 = GUICtrlCreateButton("< &Back", 326 - 74 - 2, 325, 74, 23) GUICtrlSetState(-1, $GUI_HIDE) #EndRegion -> Screen 1: Welcome Screen #Region -> Screen 2: Download $bkg2 = GUICtrlCreateGraphic(0, 0, 500, 60) GUICtrlSetBkColor(-1, 0xfeb916) GUICtrlSetState(-1, $GUI_HIDE) $logo = GUICtrlCreatePic($AppConfigFolder & '\images\logo_updater.jpg', 440, 0, 60, 60) GUICtrlSetState(-1, $GUI_HIDE) $divTop = GUICtrlCreateGraphic(0, 60, 500, 1, $SS_GRAYFRAME) GUICtrlSetState(-1, $GUI_HIDE) $tDownloadHead = GUICtrlCreateLabel("Download " & $App & " " & $verr & ".", 15, 10, 300, 20) GUICtrlSetFont(-1, 8.5, 800, "", "Tahoma") GUICtrlSetBkColor(-1, 0xfeb916) GUICtrlSetState(-1, $GUI_HIDE) $tDownloadHead2 = GUICtrlCreateLabel("", 25, 30, 410, 30) GUICtrlSetBkColor(-1, 0xfeb916) GUICtrlSetFont(-1, 8.5, 400, "", "Tahoma") GUICtrlSetState(-1, $GUI_HIDE) $tDownloadBody = GUICtrlCreateLabel("", 25, 75, 450, 20) GUICtrlSetState(-1, $GUI_HIDE) $divBottom2 = GUICtrlCreateGraphic(0, 314, 500, 1, $SS_ETCHEDHORZ) GUICtrlSetState(-1, $GUI_HIDE) $ProgressDownload = GUICtrlCreateProgress(25, 90, 450, 20, $PBS_SMOOTH) GUICtrlSetState(-1, $GUI_HIDE) #EndRegion -> Screen 2: Download #Region -> Screen 3: Royalty Points $tRoyaltyHead = GUICtrlCreateLabel("Royalty Points", 15, 10, 300, 20) GUICtrlSetFont(-1, 8.5, 800, "", "Tahoma") GUICtrlSetBkColor(-1, 0xfeb916) GUICtrlSetState(-1, $GUI_HIDE) $tRoyaltyHead2 = GUICtrlCreateLabel("Please confirm your email address to claim your Royalty Points.", 25, 30, 410, 30) GUICtrlSetBkColor(-1, 0xfeb916) GUICtrlSetFont(-1, 8.5, 400, "", "Tahoma") GUICtrlSetState(-1, $GUI_HIDE) $tRoyaltyBody1 = GUICtrlCreateLabel("Please enter your email address to continue.", 25, 75, 450, 20) GUICtrlSetState(-1, $GUI_HIDE) $input = GUICtrlCreateInput("Enter your email address here", 25, 90, 225, 20) ;~ $input = GUICtrlCreateInput("fran@bowens.co.za", 25, 90, 225, 20) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetTip(-1, "Enter your email address (ex. joe.soap@email.com)") FileInstall('..\_resources\royalty.txt',$AppConfigFolder & "\royalty.txt") $tRoyaltyBody = GUICtrlCreateEdit(FileRead($AppConfigFolder & "\royalty.txt"), 25, 115, 450, 175, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetState(-1, $GUI_HIDE) ;~ GUICtrlSetFont(-1, 8.5, 400, "", "Lucida Console", 5) GUICtrlSetBkColor(-1, 0xFFFFFF) #EndRegion -> Screen 3: Royalty Points #EndRegion -> GUI Items #cs #Region -> Pre GUI checks Ping('www.google.com') If @error Then Ping('www.google.com') If @error Then MsgBox(0, '', 'You are not connected to the internet!') ;for testing $installdir = @ProgramFilesDir & "\RapidStudio_Updater" RunWait('schtasks /delete /TN "RapidStudio Updater" /F', '', @SW_HIDE) RunWait('schtasks /create /RU SYSTEM /SC daily /TN "RapidStudio Updater" /TR "' & $installdir & '\Updater.exe"', '', @SW_HIDE) Exit EndIf $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://www.rapidstudio.info/rsupdater/index.php?useremail=" & $useremail & "&update=1&version=" & $verl) $oHTTP.Send() $HTMLSource = $oHTTP.Responsetext $aSource = StringSplit($HTMLSource, ",") $verr = $aSource[2] $releasedate = $aSource[3] ConsoleWrite("Remote Version:" & @TAB & $verr & @CRLF & "Release Date:" & @TAB & $releasedate & @CRLF) ;for testing _CheckVersion($verl, $verr) If $vStatus = 1 Then If $fromsetup = 1 Then MsgBox(4160, "RapidStudio Updater", "RapidStudio is up to date.") Else TrayTip("RapidStudio Updater", "RapidStudio is up to date.", 5, 1) Sleep(5000) EndIf Exit EndIf If $vStatus = 3 Then TrayTip("RapidStudio Updater", "Your version is too old to upgrade." & @CRLF & "Please phone support on 011 225 0522", 5, 1) Sleep(5000) Exit EndIf #EndRegion -> Pre GUI checks #ce TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_On_Tray_Show") TraySetClick(16) TrayTip("RapidStudio Updater", "New update available for RapidStudio.", 5, 1) TraySetToolTip("RapidStudio - Updater") TraySetState(4) ;~ $msg = MsgBox(4 + 64 + 8192 + 262144, $instProgram, "There is a new version of RapidStudio available!" & @CRLF & @CRLF & "Would you like to upgrade now?") ;~ If $msg = 7 Then Exit _Main() Func _Main() GUISetState(@SW_HIDE) If $fromsetup = 1 Then If MsgBox(4096 + 52, "RapidStudio Updater", "New update available for RapidStudio." & @CRLF & @CRLF & "Update Now?") = 6 Then _On_Tray_Show() Else GUISetState(@SW_HIDE) EndIf EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $but2 If $finish = 0 Then If $goto = 3 Then ;download is busy _Exit() Else If MsgBox(52 + 4096, $instProgram, "Are you sure you want to quit " & $instProgram & "?") = 6 Then _Hide_GUI() ;Hide gui, but keep showing tray icon, so if the user clicks on the tray icon, function _Main() will be called again... or something like that. ;~ EndIf EndIf Else Exit EndIf Case $but1 If $goto = 2 Then ;goto Stage 2: Prepare to Download Upgrade GUICtrlSetState($bkg1, $GUI_HIDE) GUICtrlSetState($pic1, $GUI_HIDE) GUICtrlSetState($tWelcomeHead, $GUI_HIDE) GUICtrlSetState($tWelcomeBody, $GUI_HIDE) GUICtrlSetState($divBottom1, $GUI_HIDE) GUICtrlSetData($tDownloadHead, "Download " & $App & " " & $verr & " Upgrade.") GUICtrlSetData($tDownloadHead2, "Download the newest version of " & $App & ".") GUICtrlSetData($tDownloadBody, "Click Download to start the download for " & $App & " " & $verr & " Upgrade.") GUICtrlSetState($bkg2, $GUI_SHOW) GUICtrlSetState($logo, $GUI_SHOW) GUICtrlSetState($divTop, $GUI_SHOW) GUICtrlSetState($divBottom2, $GUI_SHOW) GUICtrlSetState($tDownloadBody, $GUI_SHOW) GUICtrlSetState($tDownloadHead, $GUI_SHOW) GUICtrlSetState($tDownloadHead2, $GUI_SHOW) GUICtrlSetState($ProgressDownload, $GUI_SHOW) GUICtrlSetData($but1, '&Download >') GUICtrlSetState($but3, $GUI_SHOW) $backto = 1 $goto = 2.5 $tCur = TimerInit() Do If TimerDiff($tCur) > 10000 Then ExitLoop Until GUIGetMsg() = $but1 ;Or $but3 Or $GUI_EVENT_CLOSE Or $but2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $backto = 0 GUICtrlSetState($but1, $GUI_DISABLE) GUICtrlSetState($but2, $GUI_DISABLE) GUICtrlSetState($but3, $GUI_DISABLE) Sleep(100) GUICtrlSetState($but1, $GUI_HIDE) GUICtrlSetState($but2, $GUI_HIDE) GUICtrlSetState($but3, $GUI_HIDE) GUICtrlSetState($divBottom2, $GUI_HIDE) Sleep(100) GUICtrlSetData($tDownloadBody, "Downloading...") DirCreate($file) $StatusBar = _GUICtrlStatusBar_Create($gui) _GUICtrlStatusBar_SetText($StatusBar, "Ready") Start_DL($url, $file) $goto = 3 ElseIf $goto = 2.5 Then ;goto Stage 2.5: Download Upgrade $backto = 0 GUICtrlSetState($but1, $GUI_DISABLE) GUICtrlSetState($but2, $GUI_DISABLE) GUICtrlSetState($but3, $GUI_DISABLE) Sleep(100) GUICtrlSetState($but1, $GUI_HIDE) GUICtrlSetState($but2, $GUI_HIDE) GUICtrlSetState($but3, $GUI_HIDE) GUICtrlSetState($divBottom2, $GUI_HIDE) Sleep(100) GUICtrlSetData($tDownloadBody, "Downloading...") DirCreate($file) $StatusBar = _GUICtrlStatusBar_Create($gui) _GUICtrlStatusBar_SetText($StatusBar, "Ready") Start_DL($url, $file) $goto = 3 ElseIf $goto = 3 Then ;goto Stage 3: Royalty Points _GUICtrlStatusBar_Destroy($StatusBar) GUICtrlSetState($ProgressDownload, $GUI_HIDE) GUICtrlSetState($tDownloadBody, $GUI_HIDE) GUICtrlSetState($divBottom2, $GUI_SHOW) GUICtrlSetState($tRoyaltyBody, $GUI_SHOW) GUICtrlSetState($tRoyaltyBody1, $GUI_SHOW) GUICtrlSetState($tRoyaltyHead, $GUI_SHOW) GUICtrlSetState($tRoyaltyHead2, $GUI_SHOW) GUICtrlSetData($but1, '&Next >') GUICtrlSetState($but1, $GUI_ENABLE) GUICtrlSetState($but1, $GUI_SHOW) GUICtrlSetState($but2, $GUI_SHOW) GUICtrlSetState($but3, $GUI_SHOW) GUICtrlSetState($but2, $GUI_ENABLE) GUICtrlSetData($input, $useremail) GUICtrlSetState($input, $GUI_SHOW) GUICtrlSetState($input, $GUI_FOCUS) $goto = 4 ElseIf $goto = 4 Then ;goto Stage 4: Launch upgrade.exe GUISetState(@SW_HIDE) RunWait($file & "\" & "RapidStudio Upgrade.exe") $verlNEW = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RapidStudio_RapidStudio", "AppVersion") If $verl < $verlNEW Then $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://www.rapidstudio.info/rsupdater/index.php?useremail=" & $useremail & "&update=1&upgraded=1&version=" & $verl) $oHTTP.Send() $HTMLSource = $oHTTP.Responsetext $aSource = StringSplit($HTMLSource, ",") $verr = $aSource[2] $releasedate = $aSource[3] ConsoleWrite("Remote Version:" & @TAB & $verr & @CRLF & "Release Date:" & @TAB & $releasedate & @CRLF) ;for testing MsgBox(0, '', 'You have been awarded ' & $numRP & ' Royalty Points for upgrading RapidStudio to version ' & $verl) $finish = 1 ElseIf $verl = $verlNEW Then $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://www.rapidstudio.info/rsupdater/index.php?useremail=" & $useremail & "&update=1&upgraded=0&version=" & $verl) $oHTTP.Send() $HTMLSource = $oHTTP.Responsetext $aSource = StringSplit($HTMLSource, ",") $verr = $aSource[2] $releasedate = $aSource[3] ConsoleWrite("Remote Version:" & @TAB & $verr & @CRLF & "Release Date:" & @TAB & $releasedate & @CRLF) ;for testing MsgBox(0, '', 'You have been awarded ' & 0 & ' Royalty Points for upgrading RapidStudio to version ' & $verl) $finish = 2 ;upgrade not successful EndIf ExitLoop EndIf Case $but3 If $backto = 1 Then ;go backto Screen 1: Welcome GUICtrlSetState($bkg2, $GUI_HIDE) GUICtrlSetState($divTop, $GUI_HIDE) GUICtrlSetState($logo, $GUI_HIDE) GUICtrlSetState($divBottom2, $GUI_HIDE) GUICtrlSetState($tDownloadBody, $GUI_HIDE) GUICtrlSetState($tDownloadHead, $GUI_HIDE) GUICtrlSetState($tDownloadHead2, $GUI_HIDE) GUICtrlSetState($ProgressDownload, $GUI_HIDE) GUICtrlSetData($but1, '&Next >') GUICtrlSetState($but3, $GUI_HIDE) GUICtrlSetState($bkg1, $GUI_SHOW) GUICtrlSetState($pic1, $GUI_SHOW) GUICtrlSetState($tWelcomeHead, $GUI_SHOW) GUICtrlSetState($tWelcomeBody, $GUI_SHOW) GUICtrlSetState($divBottom1, $GUI_SHOW) $goto = 2 EndIf Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) $min = 1 EndSwitch WEnd ;~ RunWait('schtasks /delete /TN "RapidStudio Updater" /F', '', @SW_HIDE) ;~ RunWait('schtasks /create /RU SYSTEM /SC weekly /TN "RapidStudio Updater" /TR "' & $AppFolderUpdater & '\Updater.exe"', '', @SW_HIDE) Exit EndFunc ;==>_Main #Region -> Functions Func _On_Tray_Show() ; Left clicking the tray icon shows the GUI GUISetState(@SW_SHOW) TraySetState(8) EndFunc ;==>_On_Tray_Show Func _On_Exit() ; Exit the script Exit EndFunc ;==>_On_Exit Func _Hide_GUI() GUICtrlSetState($bkg2, $GUI_HIDE) GUICtrlSetState($divTop, $GUI_HIDE) GUICtrlSetState($divBottom2, $GUI_HIDE) GUICtrlSetState($tDownloadBody, $GUI_HIDE) GUICtrlSetState($tDownloadHead, $GUI_HIDE) GUICtrlSetState($tDownloadHead2, $GUI_HIDE) GUICtrlSetState($ProgressDownload, $GUI_HIDE) GUICtrlSetData($but1, '&Next >') GUICtrlSetState($but3, $GUI_HIDE) GUICtrlSetState($tRoyaltyBody, $GUI_HIDE) GUICtrlSetState($tRoyaltyBody1, $GUI_HIDE) GUICtrlSetState($tRoyaltyHead, $GUI_HIDE) GUICtrlSetState($tRoyaltyHead2, $GUI_HIDE) GUICtrlSetState($input, $GUI_HIDE) _GUICtrlStatusBar_Destroy($StatusBar) GUICtrlSetState($bkg1, $GUI_SHOW) GUICtrlSetState($pic1, $GUI_SHOW) GUICtrlSetState($tWelcomeHead, $GUI_SHOW) GUICtrlSetState($tWelcomeBody, $GUI_SHOW) GUICtrlSetState($divBottom1, $GUI_SHOW) GUICtrlSetState($but1, $GUI_SHOW) GUICtrlSetState($but1, $GUI_ENABLE) GUICtrlSetState($but1, $GUI_FOCUS) GUICtrlSetState($but2, $GUI_SHOW) GUICtrlSetState($but2, $GUI_ENABLE) $goto = 2 GUISetState(@SW_HIDE) TrayTip("RapidStudio Updater", "New update available for RapidStudio.", 5, 1) EndFunc ;==>_Hide_GUI Func _RegRead() RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RapidStudio_RapidStudio", "") If @error > 0 Then ;Key does not exist MsgBox(16, "RapidStudio Updater Message", "RapidStudio is not installed on this computer." & @CRLF & "Please call support on 011 225 0522 if you require assistance.", 5000) RunWait('schtasks /delete /TN "RapidStudio Updater" /F', '', @SW_HIDE) Exit Else ;Key does exist $appath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RapidStudio_RapidStudio", "AppFolder") ;~ MsgBox(4096, "Success", "RapidStudio is installed in the following directory:" & @CRLF & $appath) ; for testing EndIf EndFunc ;==>_RegRead Func _CheckVersion($verl, $verr) $averl = StringSplit($verl, ".") $averr = StringSplit($verr, ".") If $verl = $verr Then $vStatus = 1 ;~ MsgBox(262144, "Message", "Your " & $App & " installation is up to date." & @LF & "Version: " & $verl) ElseIf ($averl[1] < $averr[1]) Then $vStatus = 3 ;~ If MsgBox(52 + 262144, "Message", "There is a newer version of RapidStudio available, but the upgrade is not compatible with the version you are currently running. " & @LF & @LF & "Your version:" & @TAB & $verl & @LF & "New version:" & @TAB & $verr & @LF & @LF & "Would you like to download the fresh install of version " & $verr & " ?") = 6 Then ;~ MsgBox(0, "result", "Download full installation.") ;~ EndIf ElseIf ($verl < $verr) Then $vStatus = 2 ;~ If MsgBox(68+ 262144, "Message", "Your " & $App & " installation is not up to date." & @LF & "Version: " & $verl & @CRLF & @CRLF &"Download the newer version? " & $verr) = 6 Then ;~ MsgBox(0, "result", "Download upgrade.") ;~ $upgraded = 1 ;~ EndIf EndIf EndFunc ;==>_CheckVersion Func Start_DL($url, $file) If $url <> "" And $file <> "" Then $file &= "\" & "RapidStudio Upgrade.exe" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $file = ' & $file & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $nSize = InetGetSize($url) $hDownload = InetGet($url, $file, 1, 1) AdlibRegister("DL_Check", 50) $starttime = TimerInit() EndIf EndFunc ;==>Start_DL Func DL_Check() If InetGetInfo($hDownload, 2) Then InetClose($hDownload) $nRead = $nSize $calc = Int(100 * $nRead / $nSize) GUICtrlSetData($ProgressDownload, $calc) _GUICtrlStatusBar_SetText($StatusBar, Round($nSize / 1024 / 1024, 2) & " MB" & @TAB & "100 %" & @TAB & $speed & " KBs / second") Sleep(2000) _GUICtrlStatusBar_Destroy($StatusBar) $goto = 3 _GUICtrlButton_Click($but1) ElseIf $stop Then InetClose($hDownload) ;~ GUICtrlSetState($Start_DL, $GUI_ENABLE) ;~ GUICtrlSetState($Stop_DL, $GUI_DISABLE) GUICtrlSetData($ProgressDownload, 0) _GUICtrlStatusBar_SetText($StatusBar, "Ready") FileDelete($file) $stop = 0 AdlibUnRegister("DL_Check") Else $nRead = InetGetInfo($hDownload, 0) $calc = Int(100 * $nRead / $nSize) GUICtrlSetData($ProgressDownload, $calc) $speed = Round(($nRead / 1024) / (_Timer_Diff($starttime) / 1000)) _GUICtrlStatusBar_SetText($StatusBar, Round($nRead / 1024 / 1024, 2) & " / " & Round($nSize / 1024 / 1024, 2) & " MB" & @TAB & $calc & " %" & @TAB & $speed & " KBs / second") EndIf EndFunc ;==>DL_Check Func Stop_DL() If MsgBox(8196, "Cancel", "Are you sure you want to cancel the download?") = 6 Then $stop = 1 EndFunc ;==>Stop_DL Func _Exit() If $nRead < $nSize Then If MsgBox(8196, "Exit", "The download is not complete. Are you sure you want to exit?") = 6 Then InetClose($hDownload) FileDelete($file) _Hide_GUI() EndIf Else _Hide_GUI() EndIf EndFunc ;==>_Exit #EndRegion -> Functions Br, UEZ
    1 point
×
×
  • Create New...