Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/24/2020 in all areas

  1. Are you annoyed by the limitations of the standard Windows message dialog created by MsgBox? Would you like to have coloured backgrounds and text? To choose the justification and font? Do you want to be able to place the message box other than in the centre of the screen? Centred on your GUI, for example, or at a particular location on screen? What about having user-defined text on as many buttons as you need? And user-defined icons? Or a visible countdown of the timeout? Finally, would you like to choose whether the message box has a button on your already too-crowded taskbar? If the answer to any of these questions is "YES" then the ExtMsgBox UDF is for you! [NEW VERSION] 16 Feb 24 Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox: - A positive integer sets the EMB timeout as before. - A negative integer will double the size of the countdown timer if it is used. - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer). New UDF and examples in the zip. Older version changes: ChangeLog.txt As always, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - but as with all my UDFs (which you can find in my sig below) I am trying to prevent the need for any other include files. The UDF and examples (plus StringSize) in zip format: ExtMsgBox.zip Courteous comments and constructive criticisms welcome - guess which I prefer! M23
    1 point
  2. 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
  3. @Guru_Ragavendra I suspect that you are using an out-of-date version of WinHTTP. Please see here for details on how to obtain the correct version. Also, please review this link for proper way to post code on the forum.
    1 point
  4. Hello. You just need to free it when you're not using it. UDF design is not so good but basically you will need to do this. #include <OO_JSON.au3> ConsoleWrite(@AutoItPID & @CRLF) Local $iMemoryUsage = _ProcessGetMemoryUsage() ConsoleWrite("Dicionary Empty. Current Memory Usage: " & $iMemoryUsage & @CRLF) MsgBox(0, "", "1") Global $g_oJSON = 0 _CreateNewJsonObject() ;create Local $jsObj For $i=1 to 1 $jsObj=$g_oJSON.parse(FileRead("C:\Users\Raziel\Desktop\mobileread_get_books.json")) Next $jsObj=0 ;free Object $iMemoryUsage = _ProcessGetMemoryUsage() ;free old Json Object and Data and create new one ConsoleWrite("Dicionary Empty. Current Memory Usage: " & $iMemoryUsage & @CRLF) MsgBox(0, "", "2") _CreateNewJsonObject() $iMemoryUsage = _ProcessGetMemoryUsage() ConsoleWrite("Dicionary Empty. Current Memory Usage: " & $iMemoryUsage & @CRLF) MsgBox(0, "", "3") ;this will free old instance and free Memory ;I do not recommend to call it in a very long loop Func _CreateNewJsonObject() If IsObj($g_oJSON) Then $g_oJSON=0 $g_oJSON=_OO_JSON_Init() EndFunc Func _ProcessGetMemoryUsage($sProcess = @AutoItPID) Local Const $PROCESS_QUERY_INFORMATION = 0x400 Local Const $PROCESS_VM_READ = 0x10 ;get process ID $nPID = ProcessExists($sProcess) If $nPID = 0 Then Return -1 ;get process handle, required for GetProcessMemoryInfo $aRet = DllCall("Kernel32.dll", "int", "OpenProcess", _ "dword", $PROCESS_QUERY_INFORMATION + $PROCESS_VM_READ, "dword", False, "dword", $nPID) If @error Or ($aRet[0] = 0) Then Return -1 $hProc = $aRet[0] ;create PPROCESS_MEMORY_COUNTERS to receive data, required for GetProcessMemoryInfo $structPROCESS_MEMORY_COUNTERS = DllStructCreate("dword; dword; uint peakmemsize; uint memsize; uint; uint; uint; uint; uint; uint") $nSize = DllStructGetSize($structPROCESS_MEMORY_COUNTERS) ;call GetProcessMemoryInfo $aRet = DllCall("Psapi.dll", "int", "GetProcessMemoryInfo", _ "hwnd", $hProc, "ptr", DllStructGetPtr($structPROCESS_MEMORY_COUNTERS), "dword", $nSize) ;close process handle DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hProc) ;return memory size in kb Return DllStructGetData($structPROCESS_MEMORY_COUNTERS, "memsize") / 1024 EndFunc ;==>_ProcessGetMemoryUsage Saludos
    1 point
  5. Subz

    Excel RangeFind help

    Here is my attempt: #include <Array.au3> #include <Date.au3> #include <Excel.au3> Local $sWorkbook = "E:\Pick Schedule.xlsx" Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(4096, "Error", "Error creating the Excel application object.") Local $oWorkbook = _Excel_BookAttach($sWorkbook) If @error Then $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then MsgBox(4096, "Error", "Error opening workbook '" & $sWorkbook & "'.") _Excel_Close($oExcel) Exit EndIf EndIf Local $aWorkbook = _Excel_RangeRead($oWorkbook, Default, Default, 2, True) Local $aPicks[0][4], $sLastDate, $sField, $sDateTime, $aDatePart, $sDatePart, $aTimePart, $sTimePart For $i = 0 To UBound($aWorkbook) - 1 If $i >= 2 Then ;~ Set the date in column 0 for each row If StringStripWS($aWorkbook[$i][0], 8) <> "" Then $sLastDate = $aWorkbook[$i][0] Else $aWorkbook[$i][0] = $sLastDate EndIf EndIf For $j = 2 To UBound($aWorkbook, 2) - 1 ;~ Set the Field in row 0 for each column If $i = 0 Then If StringStripWS($aWorkbook[$i][$j], 8) <> "" Then $sField = $aWorkbook[$i][$j] Else $aWorkbook[$i][$j] = $sField EndIf ContinueLoop EndIf ;~ Find each cell with the word "Pick" If StringStripWS($aWorkbook[$i][$j], 8) = "Pick" Then ;~ Convert the Excel Date/Time to proper format ;~ nb: Needed to change the _ConvertSerialDateTime written by Water time format was incorrect $sDateTime = _ConvertSerialDateTime($aWorkbook[$i][0] + $aWorkbook[$i][1]) ;~ Split the Date/Time _DateTimeSplit($sDateTime, $aDatePart, $aTimePart) $sDatePart = $aDatePart[3] & "/" & $aDatePart[2] & "/" & $aDatePart[1] $sTimePart = _12HourFormat($aTimePart[1], $aTimePart[2]) _ArrayAdd($aPicks, $sDatePart & "|" & $sTimePart & "|" & $aWorkbook[0][$j] & "|" & $aWorkbook[1][$j]) $aWorkbook[$i][2] = $sDateTime EndIf Next Next _ArrayDisplay($aPicks) Func _ConvertSerialDateTime($nDT) Local Const $dtExcel = '1899/12/31 00:00:00' Local $iDate = Int($nDT) Local $iTime = Mod($nDT, 1) - 1 $iTime = Int(24 * 3600 * $iTime) $dtRes = _DateAdd('D', $iDate, $dtExcel) $dtRes = _DateAdd('s', $iTime, $dtRes) Return $dtRes EndFunc Func _12HourFormat($_iHour = "", $_iMin = "00") If $_iHour = "" Or IsInt($_iHour) = False Then Return Select Case $_iHour <= 11 Return StringFormat("%d:%02d AM", $_iHour, $_iMin) Case Else Return StringFormat("%d:%02d PM", $_iHour, $_iMin) EndSelect EndFunc
    1 point
  6. I'm mainly using two scripting languages: AutoIt and Perl. Today I'm mostly using AutoIt. In the past mostly Perl. I've long had an idea of integrating AutoIt and Perl to be able to generate and collect data in Perl scripts and display data in AutoIt GUIs. Over the past few months, I've been working on examples about ROT objects and their use in IPC techniques. I've tested the ideas with regard to AutoIt/Perl integration. It seems to work. Install PerlTo use the Perl programming language on a Windows PC, the program must be installed. I'm using ActivePerl from ActiveState. An alternative distribution is Strawberry Perl. ActivePerl seems to be the easiest to use. Strawberry Perl is more advanced and includes a complete C/C++ compiler. The interesting Perl module for AutoIt/Perl integration is the Win32::OLE module. It's the module that makes Perl a COM compatible programming language. Remember to add this module to your Perl installation. PerlScript Be careful not to confuse Perl with PerlScript. PerlScript is a Perl module developed by ActiveState and is only a small part of the ActivePerl package for Windows. PerlScript is an ActiveX Scripting Engine for the Perl language to use Perl to create dynamic content on the Microsoft web server (in the same way as it can be done with VBScript and JScript). First attemptServer.au3 (Examples\0) First attempt\): #include <GUIConstantsEx.au3> #include "..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $hGui = GUICreate( "AutoIt/Perl integration", 300, 100 ) Local $sText = "Run Client.pl:" & @CRLF & _ "Open a Command Prompt in current folder." & @CRLF & _ "Key in ""Perl Client.pl"" and hit the Enter key." & @CRLF & _ "Or ""Perl Client.pl >Client.txt"" to get output in file." GUICtrlCreateLabel( $sText, 20, 20, 260, 60 ) GUISetState( @SW_SHOW, $hGui ) Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) EndFunc In the first attempt, we'll simply test whether the GetObject() function in a Perl script is at all able to recognize the ROT object (the dictionary object), and thus return something similar to a dictionary object. This is more or less the same as we did in the VBScript example in the bottom half of this post. So far, no data is stored in the ROT object. This Perl snippet copied from Win32::OLE can be used to test whether the ROT object is recognized. The code snippet prints object and class information: Win32::OLE->EnumAllObjects( sub { my $Object = shift; my $Class = Win32::OLE->QueryObjectType( $Object ); printf "Object = %s, Class = %s\n", $Object, $Class; } ); Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); Win32::OLE->EnumAllObjects( sub { my $Object = shift; my $Class = Win32::OLE->QueryObjectType( $Object ); printf "Object = %s, Class = %s\n", $Object, $Class; } ); Output: Object = Win32::OLE=HASH(0x71b5a8), Class = IDictionary It looks good. The ROT object is recognized as a kind of HASH object (sometimes called associative array, dictionary or map) of class IDictionary. This corresponds to the fact that the ROT object is actually a dictionary object. Data from AutoIt to PerlSimple dataNow we can store simple data in the ROT object this way. Server.au3 (Examples\1) AutoIt to Perl\1) Simple data\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object $oDataTransfer( "$iInt" ) = 123 $oDataTransfer( "$fFlt" ) = 123.456 $oDataTransfer( "$sStr" ) = "String" Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "$oObj->{'$iInt'}\n"; print "$oObj->{'$fFlt'}\n"; print "$oObj->{'$sStr'}\n"; Output: 123 123.456 String 1D arrayServer.au3 (Examples\1) AutoIt to Perl\2) 1D array\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = [ 123, 123.456, "String" ] $oDataTransfer( "$aArray" ) = $aArray Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "@{$oObj->{'$aArray'}}\n"; Output: 123 123.456 String Note that internal data types of array elements are preserved. 2D arrayServer.au3 (Examples\1) AutoIt to Perl\2) 2D array\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next $oDataTransfer( "$aArray" ) = $aArray Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); foreach my $aRow ( @{$oObj->{'$aArray'}} ) { print "@{$aRow}\n"; } Output: 0/0 1/0 2/0 3/0 4/0 5/0 6/0 7/0 8/0 9/0 10/0 11/0 12/0 13/0 14/0 15/0 ... 0/1 1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 9/1 10/1 11/1 12/1 13/1 14/1 15/1 ... 0/2 1/2 2/2 3/2 4/2 5/2 6/2 7/2 8/2 9/2 10/2 11/2 12/2 13/2 14/2 15/2 ... 0/3 1/3 2/3 3/3 4/3 5/3 6/3 7/3 8/3 9/3 10/3 11/3 12/3 13/3 14/3 15/3 ... 0/4 1/4 2/4 3/4 4/4 5/4 6/4 7/4 8/4 9/4 10/4 11/4 12/4 13/4 14/4 15/4 ... 0/5 1/5 2/5 3/5 4/5 5/5 6/5 7/5 8/5 9/5 10/5 11/5 12/5 13/5 14/5 15/5 ... 0/6 1/6 2/6 3/6 4/6 5/6 6/6 7/6 8/6 9/6 10/6 11/6 12/6 13/6 14/6 15/6 ... 0/7 1/7 2/7 3/7 4/7 5/7 6/7 7/7 8/7 9/7 10/7 11/7 12/7 13/7 14/7 15/7 ... 0/8 1/8 2/8 3/8 4/8 5/8 6/8 7/8 8/8 9/8 10/8 11/8 12/8 13/8 14/8 15/8 ... 0/9 1/9 2/9 3/9 4/9 5/9 6/9 7/9 8/9 9/9 10/9 11/9 12/9 13/9 14/9 15/9 ... Rows and columns are swapped in the Perl array. Dict objServer.au3 (Examples\1) AutoIt to Perl\4) Dict obj\): Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $oDict = ObjCreate( "Scripting.Dictionary" ) $oDict( "$iInt" ) = 123 $oDict( "$fFlt" ) = 123.456 $oDict( "$sStr" ) = "String" $oDataTransfer( "$oDict" ) = $oDict Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); print "${$oObj->{'$oDict'}}{'$iInt'}\n"; print "${$oObj->{'$oDict'}}{'$fFlt'}\n"; print "${$oObj->{'$oDict'}}{'$sStr'}\n"; Output: 123 123.456 String Data from Perl to AutoItSimple dataServer.au3 (Examples\2) Perl to AutoIt\1) Simple data\): #include "..\..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object MsgBox( 0, "AutoIt/Perl integration", "$oDataTransfer( ""$iInt"" ) = " & $oDataTransfer( "$iInt" ) & @CRLF & _ "$oDataTransfer( ""$fFlt"" ) = " & $oDataTransfer( "$fFlt" ) & @CRLF & _ "$oDataTransfer( ""$sStr"" ) = " & $oDataTransfer( "$sStr" ) ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); $oObj->{'$iInt'} = 123; $oObj->{'$fFlt'} = 123.456; $oObj->{'$sStr'} = "String"; Output: $oDataTransfer( "$iInt" ) = 123 $oDataTransfer( "$fFlt" ) = 123.456 $oDataTransfer( "$sStr" ) = String 1D arrayServer.au3 (Examples\2) Perl to AutoIt\2) 1D array\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = $oDataTransfer( "$aArray" ) _ArrayDisplay( $aArray ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my @aArray = ( 123, 123.456, "String" ); $oObj->{'$aArray'} = \@aArray; Output: 123 123.456 String 2D arrayServer.au3 (Examples\2) Perl to AutoIt\3) 2D array\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aArray = $oDataTransfer( "$aArray" ) _ArrayDisplay( $aArray ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my @aArray; for( my $i = 0; $i < 10; $i++ ) { for( my $j = 0; $j < 1000; $j++ ) { $aArray[$i][$j] = $j . "/" . $i; } } $oObj->{'$aArray'} = \@aArray; Output: 0/0 0/1 0/2 0/3 0/4 0/5 0/6 0/7 0/8 0/9 1/0 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 2/0 2/1 2/2 2/3 2/4 2/5 2/6 2/7 2/8 2/9 3/0 3/1 3/2 3/3 3/4 3/5 3/6 3/7 3/8 3/9 4/0 4/1 4/2 4/3 4/4 4/5 4/6 4/7 4/8 4/9 5/0 5/1 5/2 5/3 5/4 5/5 5/6 5/7 5/8 5/9 6/0 6/1 6/2 6/3 6/4 6/5 6/6 6/7 6/8 6/9 7/0 7/1 7/2 7/3 7/4 7/5 7/6 7/7 7/8 7/9 8/0 8/1 8/2 8/3 8/4 8/5 8/6 8/7 8/8 8/9 9/0 9/1 9/2 9/3 9/4 9/5 9/6 9/7 9/8 9/9 10/0 10/1 10/2 10/3 10/4 10/5 10/6 10/7 10/8 10/9 11/0 11/1 11/2 11/3 11/4 11/5 11/6 11/7 11/8 11/9 12/0 12/1 12/2 12/3 12/4 12/5 12/6 12/7 12/8 12/9 13/0 13/1 13/2 13/3 13/4 13/5 13/6 13/7 13/8 13/9 14/0 14/1 14/2 14/3 14/4 14/5 14/6 14/7 14/8 14/9 15/0 15/1 15/2 15/3 15/4 15/5 15/6 15/7 15/8 15/9 ... Dict objServer.au3 (Examples\2) Perl to AutoIt\4) Dict obj\): #include "..\..\..\Includes\IRunningObjectTable.au3" #include <Array.au3> Example() Func Example() Local $sDataTransfer = "DataTransfer" ROT_RegisterObject( Default, $sDataTransfer ) ; Default => Object = Dictionary object RunWait( @ComSpec & " /c " & "Perl Client.pl", "", @SW_HIDE ) Local $oDataTransfer = ObjGet( $sDataTransfer ) ; Dictionary object Local $aDict = $oDataTransfer( "$aDict" ) _ArrayDisplay( $aDict ) EndFunc Client.pl: use strict; use Win32::OLE; my $oObj = Win32::OLE->GetObject( "DataTransfer" ); my %oDict = ( '$iInt' => 123, '$fFlt' => 123.456, '$sStr' => "String" ); my @aDict = ( [ keys %oDict ], [ values %oDict ] ); $oObj->{'$aDict'} = \@aDict; Output: $iInt 123 $fFlt 123.456 $sStr String 7z-fileThe 7z-file contains source code for the UDF and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. AutoItAndPerl.7z
    1 point
  7. Looking at the control displaying the text--it is a Static control, so the behavior makes sense since it appears to be a default style. Static controls support a style called SS_NOPREFIX which, "...Prevents interpretation of any ampersand (&) characters in the control's text as accelerator prefix characters" which can be used to address this behavior. Here's a demo on one way to apply the NOPREFIX style to the Static control inside the SplashTextOn window: #include <WinAPI.au3> #include <Constants.au3> #include <StaticConstants.au3> $hWnd = SplashTextOn("Splash Screen","B&efore NOPREFIX Style") sleep(5 * 1000) $hWndStatic = ControlGetHandle($hWnd,"","Static1") $iStyle = _WinAPI_GetWindowLong($hWndStatic,$GWL_STYLE) $iNewStyle = BitOR($iStyle, $SS_NOPREFIX) _WinAPI_SetWindowLong($hWndStatic, $GWL_STYLE, $iNewStyle) _WinAPI_SetWindowText ($hWndStatic, "A&fter NOPREFIX Style") sleep(5 * 1000) Either way, it's going to take extra work to make it behave the way you want/need it to.
    1 point
  8. Why not _WinAPI_GetProcessFileName ? (coming with #include <WinAPIProc.au3>)
    1 point
×
×
  • Create New...