Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/2020 in all areas

  1. I don't know if you are like me, but I am always searching for that specific code I wrote over the years, but cannot find it. It was way too exhausting to look at 1k+ scripts. And Windows Explorer is not the best tool to do such exploration. So I made this little script that save me tons of time. Hope you will find it useful too. You can adjust default search folders and type of files you want to search for, but you can also change it at runtime. To use multiple filters separate them with ";" Let me know if you have any suggestion to enhance the tool. Version 2023-12-27 * Code revision : 3.3.16.1 now required Version 2023-05-10 * Sets children flag on first drawn list Version 2021-04-06 * Context menu modified to allow clipping file name and line content Version 2020-11-21 * Allows only 1 running instance of the script * Added right-click support on Tray to exit script Version 2020-06-29 * Added Copy File Name to context menu (helps to copy include files names) Version 2020-04-22 * Added icons to main buttons * Added informative box to describe progress and results of a search * Increased robustness of the GUI * Open Button enabled only under the right conditions * Added Tooltip on filter field to describe how to enter multiple criteria * Forced a minimum Window size Version 2020-04-18 * Added support of Context Menu in Tree View * Added support of Tray * Minimizes on Tray Version 2020-04-12 * Added DPI awareness * Added Enter Key functionality to start a search Version 2020-04-09 * Changed base size of the GUI to make it wider * Made the window resizable * Added Reset button * Shown busy cursor more appropriately * Corrected bug of first line displayed Thanks all for your input. SearchContent.au3
    1 point
  2. iamtheky

    powershell to array

    In addition to all of the optimization suggestions, you have fundamental issues, the return from the run command is the PID not the STDOUT. You can then use the PID to read the output of the command. But WMI is already slow without asking powershell to ask WMI. ;#RequireAdmin #include <Constants.au3> #include <Array.au3> $pidPrintlist = Run("powershell.exe get-printer" , @SystemDir , @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($pidPrintlist) $out = StdoutRead($pidPrintlist) _ArrayDisplay(stringsplit($out , @CR , 2)) yeah, pretty much what @Deye said at the same time he said it
    1 point
  3. wolf9228

    Free C++ Compiler

    The code contains the command lines of the Free C ++ Compiler by simplifying the work on the Free C ++ Compiler via the Autoit script. There are several examples of creating dll files, executable files, and also dll libraries Initially, download the Free C ++ Compiler from its official website after Free registering with this link. https://www.embarcadero.com/free-tools/ccompiler Free C++ Compiler The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's award-winning C++Builder product line. some notes For Bat.bat File All errors and notices appear on the Ms-dos data The _wpopen function cannot show errors that the C++ Compiler application returns /// (BCC32C.exe) ///" This also occurs on the Autoit StderrRead function Thanks Compiler.zip yProject.cpp #include <stdio.h> #include <shlobj.h> #ifdef __cplusplus extern "C" { #endif __declspec(dllexport) DWORD WINAPI Func(DWORD NumA,DWORD NumB); #ifdef __cplusplus } #endif BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } DWORD WINAPI Func(DWORD NumA,DWORD NumB) { return (NumA + NumB); } Project.cpp #include <windows.h> #include <stdio.h> HWND yButton; LRESULT CALLBACK GuiProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); static TCHAR szWindowClass[] = ("win32app"); static TCHAR szTitle[] = ("Gui Win32 Application"); HINSTANCE hInst; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = GuiProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); RegisterClassEx(&wcex); HWND hWnd = CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW|WS_VISIBLE,0,0,200,200,0,0,hInstance,0); yButton = CreateWindowEx(0,"Button","yButton",WS_TABSTOP|WS_CHILD|BS_NOTIFY|WS_VISIBLE,10,10,80,40,hWnd,0,hInstance,0); MSG msg; while (GetMessage(&msg,0,0,0)) { if (!TranslateAccelerator(msg.hwnd,0,&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return 0; } LRESULT CALLBACK GuiProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch (message) { case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: if ((HWND) lParam == yButton) { MessageBox(0,"yButton","MSG",0); } break; } break; case WM_PAINT: break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); } yProject_Error.cpp #include <windows.h> #include <stdio.h> // Here Error Error HWND yButton; LRESULT CALLBACK GuiProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); static TCHAR szWindowClass[] = ("win32app"); static TCHAR szTitle[] = ("Gui Win32 Application"); HINSTANCE hInst; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = GuiProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); RegisterClassEx(&wcex); HWND hWnd = CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW|WS_VISIBLE,0,0,200,200,0,0,hInstance,0); yButton = CreateWindowEx(0,"Button","yButton",WS_TABSTOP|WS_CHILD|BS_NOTIFY|WS_VISIBLE,10,10,80,40,hWnd,0,hInstance,0); MSG msg; while (GetMessage(&msg,0,0,0)) { if (!TranslateAccelerator(msg.hwnd,0,&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return 0; } LRESULT CALLBACK GuiProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch (message) { case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: if ((HWND) lParam == yButton) { MessageBox(0,"yButton","MSG",0); } break; } break; case WM_PAINT: break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); } Exe_Wthe_Bat.au3 ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\Project.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 1 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $PFile = FileGetShortName($PFile) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile & @CRLF & "Pause" if FileExists("Batch.bat") And Not FileDelete("Batch.bat") Then Exit FileWrite("Batch.bat",$Command) RunWait("Batch.bat") if $VisualStyles Then ;Enabling Visual Styles ;https://docs.microsoft.com/en-us/windows/win32/controls/cookbook-overview $ManiText = _ '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' & @CRLF & _ '<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' & @CRLF & _ ' <security>' & @CRLF & _ ' <requestedPrivileges>' & @CRLF & _ ' <requestedExecutionLevel level="asInvoker" uiAccess="false">'& @CRLF & _ ' </requestedExecutionLevel>' & @CRLF & _ ' </requestedPrivileges>' & @CRLF & _ ' </security>' & @CRLF & _ ' </trustInfo>' & @CRLF & _ ' <dependency>' & @CRLF & _ ' <dependentAssembly>' & @CRLF & _ ' <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>' & @CRLF & _ ' </dependentAssembly>' & @CRLF & _ ' </dependency>' & @CRLF & _ '</assembly>' $RT_MANIFEST = 24 $vDataStruct = StringToDataStruct($ManiText) $vlpData = DllStructGetPtr($vDataStruct) $vcbData = DllStructGetSize($vDataStruct) UpdateResource($NewFile,$RT_MANIFEST,1,$vlpData,$vcbData) EndIf Sleep(300) RunWait($NewFile) ShellExecute($BCC102) Func StringToDataStruct($Text) $Len = StringLen($Text) if $Len = 0 Then $Len = 1 $DataStruct = DllStructCreate("char[" & $Len & "]") DllStructSetData($DataStruct,1,$Text) Return $DataStruct EndFunc Func UpdateResource($Dll_Exe_File,$lpType,$lpName,$lpData,$cbData) $Handle = DllCall("kernel32.dll","HANDLE","BeginUpdateResourceW","wstr",$Dll_Exe_File,"BOOL",False) if @error Or $Handle[0] = 0 Then Return SetError(1,0,False) $Handle = $Handle[0] Select Case IsString($lpType) $DTypeA = "wstr" $lpType = StringUpper($lpType) Case Else $DTypeA = "long" $lpType = Int($lpType) EndSelect Select Case IsString($lpName) $DTypeB = "wstr" $lpName = StringUpper($lpName) Case Else $DTypeB = "long" $lpName = Int($lpName) EndSelect $BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","HANDLE",$Handle,$DTypeA _ ,$lpType,$DTypeB,$lpName,"WORD",0,"ptr",$lpData,"DWORD",$cbData) if @error Or $BOOL[0] = 0 Then Return SetError(2,0,False) $BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$Handle,"BOOL",False) if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False) Return SetError(0,0,True) EndFunc Exe_Wthe_wpopen.au3 $MsvcrtDll = DllOpen("Msvcrt.Dll") ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\Project.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 1 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile Local $Buffer = DllStructCreate("wchar[1024]") , $Text = "" $Return = DllCall($MsvcrtDll,"ptr:cdecl","_wpopen","wstr",$Command,"wstr","rt") if @error Or $Return[0] = 0 Then Exit $pPipe = $Return[0] while 1 $Return = DllCall($MsvcrtDll,"ptr:cdecl","fgetws","STRUCT*",$Buffer,"int",1024,"ptr",$pPipe) $Text &= DllStructGetData($Buffer,1) if Not $Return[0] Then ExitLoop WEnd MsgBox(0,"",$Text) if $VisualStyles Then ;Enabling Visual Styles ;https://docs.microsoft.com/en-us/windows/win32/controls/cookbook-overview $ManiText = _ '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' & @CRLF & _ '<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' & @CRLF & _ ' <security>' & @CRLF & _ ' <requestedPrivileges>' & @CRLF & _ ' <requestedExecutionLevel level="asInvoker" uiAccess="false">'& @CRLF & _ ' </requestedExecutionLevel>' & @CRLF & _ ' </requestedPrivileges>' & @CRLF & _ ' </security>' & @CRLF & _ ' </trustInfo>' & @CRLF & _ ' <dependency>' & @CRLF & _ ' <dependentAssembly>' & @CRLF & _ ' <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>' & @CRLF & _ ' </dependentAssembly>' & @CRLF & _ ' </dependency>' & @CRLF & _ '</assembly>' $RT_MANIFEST = 24 $vDataStruct = StringToDataStruct($ManiText) $vlpData = DllStructGetPtr($vDataStruct) $vcbData = DllStructGetSize($vDataStruct) UpdateResource($NewFile,$RT_MANIFEST,1,$vlpData,$vcbData) EndIf Sleep(300) RunWait($NewFile) ShellExecute($BCC102) Func StringToDataStruct($Text) $Len = StringLen($Text) if $Len = 0 Then $Len = 1 $DataStruct = DllStructCreate("char[" & $Len & "]") DllStructSetData($DataStruct,1,$Text) Return $DataStruct EndFunc Func UpdateResource($Dll_Exe_File,$lpType,$lpName,$lpData,$cbData) $Handle = DllCall("kernel32.dll","HANDLE","BeginUpdateResourceW","wstr",$Dll_Exe_File,"BOOL",False) if @error Or $Handle[0] = 0 Then Return SetError(1,0,False) $Handle = $Handle[0] Select Case IsString($lpType) $DTypeA = "wstr" $lpType = StringUpper($lpType) Case Else $DTypeA = "long" $lpType = Int($lpType) EndSelect Select Case IsString($lpName) $DTypeB = "wstr" $lpName = StringUpper($lpName) Case Else $DTypeB = "long" $lpName = Int($lpName) EndSelect $BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","HANDLE",$Handle,$DTypeA _ ,$lpType,$DTypeB,$lpName,"WORD",0,"ptr",$lpData,"DWORD",$cbData) if @error Or $BOOL[0] = 0 Then Return SetError(2,0,False) $BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$Handle,"BOOL",False) if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False) Return SetError(0,0,True) EndFunc Dll_Wthe_Bat.au3 ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\yProject.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 2 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $PFile = FileGetShortName($PFile) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile & @CRLF & "Pause" if FileExists("Batch.bat") And Not FileDelete("Batch.bat") Then Exit FileWrite("Batch.bat",$Command) RunWait("Batch.bat") if $VisualStyles Then ;Enabling Visual Styles ;https://docs.microsoft.com/en-us/windows/win32/controls/cookbook-overview $ManiText = _ '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' & @CRLF & _ '<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' & @CRLF & _ ' <security>' & @CRLF & _ ' <requestedPrivileges>' & @CRLF & _ ' <requestedExecutionLevel level="asInvoker" uiAccess="false">'& @CRLF & _ ' </requestedExecutionLevel>' & @CRLF & _ ' </requestedPrivileges>' & @CRLF & _ ' </security>' & @CRLF & _ ' </trustInfo>' & @CRLF & _ ' <dependency>' & @CRLF & _ ' <dependentAssembly>' & @CRLF & _ ' <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>' & @CRLF & _ ' </dependentAssembly>' & @CRLF & _ ' </dependency>' & @CRLF & _ '</assembly>' $RT_MANIFEST = 24 $vDataStruct = StringToDataStruct($ManiText) $vlpData = DllStructGetPtr($vDataStruct) $vcbData = DllStructGetSize($vDataStruct) UpdateResource($NewFile,$RT_MANIFEST,1,$vlpData,$vcbData) EndIf Sleep(300) $Return = DllCall($NewFile,"DWORD","Func","DWORD",5,"DWORD",5) MsgBox(0,"Func Call",$Return[0]) ShellExecute($BCC102) Func StringToDataStruct($Text) $Len = StringLen($Text) if $Len = 0 Then $Len = 1 $DataStruct = DllStructCreate("char[" & $Len & "]") DllStructSetData($DataStruct,1,$Text) Return $DataStruct EndFunc Func UpdateResource($Dll_Exe_File,$lpType,$lpName,$lpData,$cbData) $Handle = DllCall("kernel32.dll","HANDLE","BeginUpdateResourceW","wstr",$Dll_Exe_File,"BOOL",False) if @error Or $Handle[0] = 0 Then Return SetError(1,0,False) $Handle = $Handle[0] Select Case IsString($lpType) $DTypeA = "wstr" $lpType = StringUpper($lpType) Case Else $DTypeA = "long" $lpType = Int($lpType) EndSelect Select Case IsString($lpName) $DTypeB = "wstr" $lpName = StringUpper($lpName) Case Else $DTypeB = "long" $lpName = Int($lpName) EndSelect $BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","HANDLE",$Handle,$DTypeA _ ,$lpType,$DTypeB,$lpName,"WORD",0,"ptr",$lpData,"DWORD",$cbData) if @error Or $BOOL[0] = 0 Then Return SetError(2,0,False) $BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$Handle,"BOOL",False) if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False) Return SetError(0,0,True) EndFunc Dll_Wthe_wpopen.au3 $MsvcrtDll = DllOpen("Msvcrt.Dll") ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\yProject.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 2 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile Local $Buffer = DllStructCreate("wchar[1024]") , $Text = "" $Return = DllCall($MsvcrtDll,"ptr:cdecl","_wpopen","wstr",$Command,"wstr","rt") if @error Or $Return[0] = 0 Then Exit $pPipe = $Return[0] while 1 $Return = DllCall($MsvcrtDll,"ptr:cdecl","fgetws","STRUCT*",$Buffer,"int",1024,"ptr",$pPipe) $Text &= DllStructGetData($Buffer,1) if Not $Return[0] Then ExitLoop WEnd MsgBox(0,"",$Text) if $VisualStyles Then ;Enabling Visual Styles ;https://docs.microsoft.com/en-us/windows/win32/controls/cookbook-overview $ManiText = _ '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' & @CRLF & _ '<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' & @CRLF & _ ' <security>' & @CRLF & _ ' <requestedPrivileges>' & @CRLF & _ ' <requestedExecutionLevel level="asInvoker" uiAccess="false">'& @CRLF & _ ' </requestedExecutionLevel>' & @CRLF & _ ' </requestedPrivileges>' & @CRLF & _ ' </security>' & @CRLF & _ ' </trustInfo>' & @CRLF & _ ' <dependency>' & @CRLF & _ ' <dependentAssembly>' & @CRLF & _ ' <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>' & @CRLF & _ ' </dependentAssembly>' & @CRLF & _ ' </dependency>' & @CRLF & _ '</assembly>' $RT_MANIFEST = 24 $vDataStruct = StringToDataStruct($ManiText) $vlpData = DllStructGetPtr($vDataStruct) $vcbData = DllStructGetSize($vDataStruct) UpdateResource($NewFile,$RT_MANIFEST,1,$vlpData,$vcbData) EndIf Sleep(300) $Return = DllCall($NewFile,"DWORD","Func","DWORD",5,"DWORD",5) MsgBox(0,"Func Call",$Return[0]) ShellExecute($BCC102) Func StringToDataStruct($Text) $Len = StringLen($Text) if $Len = 0 Then $Len = 1 $DataStruct = DllStructCreate("char[" & $Len & "]") DllStructSetData($DataStruct,1,$Text) Return $DataStruct EndFunc Func UpdateResource($Dll_Exe_File,$lpType,$lpName,$lpData,$cbData) $Handle = DllCall("kernel32.dll","HANDLE","BeginUpdateResourceW","wstr",$Dll_Exe_File,"BOOL",False) if @error Or $Handle[0] = 0 Then Return SetError(1,0,False) $Handle = $Handle[0] Select Case IsString($lpType) $DTypeA = "wstr" $lpType = StringUpper($lpType) Case Else $DTypeA = "long" $lpType = Int($lpType) EndSelect Select Case IsString($lpName) $DTypeB = "wstr" $lpName = StringUpper($lpName) Case Else $DTypeB = "long" $lpName = Int($lpName) EndSelect $BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","HANDLE",$Handle,$DTypeA _ ,$lpType,$DTypeB,$lpName,"WORD",0,"ptr",$lpData,"DWORD",$cbData) if @error Or $BOOL[0] = 0 Then Return SetError(2,0,False) $BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$Handle,"BOOL",False) if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False) Return SetError(0,0,True) EndFunc Exe_Wthe_wpopen_Error.au3 $MsvcrtDll = DllOpen("Msvcrt.Dll") ;The _wpopen function cannot show errors that the C++ Compiler application returns /// (BCC32C.exe) ///" ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\yProject_Error.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 1 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch ;The _wpopen function cannot show errors that the C++ Compiler application returns /// (BCC32C.exe) ///" $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile Local $Buffer = DllStructCreate("wchar[1024]") , $Text = "" $Return = DllCall($MsvcrtDll,"ptr:cdecl","_wpopen","wstr",$Command,"wstr","rt") if @error Or $Return[0] = 0 Then Exit $pPipe = $Return[0] $Text = "Important note" & @CRLF & "The _wpopen function cannot show errors that the C++ Compiler " & @CRLF & _ "application returns /// (BCC32C.exe) ///" & @CRLF & @CRLF while 1 $Return = DllCall($MsvcrtDll,"ptr:cdecl","fgetws","STRUCT*",$Buffer,"int",1024,"ptr",$pPipe) $Text &= DllStructGetData($Buffer,1) if Not $Return[0] Then ExitLoop WEnd MsgBox(0,"",$Text) Exe_Wthe_Bat_Error.au3 ;All errors and notices appear on the Ms-dos data ;https://www.embarcadero.com/free-tools/ccompiler ;Free C++ Compiler ;The BCC32C/BCC32X Compiler is the high performance foundation and core technology of Embarcadero's ;award-winning C++Builder product line. ;This free download of the C++ Compiler for C++Builder includes C11 language support, the Dinkumware STL ;(Standard Template Library) framework, and the complete Embarcadero C/C++ Runtime Library (RTL). In this ;free version, you’ll also find a number of C/C++ command line tools—such as the high-performance linker ;and resource compiler. ;The Free C++ Compiler download includes: ;Embarcadero C++ Compiler (bcc32c/bcc32x) ;Turbo Incremental Linker (tlink32) ;C++ Win32 Preprocessor (cpp32) ;Import Library utility—for creating import libraries from DLLs (implib) ;Librarian for symbol case-conversion, creating extended libraries and modifying page size (tlib) ;Other useful command-line utilities such as make, grep, and touch ;Includes the Embarcadero C/C++ Runtime Library, and the DinkumwareANSI/ISO Standard Template Library (STL) ;bcc32c-101-Berlin-screenshot ;C++Builder includes compilers for Win64, macOS, iOS, and Android. And, C++Builder also features a modern, ;high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform ;UI development. Learn more about RAD Studio on its product page. ;C++ is avilable in three editions - Free, Community or Pro/Enterprise/Architect. Global $VisualStyles = True , $BCC102 = "D:\BCC102", $compExe = "bcc32c.exe" ; $compExe compiled Exe File Name Global $PFile = $BCC102 & "\yProject_Error.cpp" ; C++ File Global $NewFile = "NewFile" ; New Out File Global $Exe_Dll = 1 ; /// 1 Exe File /// 2 Dll File // Else Numbers Choose One Switch $Exe_Dll Case 1 $FType = ".exe " $TCod = " -tW " ; Exe File Command Case 2 $FType = ".dll " $TCod = " -tWD " ; Dll File Command Case Else $Gui = GUICreate("compiled", 210 + 150, 80) GUICtrlCreateLabel("Please Choose One!", 10, 10) $Exe = GUICtrlCreateButton("Exe File", 10, 50, 100, 23) $DLL = GUICtrlCreateButton("Dll File", 80 + 50, 50, 100, 23) $Ext = GUICtrlCreateButton("Exit", 150 + 100, 50, 100, 23) GUISetState() While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $Exe $FType = ".exe " $TCod = " -tW " ; Exe File Command ExitLoop Case $iMsg = $DLL $FType = ".dll " $TCod = " -tWD " ; Dll File Command ExitLoop Case $iMsg = -3 Or $iMsg = $Ext ; $GUI_EVENT_CLOSE = -3 Exit EndSelect WEnd GUIDelete($Gui) EndSwitch ;All errors and notices appear on the Ms-dos data $Dir = @ScriptDir $yCompiled_File = $BCC102 & "\Bin\" & $compExe if Not FileExists($yCompiled_File) Then $BCC102 = FileSelectFolder("Choose BCC102","C:\") if @error Then Exit if Not FileExists($PFile) Then $PFile = FileOpenDialog("Choose C++ File",$Dir,"(*.cpp)",5) if @error Then Exit $NewFile &= $FType FileChangeDir($BCC102) $PFile = FileGetShortName($PFile) $Command = "Bin\" & $compExe & $TCod & "-IInclude -LLib -e" & $NewFile & $PFile & @CRLF & "Pause" if FileExists("Batch.bat") And Not FileDelete("Batch.bat") Then Exit FileWrite("Batch.bat",$Command) RunWait("Batch.bat") ;All errors and notices appear on the Ms-dos data
    1 point
  4. If you ever tried to download some remote file from your script using InetGet(), InetRead() or other download functions, you probably noticed that the download speed was never as good as when you try to download the same file using a download manager. But that's over, you won't lack the high speed download capability of download managers in your AutoIt scripts, not anymore. Enjoy: #include-once #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WinHttp.au3> ;http://www.autoitscript.com/forum/topic/84133-winhttp-functions/ #include <FileConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: UrlDownloadEx ; Description ...: Download a single file by splitting it in segments and using several simultaneous connections to download these segments from a single server. ; Syntax ........: UrlDownloadEx($sUrl [, $sFileName = Default [, $iNumberOfConnections = Default [, $CallbackFunction = Default [, $vParam = 0]]]]) ; Parameters ....: $sUrl - Url of the file to download. ; $sFileName - [optional] Local filename to download to. Default is "". ; $iNumberOfConnections - [optional] Number of simultaneous connections. Default is 8. ; $CallbackFunction - [optional] An application-defined callback function to call when progress is made. Default is Null. ; $vParam - [optional] An application-defined value to be passed to the callback function. Default is 0. ; Return values .: Success - Returns a binary string if file name is not supplied. ; - Returns 1 if file name is supplied ; - @extended receives the number of received bytes. ; Failure - Returns 0 and sets @error: ; |1 - Invalid number of connections ; |2 - Invalid callback function ; |3 - Invalid url ; |4 - _WinHttpOpen failed ; |5 - _WinHttpConnect failed ; |6 - _WinHttpOpenRequest failed ; |7 - _WinHttpSendRequest failed ; |8 - _WinHttpReceiveResponse failed ; |9 - _WinHttpQueryHeaders failed ; |10 - _WinHttpOpenRequest failed, while trying to create multiple request ; |11 - _WinHttpQueryHeaders failed, while trying to prepare multiple request ; |12 - Not enough memory to allocate buffer ; |13 - _WinHttpQueryDataAvailable failed ; |14 - Download aborted, callback function returned False ; |15 - FileOpen failed ; |16 - FileWrite failed ; Author ........: FaridAgl ; Remarks .......: The Url parameter should be in the form "http://www.somesite.com/path/file.html", just like an address you would type into your web browser. ; + Please use a high number of connections with caution. Some servers may have specific limitations for a number of connections from one client, when the number of connections is high, the servers can put your computer to a black list. ; + For some connection types or for low performance computers or routers, the download speed may decrease when you increase the number of connections. ; + The callback function is called with the following parameters: $iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam ; + To continue downloading, the callback function must return True; to stop downloading, it must return False. ; Example .......: Yes ; =============================================================================================================================== Func UrlDownloadEx($sUrl, $sFileName = Default, $iNumberOfConnections = Default, $CallbackFunction = Default, $vParam = 0) If ($sFileName = Default Or $sFileName = -1) Then $sFileName = "" If ($iNumberOfConnections = Default Or $iNumberOfConnections = -1) Then $iNumberOfConnections = 8 ElseIf (IsInt($iNumberOfConnections) = 0 Or $iNumberOfConnections < 1) Then Return SetError(1, 0, 0) EndIf If ($CallbackFunction = Default Or $CallbackFunction = -1) Then $CallbackFunction = Null Else If (IsFunc($CallbackFunction) = 0) Then Return SetError(2, 0, 0) EndIf Local $avUrlComponents = _WinHttpCrackUrl($sUrl, $ICU_DECODE) If ($avUrlComponents = 0) Then Return SetError(3, 0, 0) Local Const $SERVER_NAME = $avUrlComponents[2] Local Const $OBJECT_NAME = $avUrlComponents[6] Local Const $SERVER_PORT = $avUrlComponents[3] Local Const $FLAGS = ($avUrlComponents[1] = $INTERNET_SCHEME_HTTPS) ? ($WINHTTP_FLAG_SECURE) : (0) Local $hSession = _WinHttpOpen("Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))", $WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, $WINHTTP_NO_PROXY_NAME, $WINHTTP_NO_PROXY_BYPASS, 0) If ($hSession = 0) Then Return SetError(4, 0, 0) Local $hConnect = _WinHttpConnect($hSession, $SERVER_NAME, $SERVER_PORT) If ($hConnect = 0) Then _WinHttpCloseHandle($hSession) Return SetError(5, 0, 0) EndIf Local $hRequest = _WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS) If ($hRequest = 0) Then _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(6, 0, 0) EndIf If (_WinHttpSendRequest($hRequest, "Range: bytes=0-0", $WINHTTP_NO_REQUEST_DATA, 0, 0) = 0) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(7, 0, 0) EndIf If (_WinHttpReceiveResponse($hRequest) = 0) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(8, 0, 0) EndIf Local $sStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) If (Int($sStatusCode, 1) <> $HTTP_STATUS_PARTIAL_CONTENT) Then _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(9, 0, 0) EndIf Local $sContentRange = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_RANGE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) _WinHttpCloseHandle($hRequest) Local Enum $REQUEST_HANDLE, $RECEIVED_BYTES, $DOWNLOAD_OFFSET, $BYTES_TO_DOWNLOAD Local $avConnections[$iNumberOfConnections][4] Local $iDownloadSize = Int(StringTrimLeft($sContentRange, StringLen("bytes 0-0/")), 1) Local $iDownloadSizePerConnection = Floor($iDownloadSize / $iNumberOfConnections) Local $iLastByteToDownload = 0 For $i = 0 To $iNumberOfConnections - 1 $avConnections[$i][$REQUEST_HANDLE] = _WinHttpOpenRequest($hConnect, "GET", $OBJECT_NAME, 0, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $FLAGS) If ($avConnections[$i][$REQUEST_HANDLE] = 0) Then For $j = $i - 1 To 0 Step -1 _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(10, 0, 0) EndIf $avConnections[$i][$RECEIVED_BYTES] = 0 $avConnections[$i][$DOWNLOAD_OFFSET] = $i * $iDownloadSizePerConnection If ($i <> $iNumberOfConnections - 1) Then $avConnections[$i][$BYTES_TO_DOWNLOAD] = $iDownloadSizePerConnection $iLastByteToDownload = $avConnections[$i][$DOWNLOAD_OFFSET] + $iDownloadSizePerConnection - 1 Else $avConnections[$i][$BYTES_TO_DOWNLOAD] = $iDownloadSizePerConnection + Mod($iDownloadSize, $iNumberOfConnections) $iLastByteToDownload = $iDownloadSize - 1 EndIf _WinHttpSendRequest($avConnections[$i][$REQUEST_HANDLE], "Range: bytes=" & $avConnections[$i][$DOWNLOAD_OFFSET] & "-" & $iLastByteToDownload, $WINHTTP_NO_REQUEST_DATA, 0, 0) _WinHttpReceiveResponse($avConnections[$i][$REQUEST_HANDLE]) $sStatusCode = _WinHttpQueryHeaders($avConnections[$i][$REQUEST_HANDLE], $WINHTTP_QUERY_STATUS_CODE, $WINHTTP_HEADER_NAME_BY_INDEX, $WINHTTP_NO_HEADER_INDEX) If (Int($sStatusCode, 1) <> $HTTP_STATUS_PARTIAL_CONTENT) Then For $j = $i - 1 To 0 Step -1 _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(11, 0, 0) EndIf Next Local $tBuffer = DllStructCreate("BYTE[" & $iDownloadSize & "]") If (@error) Then Return SetError(12, 0, 0) Local $pBuffer = DllStructGetPtr($tBuffer) Local $iTotalReceivedBytes = 0 While (True) For $i = 0 To $iNumberOfConnections - 1 If ($avConnections[$i][$RECEIVED_BYTES] = $avConnections[$i][$BYTES_TO_DOWNLOAD]) Then ContinueLoop If (_WinHttpQueryDataAvailable($avConnections[$i][$REQUEST_HANDLE]) = 1) Then $iTotalReceivedBytes += @extended _WinHttpReadData($avConnections[$i][$REQUEST_HANDLE], 2, @extended, $pBuffer + $avConnections[$i][$DOWNLOAD_OFFSET] + $avConnections[$i][$RECEIVED_BYTES]) $avConnections[$i][$RECEIVED_BYTES] += @extended If ($CallbackFunction <> Null) Then If ($CallbackFunction(@extended, $iTotalReceivedBytes, $iDownloadSize, $vParam) = False) Then For $j = 0 To $iNumberOfConnections - 1 If ($avConnections[$j][$REQUEST_HANDLE] > 0) Then _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(14, 0, 0) EndIf EndIf If ($avConnections[$i][$RECEIVED_BYTES] = $avConnections[$i][$BYTES_TO_DOWNLOAD]) Then _WinHttpCloseHandle($avConnections[$i][$REQUEST_HANDLE]) $avConnections[$i][$REQUEST_HANDLE] = 0 EndIf Else For $j = 0 To $iNumberOfConnections - 1 If ($avConnections[$j][$REQUEST_HANDLE] > 0) Then _WinHttpCloseHandle($avConnections[$j][$REQUEST_HANDLE]) Next _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) Return SetError(13, 0, 0) EndIf Next If ($iTotalReceivedBytes = $iDownloadSize) Then _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hSession) ExitLoop EndIf WEnd If ($sFileName <> "") Then Local $hFile = FileOpen($sFileName, BitOR($FO_OVERWRITE, $FO_CREATEPATH, $FO_BINARY)) If ($hFile = -1) Then Return SetError(15, 0, 0) If (FileWrite($hFile, DllStructGetData($tBuffer, 1)) = 0) Then FileClose($hFile) Return SetError(16, 0, 0) EndIf FileClose($hFile) Return SetError(0, $iDownloadSize, 1) EndIf Return SetError(0, $iDownloadSize, DllStructGetData($tBuffer, 1)) EndFunc Example 1 - Download to a local file and use callback function to monitor and control the download progress: #include "UrlDownloadEx.au3" Global $t1 = TimerInit() Global $vResult = UrlDownloadEx("http://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe", @ScriptDir & "\AutoIt 3.3.12.0.exe", Default, BytesReceived) ConsoleWrite(StringFormat("Result:\t%s\nSize:\t%u\nError:\t%u\nTimer:\t%u\n", $vResult, @extended, @error, TimerDiff($t1))) Func BytesReceived($iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam) If ($iTotalReceivedBytes >= 2 * 1024 * 1024) Then Return False ;Stop downloading ConsoleWrite(StringFormat("%u bytes received.\n%u/%u\nParam: %s\n\n", $iReceivedBytes, $iTotalReceivedBytes, $iDownloadSize, $vParam)) Return True ;Continue downloading EndFunc Example 2 - Download to memory and set the number of connections to 2: #include "UrlDownloadEx.au3" Global $t1 = TimerInit() Global $vResult = UrlDownloadEx("http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg", Default, 2) ConsoleWrite(StringFormat("Result:\t%s\nSize:\t%u\nError:\t%u\nTimer:\t%u\n", $vResult, @extended, @error, TimerDiff($t1))) You can also download all of the above scripts at once: UrlDownloadEx + Examples.zip
    1 point
  5. Maybe someone found it useful: Func GregorianToSolar($iYear = @YEAR, $iMonth = @MON, $iDay = @MDAY) Local Const $aiDays[] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] Local $iDayOfYear = 0 For $i = 1 To $iMonth - 1 $iDayOfYear += $aiDays[$i - 1] Next $iDayOfYear += $iDay If ((Mod($iYear, 4) = 0 And Mod($iYear, 100) <> 0) Or (Mod($iYear, 400) = 0)) Then If ($iMonth > 2) Then $iDayOfYear += 1 EndIf If ($iDayOfYear <= 79) Then If (Mod($iYear - 1, 4) = 0) Then $iDayOfYear += 11 Else $iDayOfYear += 10 EndIf $iYear -= 622 If (Mod($iDayOfYear, 30) = 0) Then $iMonth = $iDayOfYear / 30 + 9 $iDay = 30 Else $iMonth = $iDayOfYear / 30 + 10 $iDay = Mod($iDayOfYear, 30) EndIf Else $iYear -= 621 $iDayOfYear -= 79 If ($iDayOfYear <= 186) Then If (Mod($iDayOfYear, 31) = 0) Then $iMonth = $iDayOfYear / 31 $iDay = 31 Else $iMonth = $iDayOfYear / 31 + 1 $iDay = Mod($iDayOfYear, 31) EndIf Else $iDayOfYear -= 186 If (Mod($iDayOfYear, 30) = 0) Then $iMonth = $iDayOfYear / 30 + 6 $iDay = 30 Else $iMonth = $iDayOfYear / 30 + 7 $iDay = Mod($iDayOfYear, 30) EndIf EndIf EndIf Return StringFormat("%u-%02u-%02u", $iYear, $iMonth, $iDay) EndFunc
    1 point
  6. I like the idea that "new year" is on 21st of March when winter is over and spring begins. Seems to calculate Norūz properly. Br, UEZ
    1 point
  7. Writing the script again is easier than searching for it. Learn some math(s)! HotKeySet("{ESC}", "_exit") $centerX = @DesktopWidth / 2 $centerY = @DesktopHeight / 2 $radius = 300 $i = 0 While 1 MouseMove($centerX + ($radius * Cos($i)), $centerY + ($radius * Sin($i)),0) $i += 0.05 Sleep(10) WEnd Func _exit() Exit EndFunc
    1 point
  8. SmOke_N

    LabelClick()

    I'm sure it's been written before, but this was written for a request in the GUI forum. It uses the same DllCall as the _IsPressed() UDF the $s_hexKey/$st_Text/and the $v_dll are optional parameteres here. UDF: Func _LabelClicked($sg_GUI, $sl_Label, $s_hexKey = '01', $st_Text = '', $v_dll = 'user32.dll') Local $Opt = Opt('MouseCoordMode', 2) Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @Error And BitAND($a_R[0], 0x8000) = 0x8000 Then Local $lab_Pos = ControlGetPos($sg_GUI, $st_Text, $sl_Label) Local $lab_Mouse = MouseGetPos() Opt('MouseCoordMode', $Opt) If IsArray($lab_Mouse) And IsArray($lab_Pos) Then If $lab_Mouse[0] >= $lab_Pos[0] And $lab_Mouse[0] <= $lab_Pos[0] + $lab_Pos[2] And $lab_Mouse[1] >= $lab_Pos[1] _ And $lab_Mouse[1] <= $lab_Pos[1] + $lab_Pos[3] Then Return 1 EndIf EndIf Return 0 EndFunc Sample Test GUI: #include <guiconstants.au3> Opt("MouseCoordMode", 0) $Main = GUICreate("MyGui", 200, 100) $MyLabel = GUICtrlCreateLabel("This Label", 10, 20, 100, 25) GUISetState() While 1 $imsg = GUIGetMsg() Select Case $imsg = -3 Exit Case _LabelClicked($Main, $MyLabel) MsgBox(48, "Yes", "It was Your Label!") EndSelect WEnd Edit: Changed from _LabelClick() (Might be misinterpreted) to _LabelClicked() ... If a Moderator could change the title to _LabelClicked() would be great!! Edit2: Added suggestion from LxP Thanks again!
    1 point
  9. LxP

    LabelClick()

    You can also do this so as not to affect the main script's MouseCoordMode setting: Func _LabelClicked(...) ··· Local $Opt = Opt('MouseCoordMode', 2) Local $lab_Mouse = MouseGetPos() Opt('MouseCoordMode', $Opt) ··· EndFunc
    1 point
×
×
  • Create New...