Leaderboard
Popular Content
Showing content with the highest reputation on 01/13/2015 in all areas
-
Run(@ComSpec) and instead of Send Command
SorryButImaNewbie and one other reacted to SmOke_N for a topic
1. Do you have to run the exe through cmd.exe? 2. There's no space separating your switch /k and @Comspec and no space after -I 3. Your quotes are off, look at the "single" double quote you have in the string from '/k to -I'. 4. You have @SW_SHOW, in the working directory parameter 5. @MDay - 1 is going to cause you trouble at the first day of the month, best to use _DateAdd(). So how I'd run the last part of the code. #include <Date.au3> Global $gsDayAdd = _DateAdd("D", -1, @YEAR & "/" & @MON & "/" & @MDAY) Run(@ComSpec & ' /k "extract.exe" -I ' & $gsDayAdd, "", @SW_SHOW) Edit: If you're having issues with Run, quotes, understanding parameters, this may help a little. It's a custom little run function. 1st parameter is the exe you're going to run (eg. @Comspec) 2nd parameter to the 11th parameter are your command line switches you want to run (if you need more than 10, just follow the code layout for the function) It makes sure it takes care of the double quotes and spaces necessary for you to run good code. #include <Date.au3> Global $gsDayAdd = _DateAdd("D", -1, _NowCalcDate()) Global $gsCommandString = _RunBuildCommandString(@ComSpec, "/k", "extract.exe", "-I", $gsDayAdd) ConsoleWrite($gsCommandString & @CRLF) ;Run($gsCommandString, "", @SW_SHOW) Func _RunBuildCommandString($sExe, $vparam1="",$vparam2="",$vparam3="", _ $vparam4="",$vparam5="", $vparam6="",$vparam7="",$vparam8="", _ $vparam9="",$vparam10=""); add more params if you need more ; check for spaces in exe string If StringRegExp($sExe, "^\s*[^\x22].*?\h") Then $sExe = '"' & $sExe & '"' EndIf Local $sCommandString, $sVal For $i = 1 To @NumParams - 1 $sVal = Eval("vparam" & $i) $sCommandString &= (StringRegExp($sVal, "^\s*[^\x22].*?\h") ? _ ' "' & $sVal & '"' : " " & $sVal) Next $sCommandString = $sExe & $sCommandString Return $sCommandString EndFunc Good luck2 points -
Ever wondered how to interact with your compiled .NET assembly and AutoIt script using COM? Then look no further, as I try to explain in simple terms the approach at which to achieve this. The code (AutoIt): As quite a few of you know, I am against the use of Global variables, as more often than not a simple approach such as encapsulating a Local Static variable in a wrapper function is just as good. Some may point out the use of the enumeration, but this is only for the purposes of doing away with "magic numbers", with the chances to expand in the future and not having to remember which number represents what etc... To create the .NET dll: In Visual Studio select a new project and class library. From there, go ahead and rename the namespace and class to something meaningful as you will need it later on when you connect to the COM interface of your .NET assembly. Add [ComVisible(true)] above the class declaration line << IMPORTANT. Once you've added all your wonderful C# related code, build the assembly and copy the .dll file to the location of your AutoIt script. Then it's just as simple as calling the _DotNet_Load() function with the filename of the .dll and voila, you have the power of AutoIt and .NET in one script. Example use of Functions: #include <File.au3> Global Const $DOTNET_PATHS_INDEX = 0, $DOTNET_REGASM_OK = 0 Global Enum $DOTNET_LOADDLL, $DOTNET_UNLOADDLL, $DOTNET_UNLOADDLLALL ; Enumeration used for the _DotNet_* functions. Global Enum $DOTNET_PATHS_FILEPATH, $DOTNET_PATHS_GUID, $DOTNET_PATHS_MAX ; Enumeration used for the internal filepath array. #cs NOTE: Don't forget to add [ComVisible(true)] to the top of the class in the class library. Otherwise it won't work. #ce Example() ; A simple example of registering and unregistering the AutoIt.dll Func Example() If _DotNet_Load('AutoIt.dll') Then ; Load the .NET compiled dll. Local $oPerson = ObjCreate('AutoIt.Person') ; Namespace.Class. If IsObj($oPerson) Then $oPerson.Name = "guinness" $oPerson.Age = Random(18, 99, 1) ConsoleWrite('Person''s age => ' & $oPerson.Age & @CRLF) $oPerson.IncreaseAge() ; A silly method to show the encapsulation of the object around the Age property. ConsoleWrite('Person''s new age => ' & $oPerson.Age & @CRLF) ConsoleWrite($oPerson.ToString() & @CRLF) ; Call the ToString() method which was overriden. Else ConsoleWrite('An error occurred when registering the Dll.' & @CRLF) EndIf Else ConsoleWrite('An error occurred when registering the Dll.' & @CRLF) EndIf ; The dll is automatically unloaded when the application closes. EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DotNet_Load ; Description ...: Load a .NET compiled dll assembly. ; Syntax ........: _DotNet_Load($sDllPath) ; Parameters ....: $sDllPath - A .NET compiled dll assembly located in the @ScriptDir directory. ; $bAddAsCurrentUser - [optional] True or false to add to the current user (supresses UAC). Default is False, all users. ; Return values .: Success: True ; Failure: False and sets @error to non-zero: ; 1 = Incorrect filetype aka not a dll. ; 2 = Dll does not exist in the @ScriptDir location. ; 3 = .NET RegAsm.exe file not found. ; 4 = Dll already registered. ; 5 = Unable to retrieve the GUID for registering as a current user. ; Author ........: guinness ; Remarks .......: With ideas by funkey for running under the current user. ; Example .......: Yes ; =============================================================================================================================== Func _DotNet_Load($sDllPath, $bAddAsCurrentUser = Default) If $bAddAsCurrentUser = Default Then $bAddAsCurrentUser = False Local $bReturn = __DotNet_Wrapper($sDllPath, $DOTNET_LOADDLL, $bAddAsCurrentUser) Return SetError(@error, @extended, $bReturn) EndFunc ;==>_DotNet_Load ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DotNet_Unload ; Description ...: Unload a previously registered .NET compiled dll assembly. ; Syntax ........: _DotNet_Unload($sDllPath) ; Parameters ....: $sDllPath - A .NET compiled dll assembly located in the @ScriptDir directory. ; Return values .: Success: True ; Failure: False and sets @error to non-zero: ; 1 = Incorrect filetype aka not a dll. ; 2 = Dll does not exist in the @ScriptDir location. ; 3 = .NET RegAsm.exe file not found. ; Author ........: guinness ; Remarks .......: With ideas by funkey for running under the current user. ; Example .......: Yes ; =============================================================================================================================== Func _DotNet_Unload($sDllPath) Local $bReturn = __DotNet_Wrapper($sDllPath, $DOTNET_UNLOADDLL, Default) Return SetError(@error, @extended, $bReturn) EndFunc ;==>_DotNet_Unload ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DotNet_UnloadAll ; Description ...: Unload all previously registered .NET compiled dll assemblies. ; Syntax ........: _DotNet_UnloadAll() ; Parameters ....: None ; Return values .: Success: True ; Failure: False and sets @error to non-zero: ; 1 = Incorrect filetype aka not a dll. ; 2 = Dll does not exist in the @ScriptDir location. ; 3 = .NET RegAsm.exe file not found. ; 4 = Dll already registered. ; 5 = Unable to retrieve the GUID for registering as a current user. ; Author ........: guinness ; Remarks .......: With ideas by funkey for running under the current user. ; Example .......: Yes ; =============================================================================================================================== Func _DotNet_UnloadAll() Local $bReturn = __DotNet_Wrapper(Null, $DOTNET_UNLOADDLLALL, Default) Return SetError(@error, @extended, $bReturn) EndFunc ;==>_DotNet_UnloadAll ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __DotNet_Wrapper ; Description ...: A wrapper for the _DotNet_* functions. ; Syntax ........: __DotNet_Wrapper($sDllPath, $iType) ; Parameters ....: $sDllPath - A .NET compiled dll assembly located in the @ScriptDir directory. ; $iType - A $DOTNET_* constant. ; Return values .: Success: True ; Failure: False and sets @error to non-zero: ; 1 = Incorrect filetype aka not a dll. ; 2 = Dll does not exist in the @ScriptDir location. ; 3 = .NET RegAsm.exe file not found. ; 4 = Dll already registered. ; 5 = Unable to retrieve the GUID for registering as current user. ; Author ........: guinness ; Remarks .......: ### DO NOT INVOKE, AS THIS IS A WRAPPER FOR THE ABOVE FUNCTIONS. ### ; Remarks .......: With ideas by funkey for running under the current user. ; Related .......: Thanks to Bugfix for the initial idea: http://www.autoitscript.com/forum/topic/129164-create-a-net-class-and-run-it-as-object-from-your-autoit-script/?p=938459 ; Example .......: Yes ; =============================================================================================================================== Func __DotNet_Wrapper($sDllPath, $iType, $bAddAsCurrentUser) Local Static $aDllPaths[Ceiling($DOTNET_PATHS_MAX * 1.3)][$DOTNET_PATHS_MAX] = [[0, 0]], _ $sRegAsmPath = Null If Not ($iType = $DOTNET_UNLOADDLLALL) Then If Not (StringRight($sDllPath, StringLen('dll')) == 'dll') Then ; Check the correct filetype was passed. Return SetError(1, 0, False) ; Incorrect filetype. EndIf If Not FileExists($sDllPath) Then ; Check the filepath exists in @ScriptDir. Return SetError(2, 0, False) ; Filepath does not exist. EndIf EndIf If $sRegAsmPath == Null Then $sRegAsmPath = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework', 'InstallRoot') If @error Then $sRegAsmPath = '' ; Set to an empty string to acknowledge that searching for the path happened. Else Local $aFilePaths = _FileListToArray($sRegAsmPath, '*', $FLTA_FOLDERS), _ $sNETFolder = '' If Not @error Then For $i = UBound($aFilePaths) - 1 To 1 Step -1 If StringRegExp($aFilePaths[$i], '(?:[vV]4\.0\.\d+)') Then $sNETFolder = $aFilePaths[$i] ExitLoop ElseIf StringRegExp($aFilePaths[$i], '(?:[vV]2\.0\.\d+)') Then $sNETFolder = $aFilePaths[$i] ExitLoop EndIf Next EndIf $sRegAsmPath &= $sNETFolder & '\RegAsm.exe' If FileExists($sRegAsmPath) Then OnAutoItExitRegister(_DotNet_UnloadAll) ; Register when the AutoIt executable is closed. Else $sRegAsmPath = '' ; Set to an empty string to acknowledge that searching for the path happened. EndIf EndIf EndIf If $sRegAsmPath == '' Then Return SetError(3, 0, False) ; .NET Framework 2.0 or 4.0 required. EndIf Switch $iType Case $DOTNET_LOADDLL Local $iIndex = -1 For $i = $DOTNET_PATHS_MAX To $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] If $sDllPath = $aDllPaths[$i][$DOTNET_PATHS_FILEPATH] Then Return SetError(4, 0, False) ; Dll already registered. EndIf If $iIndex = -1 And $aDllPaths[$i][$DOTNET_PATHS_FILEPATH] == '' Then $iIndex = $i ExitLoop EndIf Next If $iIndex = -1 Then $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] += 1 $iIndex = $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] EndIf Local Const $iUBound = UBound($aDllPaths) If $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] >= $iUBound Then ReDim $aDllPaths[Ceiling($iUBound * 1.3)][$DOTNET_PATHS_MAX] EndIf $aDllPaths[$iIndex][$DOTNET_PATHS_FILEPATH] = $sDllPath $aDllPaths[$iIndex][$DOTNET_PATHS_GUID] = Null If $bAddAsCurrentUser Then ; Idea by funkey, with modification by guinness. Local $sTempDllPath = @TempDir & '\' & $sDllPath & '.reg' If Not (RunWait($sRegAsmPath & ' /s /codebase ' & $sDllPath & ' /regfile:"' & $sTempDllPath & '"', @ScriptDir, @SW_HIDE) = $DOTNET_REGASM_OK) Then Return SetError(5, 0, False) ; Unable to retrieve the GUID for registering as current user. EndIf Local Const $hFileOpen = FileOpen($sTempDllPath, BitOR($FO_READ, $FO_APPEND)) If $hFileOpen > -1 Then FileSetPos($hFileOpen, 0, $FILE_BEGIN) Local $sData = FileRead($hFileOpen) If @error Then $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] -= 1 ; Decrease the index due to failure. Return SetError(5, 0, False) ; Unable to retrieve the GUID for registering as current user. EndIf $sData = StringReplace($sData, 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER\Software\Classes') FileSetPos($hFileOpen, 0, $FILE_BEGIN) If Not FileWrite($hFileOpen, $sData) Then $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] -= 1 ; Decrease the index due to failure. Return SetError(5, 0, False) ; Unable to retrieve the GUID for registering as current user. EndIf FileClose($hFileOpen) Local $aSRE = StringRegExp($sData, '(?:\R@="{([[:xdigit:]\-]{36})}"\R)', $STR_REGEXPARRAYGLOBALMATCH) If @error Then $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] -= 1 ; Decrease the index due to failure. Return SetError(5, 0, False) ; Unable to retrieve the GUID for registering as current user. EndIf $aDllPaths[$iIndex][$DOTNET_PATHS_GUID] = $aSRE[0] ; GUID of the registry key. RunWait('reg import "' & $sTempDllPath & '"', @ScriptDir, @SW_HIDE) ; Import to current users' classes FileDelete($sTempDllPath) EndIf Else Return RunWait($sRegAsmPath & ' /codebase ' & $sDllPath, @ScriptDir, @SW_HIDE) = $DOTNET_REGASM_OK ; Register the .NET Dll. EndIf Case $DOTNET_UNLOADDLL For $i = $DOTNET_PATHS_MAX To $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] If $sDllPath = $aDllPaths[$i][$DOTNET_PATHS_FILEPATH] And Not ($aDllPaths[$i][$DOTNET_PATHS_FILEPATH] == Null) Then Return __DotNet_Unregister($sRegAsmPath, $aDllPaths[$i][$DOTNET_PATHS_FILEPATH], $aDllPaths[$iIndex][$DOTNET_PATHS_GUID]) EndIf Next Case $DOTNET_UNLOADDLLALL Local $iCount = 0 If $sDllPath == Null And $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] > 0 Then For $i = $DOTNET_PATHS_MAX To $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] If Not ($aDllPaths[$i][$DOTNET_PATHS_FILEPATH] == Null) Then $iCount += (__DotNet_Unregister($sRegAsmPath, $aDllPaths[$i][$DOTNET_PATHS_FILEPATH], $aDllPaths[$iIndex][$DOTNET_PATHS_GUID]) ? 1 : 0) EndIf Next $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] = 0 ; Reset the count. Return $iCount == $aDllPaths[$DOTNET_PATHS_INDEX][$DOTNET_PATHS_FILEPATH] EndIf EndSwitch Return True EndFunc ;==>__DotNet_Wrapper Func __DotNet_Unregister($sRegAsmPath, ByRef $sDllPath, ByRef $sGUID) Local $bReturn = RunWait($sRegAsmPath & ' /unregister ' & $sDllPath, @ScriptDir, @SW_HIDE) = $DOTNET_REGASM_OK ; Unregister the .NET Dll. If $bReturn Then If Not ($sGUID == Null) Then RegDelete('HKEY_CURRENT_USER\Software\Classes\CLSID\' & $sGUID) ; 32-bit path. RegDelete('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\' & $sGUID) ; 64-bit path. $sGUID = Null ; Remove item. EndIf $sDllPath = Null ; Remove item. EndIf Return $bReturn EndFunc ;==>__DotNet_UnregisterI look forward to the comments and questions people have on this interesting subject, as well as any suggestions of improvement people might have. The ZIP file contains all related source code for both AutoIt and .NET. Dot-NET Assembly in AutoIt.zip1 point
-
Never say I don't give this community some little gems once in a while. I came up with the concept of creating a directory structure using nothing but valid HTML5 and CSS3. It uses an unknown "checkbox hack" concept which some HTML5/CSS3 purists consider to be beyond the semantics of the language. But I say if it's supported by all major browsers and it works, then why not! Note: I used >KaFu's idea for the current level and next level, but the rest I came up with myself, albeit I have used this "checkbox hack" before in other projects I have created. #include <File.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> MsgBox($MB_SYSTEMMODAL, '', 'This example only uses HTML5 and CSS3, I know, no JavaScript!') ; Thanks to KaFu for the idea: http://www.autoitscript.com/forum/topic/156913-dir2html-create-html-site-with-links-from-a-dir-structure/?p=1136522 Example() Func Example() Local Const $sSaveFilePath = @ScriptDir Local $sHTML = '', $sTab = @TAB _HTML_Add($sHTML, '<!DOCTYPE html>') _HTML_Add($sHTML, '<html lang="en">') _HTML_Add($sHTML, '<head>') _HTML_Add($sHTML, '<meta charset="utf-8">', $sTab) _HTML_Add($sHTML, '<title>Directory To HTML5 Concept</title>', $sTab) _HTML_Add($sHTML, '<style type="text/css">', $sTab) _Tab_Add($sTab) _HTML_Add($sHTML, '@import url(http://weloveiconfonts.com/api/?family=fontawesome);.dirtohtml a{background:transparent;color:#08c;position:relative;text-decoration:none;-webkit-transition:all .3s ease-out;transition:all .3s ease-out}.dirtohtml a:hover{color:#0af}.dirtohtml input[type=checkbox],.dirtohtml input[type=checkbox]+ul{display:none}.dirtohtml input[type=checkbox]:checked+ul{display:block}.dirtohtml label{cursor:pointer}.dirtohtml ul li{list-style:none}[class*="fontawesome-"]:before{font-family:"FontAwesome",sans-serif;margin-right:5px}', $sTab) _Tab_Remove($sTab) _HTML_Add($sHTML, '</style>', $sTab) _Tab_Remove($sTab) _HTML_Add($sHTML, '</head>') _HTML_Add($sHTML, '<body>') _Tab_Add($sTab) Local Const $sDirectorySelection = FileSelectFolder('Select a folder to map to HTML', '') Local $aFileList = _FileListToArrayRec($sDirectorySelection, '*', 0, 1, 2, 2) If @error Then _HTML_Add($sHTML, '<p>No files were present in the selected directory.</p>', $sTab) Else _HTML_Add($sHTML, '<div class="dirtohtml">', $sTab) _Tab_Add($sTab) _HTML_Add($sHTML, '<ul>', $sTab) _Tab_Add($sTab) Local $bIsRelative = False, _ $iCheckboxCount = 1, $iCurrentLevel = 0, $iNestedDepth = 0, $iNextIndex = 0, $iNextLevel = 0, _ $sFileName = '', $sRelativeFilePath = '' For $i = 1 To $aFileList[0] $aFileList[$i] = StringRegExpReplace($aFileList[$i], '(?:\\|/)', '\\') $iCurrentLevel = @extended If $i < $aFileList[0] Then $iNextIndex = $i + 1 $aFileList[$iNextIndex] = StringRegExpReplace($aFileList[$iNextIndex], '(?:\\|/)', '\\') $iNextLevel = @extended EndIf $sFileName = StringRegExpReplace($aFileList[$i], '^.+\\', '') If _WinAPI_PathIsDirectory($aFileList[$i]) = $FILE_ATTRIBUTE_DIRECTORY Then If $iNextLevel > $iCurrentLevel Or $iNextLevel = $iCurrentLevel Then _HTML_Add($sHTML, '<li>', $sTab) _Tab_Add($sTab) _HTML_Add($sHTML, '<label for="dirtohtml_' & $iCheckboxCount & '"><i class="fontawesome-folder-close-alt"></i>' & $sFileName & '</label>', $sTab) _HTML_Add($sHTML, '<input id="dirtohtml_' & $iCheckboxCount & '" type="checkbox">', $sTab) _HTML_Add($sHTML, '<ul>', $sTab) $iCheckboxCount += 1 $iNestedDepth += 1 ElseIf $iNextLevel < $iCurrentLevel Then _HTML_Add($sHTML, '<li>' & $sFileName, $sTab) EndIf _Tab_Add($sTab) Else $sRelativeFilePath = _PathGetRelative($sSaveFilePath, $aFileList[$i]) $bIsRelative = Not @error _HTML_Add($sHTML, '<li><i class="fontawesome-file"></i><a href="' & ($bIsRelative ? '' : 'file://') & StringReplace($sRelativeFilePath, '\', '/') & '">' & $sFileName & '</a></li>', $sTab) If $iNextLevel < $iCurrentLevel Then For $j = 1 To ($iCurrentLevel - $iNextLevel) _Tab_Remove($sTab) _HTML_Add($sHTML, '</ul>', $sTab) _Tab_Remove($sTab) _HTML_Add($sHTML, '</li>', $sTab) $iNestedDepth -= 1 Next EndIf EndIf Next If $iNestedDepth Then For $j = 1 To $iNestedDepth _Tab_Remove($sTab) _HTML_Add($sHTML, '</ul>', $sTab) _Tab_Remove($sTab) _HTML_Add($sHTML, '</li>', $sTab) Next EndIf _Tab_Remove($sTab) _HTML_Add($sHTML, '</ul>', $sTab) _Tab_Remove($sTab) _HTML_Add($sHTML, '</div>', $sTab) EndIf _HTML_Add($sHTML, '</body>') _HTML_Add($sHTML, '</html>') Local Const $sHTMLFilePath = _WinAPI_PathRemoveBackslash($sSaveFilePath) & '\index.html' Local Const $hFileOpen = FileOpen($sHTMLFilePath, BitOR($FO_OVERWRITE, $FO_UTF8)) If $hFileOpen > -1 Then FileWrite($hFileOpen, $sHTML) FileClose($hFileOpen) MsgBox($MB_SYSTEMMODAL, '', 'HTML file created successfully.' & @CRLF & $sHTMLFilePath) Else MsgBox($MB_SYSTEMMODAL, '', 'An error occurred writing to the HTML file.') EndIf ConsoleWrite($sHTML & @CRLF) ; ShellExecute($sHTMLFilePath) Return True EndFunc ;==>Example Func _HTML_Add(ByRef $sHTML, $sData, $sTab = Default) $sHTML &= (($sTab = Default) ? '' : $sTab) & $sData & @CRLF EndFunc ;==>_HTML_Add Func _Tab_Add(ByRef $sTab) $sTab &= @TAB EndFunc ;==>_Tab_Add Func _Tab_Remove(ByRef $sTab) Local Static $TAB_LENGTH = StringLen(@TAB) $sTab = StringTrimRight($sTab, $TAB_LENGTH) EndFunc ;==>_Tab_Remove1 point
-
This small function allows you to add an alpha channel (mask) to the specified GDI+ bitmap (see screenshots). Source bitmap and mask may be of any color depth. The output bitmap is always 32 bits-per-pixel with alpha channel. Optionally, the alpha channel may be generated from any channel of the specified mask (1 - Red, 2 - Green, 3 - Blue, or 0 - Alpha). The example below is written for Autoit 3.3.12.0. #Include <GDIPlus.au3> If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.') EndIf _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\Image.png') $hAlpha = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\Alpha.png') $hResult = _GDIPlus_BitmapCreateBitmapWithAlpha($hBitmap, $hAlpha, 1) _GDIPlus_ImageSaveToFile($hResult, @ScriptDir & '\Image+Alpha.png') _GDIPlus_BitmapDispose($hResult) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hAlpha) _GDIPlus_Shutdown() Func _GDIPlus_BitmapCreateBitmapWithAlpha($hBitmap, $hAlpha, $iChannel = 0) Local $hGraphics, $hBmp[2], $bProc, $tProc, $pProc, $Size1, $Size2, $Lenght, $Result Local $tData[2] = [$GDIP_ILMWRITE, $GDIP_ILMREAD] $Size1 = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hBitmap, 'float*', 0, 'float*', 0) If (@Error) Or ($Size1[0]) Then Return 0 EndIf $Size2 = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hAlpha, 'float*', 0, 'float*', 0) If (@Error) Or ($Size2[0]) Then Return 0 EndIf $hBmp[0] = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $Size1[2], $Size1[3], $GDIP_PXF32ARGB) If ($Size1[2] = $Size2[2]) And ($Size1[3] = $Size2[3]) Then $hBmp[1] = $hAlpha Else $hBmp[1] = _GDIPlus_BitmapCreateFromScan0($Size1[2], $Size1[3], $GDIP_PXF32ARGB) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBmp[1]) _GDIPlus_GraphicsClear($hGraphics, 0) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hAlpha, 0, 0, $Size1[2], $Size1[3]) _GDIPlus_GraphicsDispose($hGraphics) EndIf If ($iChannel < 0) Or ($iChannel > 3) Then $iChannel = 0 EndIf For $i = 0 To 1 $tData[$i] = _GDIPlus_BitmapLockBits($hBmp[$i], 0, 0, $Size1[2], $Size1[3], $tData[$i], $GDIP_PXF32ARGB) Next If @AutoItX64 Then $bProc = Binary('0x48894C240848895424104C894424184C894C24205541574831C0505050504883EC2848837C24600074054831C0EB0748C7C0010000004821C00F858100000048837C24680074054831C0EB0748C7C0010000004821C07555837C24700074054831C0EB0748C7C0010000004821C0752A4C637C24784D21FF7C0D4C637C24784983FF037F02EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C0740B4831C04863C0E9950000004C8B7C24604983C7034C897C24284C8B7C246848634424784929C74983C7034C897C243048C7442438000000004C637C247049FFCF4C3B7C24387C4A488B6C24284C0FB67D00488B6C2430480FB645004C0FAFF84C89F848C7C1FF000000489948F7F94989C74C89F850488B6C24305888450048834424280448834424300448FF44243871A748C7C0010000004863C0EB034831C04883C448415F5DC3') Else $bProc = Binary('0x555331C0505050837C241800740431C0EB05B80100000021C07568837C241C00740431C0EB05B80100000021C07545837C242000740431C0EB05B80100000021C075228B5C242421DB7C0B8B5C242483FB037F02EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C0740431C0EB6B8B5C241883C303891C248B5C241C2B5C242483C303895C2404C7442408000000008B5C24204B3B5C24087C368B2C240FB65D008B6C24040FB645000FAFD889D8B9FF00000099F7F989C3538B6C240458884500830424048344240404FF44240871BFB801000000EB0231C083C40C5B5DC21000') EndIf $Length = BinaryLen($bProc) $pProc = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', $Length, 'dword', 0x1000, 'dword', 0x0040) $tProc = DllStructCreate('byte[' & $Length & ']', $pProc[0]) DllStructSetData($tProc, 1, $bProc) $Result = DllCallAddress('uint', $pProc[0], 'ptr', $tData[0].Scan0, 'ptr', $tData[1].Scan0, 'uint', $Size1[2] * $Size1[3], 'uint', $iChannel) If Not $Result[0] Then ; Nothing EndIf DllCall('kernel32.dll', 'int', 'VirtualFree', 'ptr', $pProc[0], 'ulong_ptr', 0, 'dword', 0x4000) For $i = 0 To 1 _GDIPlus_BitmapUnlockBits($hBmp[$i], $tData[$i]) Next If $hBmp[1] <> $hAlpha Then _GDIPlus_BitmapDispose($hBmp[1]) EndIf Return $hBmp[0] EndFunc ;==>_GDIPlus_BitmapCreateBitmapWithAlpha Function + Example Previous downloads: 47 GDIPlus_BitmapCreateBitmapWithAlpha.zip1 point
-
GuiBuilderNxt - Reboot [08/18/2016]
mikell reacted to jaberwacky for a topic
A program called ByHand.exe.1 point -
You called? lol Anyway, Vista didn't like it, it's all distorted with $bAndyMode true or false, and have to use task manager to kill it (add a hotkey to exit ). But I'm going to leave it running on the borrowed PC I'm on anyway... can't wait to see the owners faces1 point
-
Shadow12345, you can either go the crude way, as jdelaney post #7 suggests, or try here: http://sourceforge.net/projects/genie.adobe/1 point
-
I'm fairly sure your "string" data is not what you think it is. Run this example, if this works, then you need to change the approach to the string vs binary data that I've suggested already: #include <Array.au3> #include <String.au3> ; stringbetween returns an array ; checking it as a string return is not going to help you Local $sHTMLString = "<html>" & @CRLF $sHTMLString &= "<body>" & @CRLF $sHTMLString &= '<table id="mytable">' & @CRLF $sHTMLString &= "<tr>" & @CRLF $sHTMLString &= "<td>noting much</td>" & @CRLF $sHTMLString &= '<td class="labelLeft" colspan="3"><b><span class="validStyle">somedata here</span></b></td>' & @CRLF $sHTMLString &= "</tr>" & @CRLF $sHTMLString &= "</table>" & @CRLF $sHTMLString &= "</body>" & @CRLF $sHTMLString &= "</html>" Local $content = $sHTMLString Local $start_Status = '<td class="labelLeft" colspan="3"><b><span class="validStyle">' consolewrite($start_Status & @crlf) Local $end_Status = '</span></b></td>' Local $Status = _StringBetween($content,$start_Status,$end_Status) _ArrayDisplay($Status) ... Good luck1 point
-
This function allows you to blur the specified GDI+ bitmap with different force of blur (see screenshots, 1 - source image, 2 - blurring image with L=5, 3 - blurring image with L=10). The source bitmap may be of any color depth, the output bitmap is always 32 bits-per-pixel with alpha channel. The function creates a few parallel threads (up to 8), that significantly reduces the time consumption. It's worth noting that the blurring is performed for all channels, including the alpha channel. The following shows the basic algorithm for a simple blur of bitmap written in AutoIt. Unfortunately, it is not possible to solve using AutoIt because the processing of even a small picture may require too much time. For example, blurring image 100x100 can last a few seconds. To solve this problem, I compiled the time-consuming part of code (main loop) to machine code. This solved the problem of the time consumption but I wanted to get better results, especially for large images (more than 1000x1000) and large blur radius (10+). Then I divided the source image into several parts and started the blurring of each part in a separate thread. Now it's become quite good. See below for a complete example written for Autoit 3.3.12.0. ; Scans the source bitmap pixel by pixel For $Yi = 0 To $H - 1 For $Xi = To $W - 1 $A = 0 $R = 0 $G = 0 $B = 0 $Count = 0 ; Calculates the average value for each color channel of source bitmap (including alpha chennel) For $Yj = $Yi - $L To $Yi + $L For $Xj = $Xi - $L To $Xi + $L If ($Xj >= 0) And ($Xj < $W) And ($Yj >= 0) And ($Yj < $H) Then $ARGB = DllStructCreate('BYTE B;BYTE G;BYTE R;BYTE A', $pBitsSrc + ($Xj + $Yj * $W) * 4) $A += $ARGB.A $R += $ARGB.R $G += $ARGB.G $B += $ARGB.B $Count += 1 EndIf Next Next ; Writes the calculated color to the corresponding pixel of destination bitmap $ARGB = DllStructCreate('BYTE B;BYTE G;BYTE R;BYTE A', $pBitsDst + ($Xj + $Yj * $W) * 4) $ARGB.A = $A / $Count $ARGB.R = $R / $Count $ARGB.G = $G / $Count $ARGB.B = $B / $Count Next Next #Include <GDIPlus.au3> If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.') EndIf $sFile = @ScriptDir & '\Birds.png' _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($sFile) $hBlur = _GDIPlus_BitmapCreateBlurBitmap($hBitmap, 5, 1) _GDIPlus_ImageSaveToFile($hBlur, StringRegExpReplace($sFile, '(\.[^\.]+)', '_Blur\1')) _GDIPlus_BitmapDispose($hBlur) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Func _GDIPlus_BitmapCreateBlurBitmap($hBitmap, $iRadius, $fAccurate = False) Local $tData[2], $hThread, $iThread, $tParams, $bProc, $tProc, $pProc, $aSize, $aHeight, $iLength, $hResult, $aResult $aSize = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hBitmap, 'float*', 0, 'float*', 0) If (@Error) Or ($aSize[0]) Then Return 0 EndIf For $i = 2 To 3 If $iRadius > $aSize[$i] Then $iRadius = $aSize[$i] EndIf Next If $iRadius < 1 Then Return 0 EndIf $hResult = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3], $GDIP_PXF32ARGB) $tData[0] = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aSize[2], $aSize[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) $tData[1] = _GDIPlus_BitmapLockBits($hResult, 0, 0, $aSize[2], $aSize[3], $GDIP_ILMWRITE, $GDIP_PXF32ARGB) If @AutoItX64 Then $bProc = Binary('0x48894C24085541574156415548C7C00A0000004883EC0848C704240000000048FFC875EF4883EC28488BAC24A000000048837D000074054831C0EB0748C7C0010000004821C00F855E010000488BAC24A000000048837D080074054831C0EB0748C7C0010000004821C00F8527010000488BAC24A0000000837D180074054831C0EB0748C7C0010000004821C00F85F1000000488BAC24A0000000837D1C0074054831C0EB0748C7C0010000004821C00F85BB000000488BAC24A0000000837D200074054831C0EB0748C7C0010000004821C00F8585000000488BAC24A0000000837D240074054831C0EB0748C7C0010000004821C07553488BAC24A0000000837D280074054831C0EB0748C7C0010000004821C07521488BAC24A0000000837D2C0074054831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C0740B4831C04863C0E946030000488BAC24A00000004863451450584889442428488BAC24A00000004C637D14488BAC24A00000004863451C4901C749FFCF4C3B7C24280F8CFB020000488BAC24A00000004863451050584889442430488BAC24A00000004C637D10488BAC24A0000000486345184901C749FFCF4C3B7C24300F8CB402000048C74424380000000048C74424400000000048C74424480000000048C74424500000000048C7442458000000004C8B7C2428488BAC24A0000000486345284929C74C897C24604C8B7C24604C8B742428488BAC24A0000000486345284901C64D39F70F8F840100004C8B7C2430488BAC24A0000000486345284929C74C897C24684C8B7C24684C8B742430488BAC24A0000000486345284901C64D39F70F8F2B0100004C8B7C24684D21FF7C614C8B7C2468488BAC24A0000000486345204939C77D3A4C8B7C24604D21FF7C1F4C8B7C2460488BAC24A0000000486345244939C77D0948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C00F8496000000488BAC24A00000004C8B7D004C8B7424684C8B6C2460488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438488B6C2470480FB645034901C74C897C24384C8B7C2440488B6C2470480FB645024901C74C897C24404C8B7C2448488B6C2470480FB645014901C74C897C24484C8B7C2450488B6C2470480FB645004901C74C897C245048FF4424584C8B7C2468488BAC24A00000004863452C4901C74C897C2468E9B3FEFFFF4C8B7C2460488BAC24A00000004863452C4901C74C897C2460E95AFEFFFF488BAC24A00000004C8B7D084C8B7424304C8B6C2428488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845034C8B7C2440FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845024C8B7C2448FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845014C8B7C2450FF7424584C89F859489948F7F94989C74C89F850488B6C24785888450048FF4424300F8123FDFFFF48FF4424280F81DCFCFFFF48C7C0010000004863C0EB034831C04883C478415D415E415F5DC3') Else $bProc = Binary('0x55535756BA0A00000083EC04C70424000000004A75F38B6C243C837D0000740431C0EB05B80100000021C00F85090100008B6C243C837D0400740431C0EB05B80100000021C00F85DF0000008B6C243C837D1000740431C0EB05B80100000021C00F85B50000008B6C243C837D1400740431C0EB05B80100000021C00F858B0000008B6C243C837D1800740431C0EB05B80100000021C075658B6C243C837D1C00740431C0EB05B80100000021C0753F8B6C243C837D2000740431C0EB05B80100000021C075198B6C243C837D2400740431C0EB05B80100000021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C0740731C0E9400200008B6C243C8B450C8904248B6C243C8B5D0C8B6C243C035D144B3B1C240F8C150200008B6C243C8B4508894424048B6C243C8B5D088B6C243C035D104B3B5C24040F8CE8010000C744240800000000C744240C00000000C744241000000000C744241400000000C7442418000000008B1C248B6C243C2B5D20895C241C8B5C241C8B3C248B6C243C037D2039FB0F8F0D0100008B5C24048B6C243C2B5D20895C24208B5C24208B7C24048B6C243C037D2039FB0F8FD30000008B5C242021DB7C438B5C24208B6C243C3B5D187D298B5C241C21DB7C148B5C241C8B6C243C3B5D1C7D07B801000000EB0231C021C07407B801000000EB0231C021C07407B801000000EB0231C021C0746E8B6C243C8B5D008B7C24208B74241C8B6C243C0FAF751801F7C1E70201FB895C24248B5C24088B6C24240FB6450301C3895C24088B5C240C8B6C24240FB6450201C3895C240C8B5C24108B6C24240FB6450101C3895C24108B5C24148B6C24240FB6450001C3895C2414FF4424188B5C24208B6C243C035D24895C2420E916FFFFFF8B5C241C8B6C243C035D24895C241CE9DDFEFFFF8B6C243C8B5D048B7C24048B34248B6C243C0FAF751801F7C1E70201FB895C24248B5C2408FF74241889D85999F7F989C3538B6C2428588845038B5C240CFF74241889D85999F7F989C3538B6C2428588845028B5C2410FF74241889D85999F7F989C3538B6C2428588845018B5C2414FF74241889D85999F7F989C3538B6C242858884500FF4424040F81FFFDFFFFFF04240F81D3FDFFFFB801000000EB0231C083C4285E5F5B5DC20400') EndIf $iLength = BinaryLen($bProc) $pProc = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', $iLength, 'dword', 0x1000, 'dword', 0x0040) $tProc = DllStructCreate('byte[' & $iLength & ']', $pProc[0]) DllStructSetData($tProc, 1, $bProc) $iThread = 8 If $iThread > $aSize[3] Then $iThread = $aSize[3] EndIf Dim $aHeight[$iThread] Dim $tParams[$iThread] Dim $hThread[$iThread] If $iThread = 1 Then $aHeight[0] = $aSize[3] Else $aHeight[0] = Floor($aSize[3] / $iThread) $aHeight[$iThread - 1] = $aSize[3] - $aHeight[0] * ($iThread - 1) For $i = 1 To $iThread - 2 $aHeight[$i] = $aHeight[0] Next EndIf $iLength = 0 For $i = 0 To $iThread - 1 $tParams[$i] = DllStructCreate('ptr;ptr;uint;uint;uint;uint;uint;uint;uint;uint') DllStructSetData($tParams[$i], 1, $tData[0].Scan0) DllStructSetData($tParams[$i], 2, $tData[1].Scan0) DllStructSetData($tParams[$i], 3, 0) DllStructSetData($tParams[$i], 4, $iLength) DllStructSetData($tParams[$i], 5, $aSize[2]) DllStructSetData($tParams[$i], 6, $aHeight[$i]) DllStructSetData($tParams[$i], 7, $aSize[2]) DllStructSetData($tParams[$i], 8, $aSize[3]) DllStructSetData($tParams[$i], 9, $iRadius) If $fAccurate Then DllStructSetData($tParams[$i],10, 1) Else DllStructSetData($tParams[$i],10, 2) EndIf $iLength+= $aHeight[$i] $aResult = DllCall('kernel32.dll', 'handle', 'CreateThread', 'ptr', 0, 'dword_ptr', 0, 'ptr', $pProc[0], 'struct*', $tParams[$i], 'dword', 0, 'ptr', 0) If (Not @Error) And ($aResult[0]) Then $hThread[$i] = $aResult[0] Else $hThread[$i] = 0 EndIf Next While 1 $iLength = 0 For $i = 0 To $iThread - 1 If $hThread[$i] Then $aResult = DllCall('kernel32.dll', 'bool', 'GetExitCodeThread', 'handle', $hThread[$i], 'dword*', 0) If (@Error) Or (Not $aResult[0]) Or ($aResult[2] <> 259) Then DllCall('kernel32.dll', 'bool', 'CloseHandle', 'handle', $hThread[$i]) $hThread[$i] = 0 Else $iLength += 1 EndIf EndIf Next If Not $iLength Then ExitLoop EndIf WEnd $aResult = DllCall('kernel32.dll', 'int', 'VirtualFree', 'ptr', $pProc[0], 'ulong_ptr', 0, 'dword', 0x4000) If (@Error) Or (Not $aResult[0]) Then ; Nothing EndIf _GDIPlus_BitmapUnlockBits($hResult, $tData[1]) _GDIPlus_BitmapUnlockBits($hBitmap, $tData[0]) Return $hResult EndFunc ;==>_GDIPlus_BitmapCreateBlurBitmap Function + Example Previous downloads: 17 GDIPlus_BitmapCreateBlurBitmap.zip1 point
-
DirToHTML5 - Create a HTML5 and CSS3 only directory structure without JavaScript.
TouchOdeath reacted to guinness for a topic
Okay thanks. You're also welcome, as I believe sharing is caring!1 point -
The send function goes to the active window. If the user switches to another window while your script is running you will get wrong results. The Word UDF uses COM to directly access the Word document.1 point
-
Or you could use the Word UDF that comes with AutoIt and check if this works as expected. The UDF is more stable as it doesn't interfere with user input.1 point
-
From the Send-Helpfile: To get the Unicode of a character you have to use: AscW ( "char" ) But AutoIt doesn't fully support all UNICODE characters (just read through the helpfile)1 point
-
4b0082, It works for me: $iFactor = 100 Local $Total = .57 Local $SubTotal = Round($Total/1.15, 2) Local $rFee = Number(FloorEx($SubTotal * 0.1, 2)) + Number(FloorEx($SubTotal * 0.05, 2)) Local $rTotal = $SubTotal + $rFee ConsoleWrite($rTotal & " - " & $Total & @CRLF) ConsoleWrite(Hex($rTotal) & @CRLF & Hex($Total) & @CRLF) If Int ($rTotal * $iFactor) <> Int ($Total * $iFactor) Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< MsgBox(0, "Broken", Hex($rTotal) & @CRLF & Hex($Total)) Else MsgBox(0, "Works", ";)") EndIf Func FloorEx($fNumber, $iDec = 3) Return StringFormat("%." & $iDec & "f", Floor($fNumber * 10 ^ $iDec) / 10 ^ $iDec) EndFunc M231 point
-
kcvinu, Welcome to the AutoIt forum. But please pay attention to where you post - the "Dev Chat" section where you started both of your recent threads is not for general support questions. I have moved both for you, but would ask you to be more careful in future. M231 point
-
Did you run the consolewrite after _InetGetSource() like I suggested? Try this: $content = _INetGetSource("C:\Data\Auto ITs\check\Test.htm", True) Your data is coming out in binary form, you're searching for strings.1 point
-
Even though this is horrible scripted (I tried to fit in different ways to handle this), but it works for me: Edit the $content = _GetSource to your benefiting. If you want to get it via _INETGetSource then you have to call the function with $content = _GetSource("http://yourdomainhere.com",2) HotKeySet("{ESC}", "Terminate") Opt("WinTextMatchMode", 2) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase AutoItSetOption("MouseCoordMode", 0) opt("SendKeyDelay",90) opt("WinWaitDelay",35) opt("TrayIconDebug",1) #include <IE.au3> #include <Inet.au3> #include <Array.au3> #include <String.au3> #include <MsgBoxConstants.au3> If FileExists(@ScriptDir & "\check.csv") =false Then FileWrite(@ScriptDir & "\check.csv","Actief;Lidstaat;nummer;Tijdstip waarop de aanvraag werd ontvangen;Naam;Adres;Cnummer"& @CRLF) EndIf $content = _GetSource(@ScriptDir & "\Test.htm") $start_Status = '<td class="labelLeft" colspan="3"><b><span class="validStyle">' $end_Status = '</span></b></td>' $Status = _StringBetween($content,$start_Status,$end_Status) $Lidstaat = _GrabValue($content,4) $nr = _GrabValue($content,7) $Tijd = _GrabValue($content,9) $Naam = _GrabValue($content,11) $Naam = StringReplace($Naam,@CRLF,"") $Adres = _GrabValue($content,13) $Adres = StringReplace($Adres,"<br />","") $Adres = StringReplace($Adres,@CRLF,"") $Cnummer = _GrabValue($content,15) $aio= $Status[0]&";"&$Lidstaat&";"&$nr&";"&$Tijd&";"&$Naam&";"&$Adres&";"&$Cnummer MsgBox(0,"",$aio) FileWrite ( "check.csv", $aio & @CRLF ) Func _GrabValue($sContent,$iOccurence) Local $start Local $end $start = StringInStr($sContent,"<td",0,$iOccurence) $start += 4 $end = StringInStr($content,"</td>",0,$iOccurence) Return StringMid($content,$start,$end - $start) EndFunc Func _GetSource($sHandle,$iMode=1) Switch $iMode Case 1 Return FileRead($sHandle) Case 2 Return _INetGetSource($sHandle) Case Else Return 0 EndSwitch EndFunc Func Terminate() Exit 0 EndFunc1 point
-
Get disk & partition index number from driver letter
doestergaard reacted to water for a topic
This should display a MsgBox for all drives displaying disk # and partition #. $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $WMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDiskToPartition") For $obj In $WMIQuery $sAntecedent = $obj.Antecedent $sDependent = $obj.Dependent $iDisk = StringMid($sAntecedent, StringInStr($sAntecedent, "Disk #") + 6, 1) $iPartitiion = StringMid($sAntecedent, StringInStr($sAntecedent, "Partition #") + 11, 1) $sDrive = StringMid($sDependent, StringInStr($sDependent, 'DeviceID="') + 10, 1) MsgBox(0, $sDrive & " Drive", $sDrive & " Drive is on Disk #" & $iDisk & ", partition #" & $iPartitiion) Next Works for one digit disk # and partition #.1 point -
Line breaks visibility (CRLF) turn on/off key command?
SorryButImaNewbie reacted to Melba23 for a topic
SorryButImaNewbie, A little bit of googling (you did try that yourself before posting? ) tells me that Ctrl-Shft-9 or the <View - Endof Line> menu item will toggle EOL visibility. M231 point -
; Pattern written by MrCreatoR. If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.') EndIf1 point
-
Why does it goes in to the 2. case?
SorryButImaNewbie reacted to Gianni for a topic
try this syntax for case: Case 0 instead of Case $check = 01 point -
Insert a space before "/k". Run(@ComSpec & ' /k "extract.exe -I' & @YEAR &"/" & @MON & "/" & @MDAY-1, @SW_SHOW)1 point
-
hi here are two little functions I made to encode and decode web URL strings, any chars that are not valid are converted to hexadecimal and vice versa, Well I wrapped it up with a little GUI for you to test hope it maybe useful. #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local Const $AppTitle = "URL Tools" Func DecodeUrl($src) Local $i Local $ch Local $buff ;Init Counter $i = 1 While ($i <= StringLen($src)) $ch = StringMid($src, $i, 1) ;Correct spaces If ($ch = "+") Then $ch = " " EndIf ;Decode any hex values If ($ch = "%") Then $ch = Chr(Dec(StringMid($src, $i + 1, 2))) $i += 2 EndIf ;Build buffer $buff &= $ch ;Inc Counter $i += 1 WEnd Return $buff EndFunc ;==>DecodeUrl Func EncodeUrl($src) Local $i Local $ch Local $NewChr Local $buff ;Init Counter $i = 1 While ($i <= StringLen($src)) ;Get byte code from string $ch = Asc(StringMid($src, $i, 1)) ;Look for what bytes we have Switch $ch ;Looks ok here Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $buff &= Chr($ch) ;Space found Case 32 $buff &= "+" Case Else ;Convert $ch to hexidecimal $buff &= "%" & Hex($ch, 2) EndSwitch ;INC Counter $i += 1 WEnd Return $buff EndFunc ;==>EncodeUrl Func ShowForm() Local $Data ;Create form controls $frmmain = GUICreate($AppTitle, 509, 265, 314, 360) $lblTitle1 = GUICtrlCreateLabel("URL Decoder/Encoder", 8, 7, 115, 17) $cmdEncode = GUICtrlCreateButton("&Encode", 423, 26, 75, 25) $cmdExit = GUICtrlCreateButton("E&xit", 423, 132, 75, 25) $txtData = GUICtrlCreateEdit("Testing + 12 http://www.google.com", 8, 26, 409, 193) $cmdDecode = GUICtrlCreateButton("&Decode", 423, 57, 75, 25) $cmdAbout = GUICtrlCreateButton("&About", 423, 100, 75, 25) $lblDesc = GUICtrlCreateLabel("Ben's URL Encoder/Decoder v1.0", 90, 228, 243, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) ;Show form GUISetState(@SW_SHOW) ;Form Messages loop While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cmdExit Exit Case $cmdEncode ;Get text data $Data = _GUICtrlEdit_GetText($txtData) ;Check length If StringLen($Data) > 0 Then ;Place text into decoded text box. _GUICtrlEdit_SetText($txtData, EncodeUrl($Data)) EndIf Case $cmdDecode ;Get text data $Data = _GUICtrlEdit_GetText($txtData) ;Check length If StringLen($Data) > 0 Then ;Place text into decoded text box. _GUICtrlEdit_SetText($txtData, DecodeUrl($Data)) EndIf Case $cmdAbout MsgBox(64, "About", $AppTitle & " v1.0" & @CRLF & @TAB & "By Ben Jones") EndSwitch WEnd EndFunc ;==>ShowForm ;Load main form ShowForm()1 point
-
GUICtrlSetOnEvent with system tray menu?
brokenbeforetime reacted to SmOke_N for a topic
TraySetOnEvent Edit: Don't forget Opt("TrayOnEventMode", 1)1 point -
Handling PopUp windows while logging in IE
SorryButImaNewbie reacted to junkew for a topic
You have windows popups and you have popping up html windows and you have html5 overlays so screenshot helps to understand what you talk about. Iuiautomation in examples section can handle a lot.of scenarios and sometimes.ie.au3 can help out. When its a windows popup native autoit controlclick will be sufficient1 point