Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/02/2023 in all areas

  1. OJBakker

    AutoIt Snippets

    This is my Showmacros.au3 script. It is one of the first scripts I have made with AutoIt , but I have enhanced it a few times. It uses an array with all the macro names in the same order as the helpfile and reports all macro's with their values (if available) with arraydisplay. If you don't like this order, just rearrange the array and be happy! #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <Array.au3> AutoItSetOption("MustDeclareVars", 1) Local $asMacroNames = [ _ "@AppDataCommonDir", "@AppDataDir", "@AutoItExe", "@AutoItPID", "@AutoItVersion", "@AutoItX64", "@COM_EventObj", "@CommonFilesDir", _ "@Compiled", "@ComputerName", "@ComSpec", "@CPUArch", "@CR", "@CRLF", "@DesktopCommonDir", "@DesktopDepth", "@DesktopDir", "@DesktopHeight", _ "@DesktopRefresh", "@DesktopWidth", "@DocumentsCommonDir", "@error", "@exitCode", "@exitMethod", "@extended", _ "@FavoritesCommonDir", "@FavoritesDir", "@GUI_CtrlHandle", "@GUI_CtrlId", "@GUI_DragFile", "@GUI_DragId", "@GUI_DropId", "@GUI_WinHandle", _ "@HomeDrive", "@HomePath", "@HomeShare", "@HotKeyPressed", "@HOUR", "@IPAddress1", "@IPAddress2", "@IPAddress3", "@IPAddress4", "@KBLayout", "@LF", _ "@LocalAppDataDir", "@LogonDNSDomain", "@LogonDomain", "@LogonServer", "@MDAY", "@MIN", "@MON", "@MSEC", "@MUILang", "@MyDocumentsDir", _ "@NumParams", "@OSArch", "@OSBuild", "@OSLang", "@OSServicePack", "@OSType", "@OSVersion", "@ProgramFilesDir", "@ProgramsCommonDir", "@ProgramsDir", _ "@ScriptDir", "@ScriptFullPath", "@ScriptLineNumber", "@ScriptName", "@SEC", "@StartMenuCommonDir", "@StartMenuDir", "@StartupCommonDir", "@StartupDir", _ "@SW_DISABLE", "@SW_ENABLE", "@SW_HIDE", "@SW_LOCK", "@SW_MAXIMIZE", "@SW_MINIMIZE", "@SW_RESTORE", "@SW_SHOW", "@SW_SHOWDEFAULT", "@SW_SHOWMAXIMIZED", _ "@SW_SHOWMINIMIZED", "@SW_SHOWMINNOACTIVE", "@SW_SHOWNA", "@SW_SHOWNOACTIVATE", "@SW_SHOWNORMAL", "@SW_UNLOCK", "@SystemDir", "@TAB", "@TempDir", "@TRAY_ID", _ "@TrayIconFlashing", "@TrayIconVisible", "@UserName", "@UserProfileDir", "@WDAY", "@WindowsDir", "@WorkingDir", "@YDAY", "@YEAR", "@NoMacro"] ; above are the macro's from autoit v3.3.16.1 These can also be found in file au3check.dat but than a compiled script (exe) would need to know where to find this file. Local $sMacroValue Local $aMacroArray[UBound($asMacroNames)][4] For $k = 0 To UBound($asMacroNames) - 1 $aMacroArray[$k][0] = $asMacroNames[$k] $aMacroArray[$k][1] = "" $aMacroArray[$k][2] = Execute($asMacroNames[$k]) If @error Then $aMacroArray[$k][1] = "N/A" $aMacroArray[$k][3] = "" $sMacroValue = " " Switch $asMacroNames[$k] Case "@COM_EventObj" $sMacroValue &= "Only valid in a COM even function" Case "@GUI_CtrlId", "@GUI_CtrlHandle", "@GUI_WinHandle" $sMacroValue &= "Only valid in an event function" Case "@GUI_DragFile", "@GUI_DragId", "@GUI_DropId" $sMacroValue &= "Only valid in a drop event function" Case "@exitCode", "@exitMethod" $sMacroValue &= "Only valid in a function in OnAutoItExitRegister" Case "@TRAY_ID" $sMacroValue &= "Only valid in Tray event function" Case Else $sMacroValue &= "Not a valid macro" EndSwitch $aMacroArray[$k][2] = $sMacroValue Else ; hex/dec view for non-visual macro's $aMacroArray[$k][3] = VarGetType($aMacroArray[$k][2]) Switch $asMacroNames[$k] Case "@CR", "@CRLF", "@LF", "@TAB" $aMacroArray[$k][2] = "Hex: " & StringToBinary($aMacroArray[$k][2]) & " Dec: " & _ArrayToString(StringToASCIIArray($aMacroArray[$k][2]), " ") Case "@HOUR", "@MDAY", "@MIN", "@MON", "@MSEC", "@SEC", "@WDAY", "@YDAY", "@YEAR" $aMacroArray[$k][2] = " now: " & $aMacroArray[$k][2] ; group these in view sort on macrovalue EndSwitch EndIf Next _ArrayDisplay($aMacroArray, "AutoIt Macro's Overview. Type = VarGetType(Execute('@Macro'))", Default, $ARRAYDISPLAY_COLALIGNLEFT + $ARRAYDISPLAY_NOROW, Default, "Macro Name|Avail.|Macro Value|Type") ShowMacros.au3
    4 points
  2. In this Thread, I'll be posting all my Autoit Syntax Guide/Tutorial with a visual Presentation. Please feel free to ask, comment, tip, and correct me. Anything is for beginners to learn as we walk through the path toward expertise. I also Promote my Channel hope you could subscribe, that would be a really big help for me. Hope These Videos are helpful in any way. Ps I'll be providing an autoit script soon with each video tutorial about the virtual animation Autoit Virtual Animation Tutorial Virtual Animation Guide Part 2 Starting Up Virtual Animation Part 1 Syntax Helper Latest While Reference Function Reference UBound Reference Redim, Static, Array and Enum Variable Declaration(Global, Local, Dim, Constant)
    3 points
  3. mLipok

    AutoIt Snippets

    I very offen wonders which values gives particular macro. For example: do I should use @AppDataDir or @LocalAppDataDir or @UserProfileDir Here is my Show_Macro_Values.au3script: ConsoleWrite('@AppDataCommonDir : ' & @AppDataCommonDir & @CRLF) ConsoleWrite('@AppDataDir : ' & @AppDataDir & @CRLF) ConsoleWrite('@AutoItExe : ' & @AutoItExe & @CRLF) ConsoleWrite('@AutoItPID : ' & @AutoItPID & @CRLF) ConsoleWrite('@AutoItVersion : ' & @AutoItVersion & @CRLF) ConsoleWrite('@AutoItX64 : ' & @AutoItX64 & @CRLF) ConsoleWrite('@CommonFilesDir : ' & @CommonFilesDir & @CRLF) ConsoleWrite('@Compiled : ' & @Compiled & @CRLF) ConsoleWrite('@ComputerName : ' & @ComputerName & @CRLF) ConsoleWrite('@ComSpec : ' & @ComSpec & @CRLF) ConsoleWrite('@CPUArch : ' & @CPUArch & @CRLF) ConsoleWrite('@DesktopCommonDir : ' & @DesktopCommonDir & @CRLF) ConsoleWrite('@DesktopDepth : ' & @DesktopDepth & @CRLF) ConsoleWrite('@DesktopDir : ' & @DesktopDir & @CRLF) ConsoleWrite('@DesktopHeight : ' & @DesktopHeight & @CRLF) ConsoleWrite('@DesktopRefresh : ' & @DesktopRefresh & @CRLF) ConsoleWrite('@DesktopWidth : ' & @DesktopWidth & @CRLF) ConsoleWrite('@DocumentsCommonDir : ' & @DocumentsCommonDir & @CRLF) ConsoleWrite('@FavoritesCommonDir : ' & @FavoritesCommonDir & @CRLF) ConsoleWrite('@FavoritesDir : ' & @FavoritesDir & @CRLF) ConsoleWrite('@HomeDrive : ' & @HomeDrive & @CRLF) ConsoleWrite('@HomePath : ' & @HomePath & @CRLF) ConsoleWrite('@HomeDrive : ' & @HomeDrive & @CRLF) ConsoleWrite('@HomeShare : ' & @HomeShare & @CRLF) ConsoleWrite('@LocalAppDataDir : ' & @LocalAppDataDir & @CRLF) ConsoleWrite('@LogonDNSDomain : ' & @LogonDNSDomain & @CRLF) ConsoleWrite('@LogonDomain : ' & @LogonDomain & @CRLF) ConsoleWrite('@LogonServer : ' & @LogonServer & @CRLF) ConsoleWrite('@MyDocumentsDir : ' & @MyDocumentsDir & @CRLF) ConsoleWrite('@OSArch : ' & @OSArch & @CRLF) ConsoleWrite('@OSBuild : ' & @OSBuild & @CRLF) ConsoleWrite('@OSLang : ' & @OSLang & @CRLF) ConsoleWrite('@OSServicePack : ' & @OSServicePack & @CRLF) ConsoleWrite('@OSType : ' & @OSType & @CRLF) ConsoleWrite('@OSVersion : ' & @OSVersion & @CRLF) ConsoleWrite('@ProgramFilesDir : ' & @ProgramFilesDir & @CRLF) ConsoleWrite('@ProgramsCommonDir : ' & @ProgramsCommonDir & @CRLF) ConsoleWrite('@ProgramsDir : ' & @ProgramsDir & @CRLF) ConsoleWrite('@ScriptFullPath : ' & @ScriptFullPath & @CRLF) ConsoleWrite('@ScriptDir : ' & @ScriptDir & @CRLF) ConsoleWrite('@ScriptName : ' & @ScriptName & @CRLF) ConsoleWrite('@ScriptLineNumber : ' & @ScriptLineNumber & @CRLF) ConsoleWrite('@StartMenuCommonDir : ' & @StartMenuCommonDir & @CRLF) ConsoleWrite('@StartMenuDir : ' & @StartMenuDir & @CRLF) ConsoleWrite('@StartupCommonDir : ' & @StartupCommonDir & @CRLF) ConsoleWrite('@StartupDir : ' & @StartupDir & @CRLF) ConsoleWrite('@SystemDir : ' & @SystemDir & @CRLF) ConsoleWrite('@TempDir : ' & @TempDir & @CRLF) ConsoleWrite('@UserName : ' & @UserName & @CRLF) ConsoleWrite('@UserProfileDir : ' & @UserProfileDir & @CRLF) ConsoleWrite('@WindowsDir : ' & @WindowsDir & @CRLF)
    2 points
  4. jguinch

    Printers Management UDF

    Hello. I did create these few functions several months ago. I post here, if it can interest someone. These functions based on WMI queries allow you to manage printers : add / delete printer, driver, port, or obtain configuration, set default printer ... I let you discover it with the code. Here is the list of the available functions : _PrintMgr_AddLocalPort _PrintMgr_AddLPRPort _PrintMgr_AddPrinter _PrintMgr_AddPrinterDriver _PrintMgr_AddTCPIPPrinterPort _PrintMgr_AddWindowsPrinterConnection _PrintMgr_CancelAllJobs _PrintMgr_CancelPrintJob _PrintMgr_EnumPorts _PrintMgr_EnumPrinter _PrintMgr_EnumPrinterConfiguration _PrintMgr_EnumPrinterDriver _PrintMgr_EnumPrinterProperties _PrintMgr_EnumPrintJobs _PrintMgr_EnumTCPIPPrinterPort _PrintMgr_Pause _PrintMgr_PortExists _PrintMgr_PrinterExists _PrintMgr_PrinterSetComment _PrintMgr_PrinterSetDriver _PrintMgr_PrinterSetPort _PrintMgr_PrinterShare _PrintMgr_PrintTestPage _PrintMgr_RemoveLocalPort _PrintMgr_RemoveLPRPort _PrintMgr_RemovePrinter _PrintMgr_RemovePrinterDriver _PrintMgr_RemoveTCPIPPrinterPort _PrintMgr_RenamePrinter _PrintMgr_Resume _PrintMgr_SetDefaultPrinter And some examples : #include <Array.au3> #include "PrintMgr.au3" _Example() Func _Example() ; Remove a printer called "My old Lexmark printer" : _PrintMgr_RemovePrinter("My old Lexmark printer") ; Remove the driver called "Lexmark T640" : _PrintMgr_RemovePrinterDriver("Lexmark T640") ; Remove the TCP/IP printer port called "TCP/IP" _PrintMgr_RemoveTCPIPPrinterPort("MyOLDPrinterPort") ; Add a driver, called "Samsung ML-451x 501x Series", and driver inf file is ".\Samsung5010\sse2m.inf" _PrintMgr_AddPrinterDriver("Samsung ML-451x 501x Series", "Windows NT x86", @ScriptDir & "\Samsung5010", @ScriptDir & "\Samsung5010\sse2m.inf") ; Add a TCP/IP printer port, called "MyTCPIPPrinterPort", with IPAddress = 192.168.1.10 and Port = 9100 _PrintMgr_AddTCPIPPrinterPort("MyTCPIPPrinterPort", "192.168.1.10", 9100) ; Add a printer, give it the name "My Printer", use the driver called "Samsung ML-451x 501x Series" and the port called "MyTCPIPPrinterPort" _PrintMgr_AddPrinter("My Printer", "Samsung ML-451x 501x Series", "MyTCPIPPrinterPort") ; Set the printer called "My Printer" as default printer _PrintMgr_SetDefaultPrinter("My Printer") ; Connect to the shared printer "\\192.168.1.1\HPDeskjetColor") _PrintMgr_AddWindowsPrinterConnection("\\192.168.1.1\HPDeskjetColor") ; List all installed printers Local $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) ; List all printers configuration Local $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration() _ArrayDisplay($aPrinterConfig) ; List all installed printer drivers Local $aDriverList = _PrintMgr_EnumPrinterDriver() _ArrayDisplay($aDriverList) ; Retrieve the printer configuration for the printer called "Lexmark T640" $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration("Lexmark T640") _ArrayDisplay($aPrinterConfig) ; Add a local printer port (for a file output) _PrintMgr_AddLocalPort("c:\temp\output.pcl") ; Remove the local port _PrintMgr_RemoveLocalPort("c:\temp\output.pcl") ; Enum a print job Local $aJobList = _PrintMgr_EnumPrintJobs() _ArrayDisplay($aJobList) EndFunc ;==>_Example Download link : PrintMgr_Example.au3 PrintMgr.au3
    1 point
  5. .NET Common Language Runtime (CLR) Framework was published five months ago. CLR.au3 which is the main UDF makes it possible to execute .NET code directly in an AutoIt script. .NET code in this context should be perceived in a very broad sense. As shown in the examples, there are virtually no limits to the possibilities that the UDF opens up for. .NET Common Language Runtime (CLR) Framework is the result of the work in Using .NET libary with AutoIt, possible? CLR.au3 is implemented in this thread. Most of the code in CLR.au3 is a translation of CLR.ahk from .NET Framework Interop (CLR, C#, VB) in the AutoHotkey forum. DotNet.au3 is a complete translation of CLR.ahk. This example is about DotNet.au3. It contains information about the functions in the UDF. Usage of the functions is demonstrated through small examples. And there is a description of a few .NET Framework concepts. The AutoHotkey project The AutoHotkey project started in .NET Framework Interop in autumn 2009. The latest update of CLR.ahk in .NET Framework Interop (CLR, C#, VB) was november 2011. The whole project seems to have been developed over this 3-year period. The project was developed by Lexikos in the AutoHotkey forum. He certainly looks very knowledgeable about the code in the .Net Framework and he has done a great job in implementing the AutoHotkey code in CLR.ahk. Lots of credit to Lexikos. If you want to test the AutoHotkey code, you can find a recipe here. DotNet.au3 Because a lot of COM support is included internally in AutoHotkey and especially because AutoHotkey natively supports safearrays, the code in CLR.ahk is short and compact. 150 code lines. In the zip-file below AutoIt safearray support is implemented in two separate UDFs: SafeArray.au3 and AccVarsUtilities.au3. Both of these UDFs were started in Accessing AutoIt Variables. That way, it has also been possible to keep the code in DotNet.au3 short and compact. 190 code lines. You should take a look at DotNet.au3. It's nice and easily readable code (maybe not so easy to understand, but easy to read). 7 functions DotNet.au3 contains 7 functions and 2 internal functions. The first 3 functions DotNet_Start(), DotNet_StartDomain() and DotNet_StopDomain() are only used to optimize the .NET Framework host (more about .NET concepts below). If you are satisfied with the default .NET Framework host, you can completely skip these functions. The next 3 functions DotNet_LoadAssembly(), DotNet_LoadCScode() and DotNet_LoadVBcode() are used to load .NET code into a domain. Before it's possible to execute .NET code it must be loaded into a domain. If DotNet_Start() and DotNet_StartDomain() have not been called, DotNet_Start() is called automatically by the 3 functions and the default domain is used to execute .NET code. DotNet_LoadAssembly() loads .NET code in a .NET assembly DLL-file into a domain. The other functions compiles C# and VB source code on the fly, creates a .NET assembly DLL-file in memory and loads the assembly file into a domain. All 3 functions returns a .NET code object which is a reference to the .NET code. The last function DotNet_CreateObject() takes a .NET code object and a class name as input parameters and creates an object as an instance of the class. The class must be defined in the .NET code. Because .NET code is object-oriented code, everything is performed through objects. Now the methods of the object can be called and this executes the functions in the .NET code. Below is a brief description of the 7 functions. $oRuntimeHost = DotNet_Start( $sVersion = "" ) DotNet_Start() Loads the .NET Framework code-execution environment known as the CLR into the AutoIt process and returns a .NET runtime host (a .NET Framework host). Default is to use the latest version of .NET Framework installed on the PC. Specify $sVersion eg. "v2.0.50727" to use an older version of .NET Framework. DotNet_Start() is automatically called by the other functions in DotNet.au3. You only need to call DotNet_Start() if you want to use an older version of .NET Framework. @error = 1 indicates that DotNet_Start() has failed. DotNet_StartDomain( ByRef $oAppDomain, $sFriendlyName = "", $sBaseDirectory = "" ) Creates and starts a user domain to run .NET code. Several user domains can be created and started at the same time. $oAppDomain is the returned domain object. $sFriendlyName is a name to identify the domain. $sBaseDirectory is the base directory where from .NET assemblies are loaded into the domain. The only purpose of $sFriendlyName is to be able to recognize the domain when the domains are listed with DotNet_ListDomains(). DotNet_ListDomains() is a utility function implemented in DotNetUtils.au3. The purpose of $sBaseDirectory is to be able to specify the directory where .NET assemblies are stored. The usage of $sBaseDirectory is demonstrated in examples. A default domain is automatically created by the other functions in DotNet.au3. You only need to call DotNet_StartDomain() if you want to specify a base directory for the domain. DotNet_StopDomain( ByRef $oAppDomain ) Unloads .NET assemblies loaded into the user domain and stops the domain. $oAppDomain is the domain object. The default domain cannot be stopped. $oNetCode = DotNet_LoadAssembly( $sAssemblyName, $oAppDomain = 0 ) DotNet_LoadAssembly() loads .NET code in a .NET assembly DLL-file into a domain and returns a .NET code object (a reference to the .NET code). $sAssemblyName is the name of the assembly DLL-file. $oAppDomain is the user domain. If no user domain is specified the assembly is loaded into the default domain. @error = 2 indicates that DotNet_LoadAssembly() has failed. $oNetCode = DotNet_LoadCScode( $sCode, $sReferences = "", $oAppDomain = 0, $sFileName = "", $sCompilerOptions = "" ) $oNetCode = DotNet_LoadVBcode( $sCode, $sReferences = "", $oAppDomain = 0, $sFileName = "", $sCompilerOptions = "" ) DotNet_LoadCScode() and DotNet_LoadVBcode() compiles C# and VB source code on the fly, creates a .NET assembly DLL-file in memory, loads the assembly file into a domain and returns a .NET code object. $sCode is the C# or VB source code. $sReferences is a pipe (|) delimited list of .NET DLL assemblies that the C#/VB code requires. Eg. "System.dll" or "System.Windows.Forms.dll". $oAppDomain is the user domain. If no user domain is specified the code is loaded into the default domain. The other parameters are related to the compilation process. If $sFileName is the name of a DLL-file the code is compiled into a .NET assembly DLL-file. Else the code is compiled in memory. $sCompilerOptions is rarely used. See Microsoft documentation for details. @error = 3/4 indicates that DotNet_LoadCScode() or DotNet_LoadVBcode() has failed. @error = 5 indicates a syntax error in the C# or VB source code. Such an error can be corrected by correcting the error in the source code. $oObject = DotNet_CreateObject( ByRef $oNetCode, $sClassName, $v3 = Default, ..., $v9 = Default ) DotNet_CreateObject() creates an object as an instance of a class. $oNetCode is a .NET code object as returned by one of the functions DotNet_LoadAssembly(), DotNet_LoadCScode() or DotNet_LoadVBcode(). $sClassName is the name of a class defined in the .NET code. The other parameters depends on the specific class. Summary Two functions must be called to execute .NET code directly in an AutoIt script. One of the functions DotNet_LoadAssembly(), DotNet_LoadCScode() or DotNet_LoadVBcode() to load the .NET code into a domain. And DotNet_CreateObject() to create an object from a class defined in the .NET code. Now the functions in the .NET code can be executed by calling the methods of the object. .NET concepts The .NET CLR In more or less the same way as AutoIt3.exe or AutoIt3_x64.exe is needed to run AutoIt code, the .NET CLR (Common Language Runtime) or the .NET Framework code-execution environment is needed to run .NET code. To be able to run .NET code inside an AutoIt script, the CLR or the .NET Framework code-execution environment must be loaded into the AutoIt process. This is the purpose of DotNet_Start(). The CLR can be loaded into a process through several of the functions in MSCorEE.dll. CorBindToRuntimeEx is one of these functions. DotNet_Start() executes CorBindToRuntimeEx in MSCorEE.dll and loads the CLR into the AutoIt process. A program or a part of a program which is able to start the CLR and execute .NET code is referred to as a .NET runtime host, a CLR host or simply a .NET Framework host. The code in DotNet.au3 implements an AutoIt .NET Framework host. Managed/unmanaged code .NET code which is executed (or managed) through the functions in the CLR is referred to as managed code. C# and VB code is managed code. Code which is not executed through the functions in the CLR is referred to as unmanaged code. AutoIt code is unmanaged code. You usually only distinguish between managed/unmanaged code in relation to .NET code and the .NET Framework. When you are executing .NET code there is often a part of both unmanaged and managed code involved. If you are executing .NET code through AutoIt, the AutoIt code is the unmanaged code and the .NET code is the managed code. The functions in MSCorEE.dll are some of the functions which belongs to the .NET Framework that can be executed from unmanaged code eg. AutoIt code. That's the reason why these functions are used to start the .NET Framework. The COM interfaces _AppDomain, _Assembly and _Type in Interfaces.au3 are some of the interfaces which belongs to the .NET Framework that can be used in unmanaged code. That's the reason why these interfaces are used to implement the functions in DotNet.au3. Managed code like C# cannot be translated into unmanaged code like AutoIt. There is no way to translate a command like "using System;" from C# to AutoIt. In many situations you can implement the same code in AutoIt as you can in C#. But that's generally not a simple translation of the C# code. It's a new implementation of the code. .NET domains With the functions in DotNet.au3 you can create an AutoIt .NET Framework host as shown in this picture: The blue box illustrates the unmanaged AutoIt code which is used to start the .NET Framework and load the CLR into the AutoIt process. The red box illustrates the default domain and several user domains where the managed .NET code is executed. Managed .NET code is always executed within a domain. The purpose of DotNet_StartDomain() and DotNet_StopDomain() is to create, start and stop user domains. If DotNet_StartDomain() isn't called the default domain is used. A domain in managed code is equivalent to a process in unmanaged code. The purpose of domains is to prevent that a crash in one part of the .NET code should lead to a crash in all of the .NET code. A crash of the code in a domain makes the domain inapplicable and a new domain must be created with DotNet_StartDomain(). This is very similar to the way that code is executed in separate processes in the operating system. The purpose of executing code in separate processes is (among other things) to prevent that a crash of the code in one process should lead to a crash of the code in several processes and finally to a crash of the entire operating system. A crash of the code in the default domain makes the entire CLR, that's loaded into the AutoIt process inapplicable. Because it's only possible to load the CLR into the same process once, the only way to reload the CLR is to restart the entire AutoIt process. That is to stop and start the AutoIt script. Usually it does not matter if the default domain or a user domain is used to execute .NET code. It's only strictly necessary to create a user domain if there is a need to specify a base directory for .NET assemblies. The only way to specify a base directory is through DotNet_StartDomain(). .NET assemblies Before it's possible to execute .NET code in a domain, the code must be loaded into the domain. Code is always loaded into a domain through a .NET assembly. This is also the case when .NET code is created on the fly by compiling C# or VB code in memory. Then the .NET code is stored in a .NET assembly which is created in memory and therefrom loaded into the domain. The purpose of DotNet_LoadAssembly() is to load .NET code in a .NET assembly DLL-file into a domain. Either the default domain or a user domain. The purpose of DotNet_LoadCScode() and DotNet_LoadVBcode() is to compile C# and VB code on the fly, create a .NET assembly in memory and load the .NET code into a domain. All 3 functions returns a .NET code object which can be used in DotNet_CreateObject() to create .NET objects. When a .NET assembly is stored as a file on disk it's usually stored with a DLL- or an EXE-extension. It contains information about classes, objects, methods, properties, events, datatypes etc. concerning the resources in the assembly. It's a binary file. A .NET assembly DLL-file should not be confused with a standard DLL-file eg. a DLL-file that belongs to the Windows operating system. A .NET assembly DLL-file contains managed code. A standard DLL-file contains unmanaged code. In the same way as there are tools to extract information about the code in a standard DLL-file, there are also tools to extract information about the code in a .NET assembly DLL-file. One of these tools is ILSpy. More about ILSpy in examples section below. .NET objects Because .NET code is object-oriented code, everything is performed through objects, properties and methods. When functions are executed in .NET code, they are executed as object methods. DotNet_CreateObject() takes a .NET code object as returned by DotNet_LoadAssembly(), DotNet_LoadCScode() or DotNet_LoadVBcode() and a class name as input parameters and creates a .NET object as an instance of the class. The class must be defined in the .NET code. Now the methods of the object can be called and this executes the functions in the .NET code. Examples The Examples folder contains scripts to demonstrate the usage of the functions in DotNet.au3. In scripts where .NET code is needed for the demonstration, the code is copied from original AutoHotkey examples: An example with a XPTable.dll .NET assembly (implemented in AutoIt in this post) and two simple C# and VB code examples. I don't want to review all examples. The examples are small examples like this: #include "..\..\Includes\DotNet.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Start the latest version of .NET Framework ; DotNet_Start() is automatically called by the other functions in DotNet.au3 ; You only have to call DotNet_Start() if you need an older version of .NET Framework DotNet_Start() If @error Then Return ConsoleWrite( "DotNet_Start ERR" & @CRLF ) ConsoleWrite( "DotNet_Start OK" & @CRLF ) EndFunc The example simply starts the .NET Framework from an AutoIt script. Run the examples in SciTE by pressing F5 on the keyboard. A few examples with "(compile me)" in the file name must be compiled. Run these examples by double-clicking the exe-file. ILSpy .NET assembly browser ILSpy is an open-source .NET assembly browser. Download ILSpy_Master_2.4.0.1963_Binaries.zip, unzip it and run ILSpy.exe. There is no installer. If you open \Examples\4) DotNet_LoadAssembly\XPTable.dll through the File | Open... menu you'll see this information in the right pane window: // ...\Examples\4) DotNet_LoadAssembly\XPTable.dll // XPTable, Version=1.1.0.27823, Culture=neutral, PublicKeyToken=24950705800d2198 // Global type: <Module> // Architecture: AnyCPU (64-bit preferred) // Runtime: .NET 1.1 using System; using System.Reflection; [assembly: AssemblyVersion("1.1.0.27823")] [assembly: CLSCompliant(true)] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCopyright("Copyright © 2005, Mathew Hall. All rights reserved.")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyDescription("A fully customisable ListView style control based on Java's JTable")] [assembly: AssemblyKeyFile("..\\..\\XPTable.snk")] [assembly: AssemblyKeyName("")] [assembly: AssemblyProduct("XPTable")] [assembly: AssemblyTitle("XPTable")] [assembly: AssemblyTrademark("")] Note the comments in the top. This line: // Architecture: AnyCPU (64-bit preferred) means that the DLL-file can be used as both a 32 and a 64 bit .NET assembly DLL-file. Using C# and VB Code in AutoIt Using C# and VB Code in AutoIt through .NET Framework is an example that uses DotNet.au3 UDF in order to be able to execute compiled C# and VB code in AutoIt scripts. Zip-file The zip-file contains two folders: Examples\ and Includes\. The project depends on eight include files of which DotNet.au3 is the actual UDF. To make it easier to use the UDF, all include files are collected in one large file: DotNetAll.au3. To use DotNet.au3 UDF in your own project just include DotNetAll.au3. You need AutoIt 3.3.10 or later. Tested on Windows 10, Windows 7 and Windows XP. Comments are welcome. Let me know if there are any issues. DotNet.7z
    1 point
  6. @HJLThe coding has already been done in _WD_UpdateDriver. You simply need to extract the relevant parts and use them in your own script. You can copy and paste, right? 😏
    1 point
  7. Hi @senatin, what I like about your videos: You spent much time to present the topic(s) in a quite interesting way which is good 👍 . On the other hand, it's sometimes a bit too much background images, animation and noices in my opinion. You try to bind the follower/the video consumer, I understand, but the most important thing, the code concepts is partially lost. 💡 My personal suggestion is to reduce the animation part just a bit, increase the code explanation a bit more and slow down the english voice also a bit. Because as non-native speaker, it's quite fast on several positions in the video(s). Thanks and keep going on the video tutorial series 👍 . Best regards Sven
    1 point
  8. Thx ahha. Using the preceding script, just a test on word wrap, space and non-break space, for fun
    1 point
  9. Now @ioa747 😂 , your post (your solution) does almost the same like my post before. The funny thing is that we come up with different approaches and different understandings what @Eazy-P was wanting and at the end we suggest almost the same way. I like that 😀 . See you later. Best regards Sven
    1 point
  10. Hi everybody It seems tricky. Have you already seen any AutoIt script where OP's need is solved with a simple control style (added or removed) after the Edit control has been created ? Even MS write this on its msdn page, topic Edit Control Styles After the control has been created, these styles cannot be modified, except as noted (...) It seems frustrating because when we open NotePad, menu Format, option Word Wrap, then we can easily check/unchech the Word wrap option and the Edit control in NotePad reacts immediately & correctly. But did you notice the following ? If you use "AutoIt Window Info Tool" to check the handle of NotePad's Edit control, before and after you checked the Word Wrap option... the handle CHANGES each time ! (we're talking here of NotePad Edit control handle, not of NotePad window handle) It means that even MS deletes the Edit Control and recreates it immediately, with the new appropriate style, when the user checks/unchecks Word Wrap in NotePad @ahha I tried the same way to solve it in the script below, it seems to work fine : #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <String.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_idEdit $g_hGUI = GUICreate("GUI Window", 920, 570, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_ACCEPTFILES) ;handle _EditRecreate(False) ;False = no word wrap (keep it False here, to match with the unchecked Menu item "Word Wrap") ;Format Menu Local $idFormatMenu = GUICtrlCreateMenu("F&ormat") ;Create the Format menu. Underline o when Alt is pressed. ;sub-menus Local $idFormatMenu_WordWrap = GUICtrlCreateMenuItem("&Word Wrap" &@TAB& "", $idFormatMenu) ;Create the "Word Wrap" menu item. Underline W when Alt is pressed. GUISetState(@SW_SHOW, $g_hGUI) ;display the GUI _GUICtrlEdit_SetSel($g_idEdit, -1, 0) ;deselects only when placed AFTER GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idFormatMenu_WordWrap _WordWrap() Case $GUI_EVENT_DROPPED _GUICtrlEdit_SetText($g_idEdit, FileRead(@GUI_DragFile)) ;read and set the data to be displayed EndSwitch WEnd ;============================= Func _WordWrap() If BitAND(GUICtrlRead($idFormatMenu_WordWrap), $GUI_CHECKED) = $GUI_CHECKED Then ;turn off Word Wrap _EditRecreate(False) ; False = no word wrap GUICtrlSetState($idFormatMenu_WordWrap, $GUI_UNCHECKED) ;uncheck Word Wrap Else ;turn on Word Wrap _EditRecreate(True) ; True = word wrap GUICtrlSetState($idFormatMenu_WordWrap, $GUI_CHECKED) ;turn on Word Wrap and show checked EndIf EndFunc ;============================= Func _EditRecreate($bWordWrap) Local $idEdit_Old = $g_idEdit ;0 at first passage If $idEdit_Old Then Local $aPos = ControlGetPos($g_hGUI, "", $idEdit_Old) Else ;1st passage Local $aPos[4] = [10, 10, 800, 455] EndIf $g_idEdit = GUICtrlCreateEdit("", $aPos[0], $aPos[1], $aPos[2], $aPos[3], ($bWordWrap _ ? BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) _ : -1)) ;control ID GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;allow drag and drop GUICtrlSetFont(-1, 10, 400, 0, "Courier New") ;change default font If $idEdit_Old Then _GUICtrlEdit_SetText($g_idEdit, GUICtrlRead($idEdit_Old)) Local $aSel = _GUICtrlEdit_GetSel($idEdit_Old) GUICtrlDelete($idEdit_Old) _GUICtrlEdit_SetSel($g_idEdit, $aSel[0], $aSel[1]) Else ;1st passage _GUICtrlEdit_SetText($g_idEdit, _StringRepeat("1234567890", 20)) EndIf EndFunc Hope it helps
    1 point
  11. this find all test*.txt (test1.txt , test2.txt etc) in folder @ScriptDir & "\kfc\ and its subfolder and replaced with @ScriptDir & "\NewTest.txt" here the initial name replaced with NewTest.txt #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <File.au3> _FindAllFile() ;---------------------------------------------------------------------------------------- Func _FindAllFile() Local $dir = @ScriptDir & "\kfc\" ; <------------ Local $ArraySrtfiles = _FileListToArrayRec($dir, "test*.txt", $FLTAR_FILES, $FLTAR_RECUR) If Not IsArray($ArraySrtfiles) Then ConsoleWrite($dir & " = Invalid input path" & @CRLF) Return Else For $x = 1 To $ArraySrtfiles[0] ;ConsoleWrite($dir & $ArraySrtfiles[$x]& @CRLF) _ReplaceTxt($dir & $ArraySrtfiles[$x]) Next EndIf EndFunc ;==>_FindAllFile ;---------------------------------------------------------------------------------------- Func _ReplaceTxt($TxtFile) Local $sName = "\NewTest.txt" Local $NewTxtFile = @ScriptDir & $sName ;ReplaceTxt FileCopy($NewTxtFile, $TxtFile, $FC_OVERWRITE + $FC_CREATEPATH) Local $sFolder = StringLeft($TxtFile, StringInStr($TxtFile, "\", $STR_NOCASESENSEBASIC, -1) -1) ;FileRename FileMove($TxtFile, $sFolder & $sName, $FC_OVERWRITE + $FC_CREATEPATH) EndFunc ;==>_ReplaceTxt
    1 point
  12. Not necessarily. Within SciTE you can open a window using SHIFT F8. There you can enter command line parameters (even several in one line). This is helpful during development. The parameters set are preserved during the SciTE session.
    1 point
  13. mistersquirrle

    delayed function

    Indeed, you'll need to show your code, as I have no issues/delays with launching a function with a hotkey: HotKeySet('\', '__Func') HotKeySet('{ESC}', '__Exit') While 1 Sleep(10) WEnd Func __Func() MsgBox(0,'Test','Test', 3) EndFunc Func __Exit() Exit EndFunc It might be possible that you have some other blocking function happening when you press the hotkey, so it's queued until it's able to actually process it.
    1 point
  14. Other big update is coming I'm still testing the code I hope that my work will make your life easier and save you time and that you will gain security and development time Update 01/12/2022 to adapt to the new version of purebasic with function additions 😇
    1 point
  15. Yeah rather than help me it's best you make me do it on my own, cheers mate good job!
    0 points
×
×
  • Create New...