Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/03/2020 in all areas

  1. "Once upon a time ..." than I've made the following: But now exist a new version of the "quricol.dll" for 32 and 64 bit. All parameters can be used now. In the old thread you can see, that is implemented with the help of @TheXman . Thanks for that. Then I revised the GUI and I came up with new possibilities. This has now resulted in a much more powerful tool, which is why I decided to create a new thread on this topic. There are 3 components:     QRCreator.au3         This is the base UDF that need for all. You can write your own applications by using it.     QRCreatorUI         This is the graphical User Interface to deal with all functions of the UDF.         As a special feature, you have a preview that can be enlarged.     QRCreatorCI         This is the Commandline Interface.          With the exception of HBITMAP generation, which is not required on the command line, you can perform all functions of the UDF to generate QR codes. Here more in detail: QRCreator.au3 - functions   _QR_generatePNG        Generates the QR-Code as PNG file for the passed text.   _QR_generateBMP        Generates the QR-Code as BMP file for the passed text.   _QR_getHBitmap        Creates a HBITMAP handle for the QR-Code for the passed text.         Don't forget to delete it, if no more need (_WinAPI_DeleteObject(HBITMAP)).   _QR_copyToClipboard        Copies the QR-Code picture for the passed text to the clipboard.   _QR_FileDefault       Generates a default filename (QR_YYYYMMDD_hhmmss)   _QR_getLastCall()      Asks for the result of the last call (_QR_getHBitmap/_QR_copyToClipboard/_QR_generateBMP/_QR_generatePNG)      Gets a structure with: .success(1/0) .error(@error) .width .type(B/C/[F/R]) .output(hBMP/''/fullpath) .margin .sizept .corrlevel      Types(.type): B (HBITMAP), C (Clipboard), F (File created), R (resized file created) The following parameters will used:   $_sText     The text to encode. Full unicode is supported.   $_sPathOut (ONLY: _QR_generatePNG und _QR_generateBMP)     The full path of the file to create. If only a filename has passed the @ScriptDir will used.     Without a filename the default filename will used (QR_YYYYMMDD_hhmmss).     If the filename exists, it will get a suffix (1..n) until it's unique.   $_iMargin       The QR-Code margin in px   $_iSizePt       Size of the points in the QR-Code (1-4, depends by the correction level)     If a wrong value is passed, it will corrected by the script.   $_iCorrLvl       The used correction level (0-3). Allows to read a QR-Code if some parts damaged.   $_iOutSize (ONLY: _QR_generatePNG und _QR_generateBMP)     As a new feature you can pass a target size for created file.      The size of the file depends by used correction level and the size of created points.      If you pass a value for width (and so for heigth too), the default by the dll created file will resized for this size.      If the passed size is to small it raises an error.   $_iScale (ONLY: _QR_copyToClipboard)     Also new is the ability to scale up the QR-Code copied to clipboard.      It's a factor for linear scaling, based on the default creation size by the dll call. QRCreatorUI.au3   All information for the actions you've done will shown in the statusbar of the GUI.    But this is my own statusbar, that allows formatting. I've attached them too. QRCreatorCI   available command line parameters   ---------------------------------------------------------------------------------------------------------------    REQUIRED NEW: Passing multi-line text via command line break=Placeholder character for a line break (default is ^) Must only be set if the default value is not to be used. For single-line text that contains the default placeholder, set "break=none"! If break is set, this must always be the first parameter!      text=Text for encoding    OPTIONAL      file=path/filename[.ext]  - If ommited, the default will used: @HomeDrive & @HomePath & "\QR_YYYYMMDD_hhmmss"      type=png,bmp,clip         - If ommited, 'png' will used. With clip runs CopyToClipboard.           or combined png/bmp    If file has .ext and type is passed but is different to .ext than will used type      width=int                 - (and height) initializes a resizing of the default created QR-Code                                  Resizing fails, if passed size is smaller as the default generated file.                                REMARK: Only for file creation      scale=int                 - Factor for up scaling the QR-Code                                REMARK: Only for CopyToClipboard      margin=4                  - The margin around the QR-Code in px (Default = 4)      corrlevel=0               - Up to 7%, 15%, 25% or 30% damage [0, 1, 2, 3]. (Default = 0)      sizept=2                  - The size of the painted pixel itself. The value depends on the correction level.                                  Only the smallest point size can be used for the largest correction level.                                  The value will corrected automatically, if wrong.   ---------------------------------------------------------------------------------------------------------------   return values   ---------------------------------------------------------------------------------------------------------------   comma separated string with:     ERROR=@error     RESULT='FullFilePath' or 'CLIPBOARD'     SIZE=width x heigth     SIZEPT=The really used (may be corrected) size of point     MARGIN=The used margin size     CORRLEVEL=The used correction level   --------------------------------------------------------------------------------------------------------------- You find all the stuff also in the function headers. So that you get an impression, here are a few pictures. Gallery QRCode.zip QRCreatorUI.au3 QRCreatorCI.au3
    5 points
  2. You could also use some sort of wrapper object that allows something like that, on top of the original one. This method would be the simplest to use. Unfortunately no one ever shared the code that would do that because writing sensible implementation requires extended knowledge of the memory management, COM Idispatch handling and whatnot. I remember one user writing it in AutoIt but it has different issues. I would do it like this (added __propget__, __propset__ and __call__ for every object): ObjectExtend.au3 #include-once ; ExtendObj.au3 ;.......script written by trancexx (trancexx at yahoo dot com) - yea it's PayPal address too Func ObjectExtend($oObject) ; This function adds three methods to original $oObject: __propget__, __propset__ and __call__ ; Resulting object doesn't require any special memory managment. It frees and deallocates itself when reference count reaches 0, like any other object in AutoIt Local $tIntfc If @AutoItX64 Then $tIntfc = DllStructCreate("ptr Object;ptr Original;ulong refCount;ptr pFree;ptr pQueryInterface;ptr pAddRef;ptr pRelease;ptr pGetTypeInfoCount;ptr pGetTypeInfo;ptr pGetIDsOfNames;ptr pInvoke;byte QueryInterface[12];byte AddRef[36];byte Release[44];byte GetTypeInfoCount[12];byte GetTypeInfo[12];byte GetIDsOfNames[148];byte Invoke[536];", __Extend_VirtualAlloc(0, 888, 0x1000, 64)) DllStructSetData($tIntfc, "QueryInterface", "0x488B4908488B0148FF20") DllStructSetData($tIntfc, "AddRef", "0x40534883EC20488BD9488B4908488B01FF50088B4310FFC08943104883C4205BC3") DllStructSetData($tIntfc, "Release", "0xFF4910514883EC20488B4908488B11FF52104883C420598B411085C0750B31D241B800800000FF6118C3") DllStructSetData($tIntfc, "GetTypeInfoCount", "0x488B4908488B0148FF6018") DllStructSetData($tIntfc, "GetTypeInfo", "0x488B4908488B0148FF6020") DllStructSetData($tIntfc, "GetIDsOfNames", "0x48895C2408574883EC304C8B5C2468418BF94D85C074544D85DB744F498B1841BA05150000440FB70B4585C9743D4183E1DF456BD221488D5B024503D1440FB70B4585C975E84181FABDAC0A5A74124181FA62ECB77D74094181FA6E12917E750A41F7DA45891333C0EB1B488B4908448BCF8B4424604C895C2428894424204C8B1141FF5228488B5C24404883C4305FC3") DllStructSetData($tIntfc, "Invoke", "0x488BC4488958084889701848897820895010554154415541564157488BEC4883EC60488B5D58418BF9498BF04C8BF181FA92ED6E810F85DD0000008B4310488B4908FFC84C8B11488D1440488B03488D52014C8D04D0488BD6488D4538488944242844894C242041B90100000041FF5228FF4B10488D45F04C8B7D70BA040000004C8B6568448BCF4C8B6D604C8BC64C897C244048894308C7431401000000498B4E084C89642438C745F0FDFFFFFF4C896C2430488B0148895C242866895424208B5538FF50303D030002800F8527010000498B4E08BA080000004C897C2440448BCF4C896424384C8BC64C896C2430488B0148895C242866895424208B5538FF50303D030002800F85EB000000B806000280E9E100000081FA9E13488275518B431033D289553885C0743A488B4908FFC88BD041B9010000004C8B114C8D044501000000488B034C03C2488BD64E8D04C0488D45384889442428897C242041FF52288B5538FF4B1041B802000000EB5181FA4353F5A575448B431085C0748E488B4908FFC88BD041B9010000004C8B114C8D044501000000488B034C03C2488BD64E8D04C0488D45384889442428897C242041FF5228FF4B108B5538440FB74550488B4570448BCF498B4E084889442440488B45684889442438488B45604C8B11488944243048895C24286644894424204C8BC641FF52304C8D5C2460498B5B30498B7340498B7B48498BE3415F415E415D415C5DC3") Else $tIntfc = DllStructCreate("ptr Object;ptr Original;ulong refCount;ptr pFree;ptr pQueryInterface;ptr pAddRef;ptr pRelease;ptr pGetTypeInfoCount;ptr pGetTypeInfo;ptr pGetIDsOfNames;ptr pInvoke;byte QueryInterface[16];byte AddRef[24];byte Release[48];byte GetTypeInfoCount[16];byte GetTypeInfo[16];byte GetIDsOfNames[108];byte Invoke[356];", __Extend_VirtualAlloc(0, 628, 0x1000, 64)) DllStructSetData($tIntfc, "QueryInterface", "0x8B4424048B40048B0889442404FF21") DllStructSetData($tIntfc, "AddRef", "0x8B5424048B4204508B08FF5104FF42088B4208C20400") DllStructSetData($tIntfc, "Release", "0x8B5424048B5204528B12FF52085A5952FF49088B410885C07515680080000050518B510C40803C02C375F901D05052C3") DllStructSetData($tIntfc, "GetTypeInfoCount", "0x8B4424048B40048B0889442404FF610C") DllStructSetData($tIntfc, "GetTypeInfo", "0x8B4424048B40048B0889442404FF6110") DllStructSetData($tIntfc, "GetIDsOfNames", "0x837C24180074498B44240C85C074418B10B8051500000FB70A85C974336BC0218D520283E1DF01C80FB70A85C975EE3DBDAC0A5A740E3D62ECB77D74073D6E12917E750CF7D88B542418890231C0EB168B4424046A0559FF742418E2FA8B4004508B00FF5014C21800") DllStructSetData($tIntfc, "Invoke", "0x8B542408538B5C2408558B6C2418565781FA92ED6E810F85A20000008B7C24288D4424188B730450558B4F088B078B1683C0F86A01C1E10403C150FF74242C56FF5214FF742434FF4F088D442418FF7424348B742424FF742434C7470C01000000576A048947048B43045556FF742434C7442434FDFFFFFF8B0850FF51183D030002800F85D3000000FF7424348B4304FF742434FF7424348B08576A085556FF74243450FF51183D030002800F85AA0000005F5E5DB8060002805BC224008B74242881FA9E134882753B8B7E0833D28954241885FF74248B4B048D442418508B06558B1183C0F86A01C1E70403C750FF74242C51FF52148B542418FF4E08BF02000000EB3A81FA4353F5A5752E8B7E0885FF749E8B4B048D442418508B06558B1183C0F86A01C1E70403C750FF74242C51FF5214FF4E088B5424188B7C2424FF7424348B4304FF742434FF7424348B08565755FF7424345250FF51185F5E5D5BC22400") EndIf DllStructSetData($tIntfc, "Object", DllStructGetPtr($tIntfc, "pQueryInterface")) DllStructSetData($tIntfc, "Original", Ptr($oObject)) DllStructSetData($tIntfc, "refCount", 1) DllStructSetData($tIntfc, "pFree", __Extend_GetProcAddress(__Extend_GetModuleHandle("kernel32.dll"), "VirtualFree")) DllStructSetData($tIntfc, "pQueryInterface", DllStructGetPtr($tIntfc, "QueryInterface")) DllStructSetData($tIntfc, "pAddRef", DllStructGetPtr($tIntfc, "AddRef")) DllStructSetData($tIntfc, "pRelease", DllStructGetPtr($tIntfc, "Release")) DllStructSetData($tIntfc, "pGetTypeInfoCount", DllStructGetPtr($tIntfc, "GetTypeInfoCount")) DllStructSetData($tIntfc, "pGetTypeInfo", DllStructGetPtr($tIntfc, "GetTypeInfo")) DllStructSetData($tIntfc, "pGetIDsOfNames", DllStructGetPtr($tIntfc, "GetIDsOfNames")) DllStructSetData($tIntfc, "pInvoke", DllStructGetPtr($tIntfc, "Invoke")) ; Call AddRef on original object DllCallAddress("ulong", DllStructGetData(DllStructCreate("ptr pQueryInterface;ptr pAddRef;ptr pRelease;", DllStructGetData(DllStructCreate("ptr Object", Ptr($oObject)), 1)), "pAddRef"), "ptr", Ptr($oObject)) Return ObjCreateInterface(DllStructGetPtr($tIntfc), Default, Default, False) EndFunc Func __Extend_VirtualAlloc($pAddress, $iSize, $iAllocationType, $iProtect) Local $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iAllocationType, "dword", $iProtect) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func __Extend_GetModuleHandle($vModule) Local $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", "wstr", $vModule) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func __Extend_GetProcAddress($hHandle, $sFunc) Local $aCall = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hHandle, "str", $sFunc) If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc ...and then (modified Chimp's): #include <ie.au3> #include "ExtendObj.au3" $oMyObject = ObjectExtend(_IECreate()) ; just to have a "guinea pig" to experiment with Global $aDesiredProperties[] = ['Left=10', 'Top=10', 'Width=260', 'Height=350', 'AddressBar=0', 'MenuBar=0', 'StatusBar=0', 'ToolBar=0'] For $i = 0 To UBound($aDesiredProperties) - 1 $aSet = StringSplit($aDesiredProperties[$i], "=", 2) ; 2 -> $STR_NOCOUNT) $oMyObject.__propset__($aSet[0], $aSet[1]) Next Local $sHTML = '0x3C21444F43545950452068746D6C3E3C68746D6C3E3C686561643E3C2F68656' & _ '1643E3C626F64793E3C696D67207372633D2268747470733A2F2F636F6F6C6D617465726' & _ '9616C2E636F6D2F77702D636F6E74656E742F75706C6F6164732F323031332F30322F737' & _ '472697065732E676966222077696474683D2232323022206865696768743D22323930223' & _ 'E3C2F626F64793E3C2F68746D6C3E' $oMyObject.document.Write(BinaryToString($sHTML)) $oMyObject.document.close() $oMyObject.document.execCommand("Refresh") MsgBox(0, "Info", "Press OK to exit") $oMyObject.quit
    5 points
  3. The Running Object Table (ROT) is a system global table where objects can register themselves. This makes the objects accessible in processes other than the process where the object was created. IRunningObjectTable and related interfaces provides access to register and maintain objects in the ROT. ThreadsOther threads related to ROT objects: Non-blocking data display functions IPC Techniques through ROT Objects AutoIt and Perl integration through ROT objects Access AutoIt by trancexx is about executing AutoIt commands in other programming languages. The AutoIt command is executed by calling a Call method of the ROT object. The example is based on the AutoItObject UDF. Posts (2021-01-03)This is a list of the most interesting posts below: Usage section with typical examples of the use of ROT objects with the following subsections: Passing array between AutoIt programs Passing array between AutoIt and VBScript Passing data through ROT Objects Executing Object Methods through VBScript VBScript (2021-01-03)VBScript is used as a consistent programming language to demonstrate the ROT technique for communicating between AutoIt and other languages. This is a list of the VBScript posts: Passing array between AutoIt and VBScript (in middle of post) Executing Object Methods through VBScript BasicRegister an objectExamples\1) Basic\0) ROT_RegisterObject.au3 #include <Array.au3> #include "..\..\Includes\IRunningObjectTable.au3" Example() Func Example() Local $sNameId = "DataTransferObject" & ROT_CreateGUID() Local $iHandle = ROT_RegisterObject( Default, $sNameId ) ; Default => Object = Dictionary object If Not $iHandle Then Return ConsoleWrite( "ROT_RegisterObject ERR" & @CRLF ) ConsoleWrite( "ROT_RegisterObject OK" & @CRLF ) Local $aROT_List = ROT_Enumerate() _ArrayDisplay( $aROT_List, "ROT_RegisterObject" ) EndFunc Output in _ArrayDisplay looks like this: DataTransferObject-{05DCB964-FD4B-40EC-A95A-999491347D20} $sNameId (similar to ProgID) is the identification of the ROT object and is used in the ObjGet() function to access the object in this way: Local $oDataTransferObject = ObjGet( "DataTransferObject-{05DCB964-FD4B-40EC-A95A-999491347D20}" ) ROT_CreateGUID() is used to make $sNameId unique. See below. ROT_RegisterObject() is the function that registers the object in the ROT. The Dictionary object is the actual object that is registered in the ROT. The Add method allows you to add a new key/item pair to the object. The key is often a string. The item property can be any COM compatible data type which includes most AutoIt data types. An exception is the DllStruct type which must be converted to a compatible type. Because many different data types can be used in the item property and the item can be identified through a key, the Dictionary object is generally applicable for many different purposes. More information about registering objects in the ROT can be found in this Microsoft documentation. ROT_Enumerate() enumerate the objects, that are registered in the ROT. The program that registers an object in the ROT plays the role of server. One or more programs that access the ROT object with the ObjGet() function play the role of clients. The ROT object is only available as long as the server program is running or until the server program deletes the object with the ROT_Revoke() function. You can find examples of using the functions in Examples\1) Basic\. ROT objects (2020-07-11)The Dictionary object is the default object in the ROT_RegisterObject() function. The object that's passed to this function is the actual object that's registered in the ROT. The Dictionary object works fine when passing data between AutoIt scripts, between AutoIt and VBScript, and between AutoIt and Perl. However, situations may easily arise where it can be an advantage to pass data with a very simple object with just a single property. There are several options for creating such a simple object. This can be done through C# and VB.NET code, as demonstrated in Using C# and VB Code in AutoIt through .NET Framework. And it can be done through the AutoItObject UDF. Examples\4) ROT Objects\ contains examples for creating the ROT object in these three ways. Client.au3 is the same script in all examples: #include <Array.au3> Example() Func Example() Local $sNameId = "DataTransfer" Local $oDataTransfer = ObjGet( $sNameId ) Local $aArray = $oDataTransfer.Item _ArrayDisplay( $aArray ) EndFunc Create object with C# code CSharp\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "..\DotNetAll.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next Local $oNetCode = DotNet_LoadCScode( FileRead( "Object.cs" ), "System.dll" ) Local $oCSObject = DotNet_CreateObject( $oNetCode, "CSObjClass" ) $oCSObject.Item = $aArray Local $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oCSObject ), $sNameId ) RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) EndFunc CSharp\Object.cs: using System; public class CSObjClass { public object Item { get; set; } } Create object with VB.NET code VB.NET\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "..\DotNetAll.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next Local $oNetCode = DotNet_LoadVBcode( FileRead( "Object.vb" ), "System.dll" ) Local $oVBObject = DotNet_CreateObject( $oNetCode, "VBObjClass" ) $oVBObject.Item = $aArray Local $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oVBObject ), $sNameId ) RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) EndFunc VB.NET\Object.vb: Imports System Public Class VBObjClass Public Property Item As Object End Class In AutoIt/Perl integration, the very first attempts were performed with the VB.NET object. Check for recognition of the ROT object with this Client.pl script (copied from the AutoIt/Perl example) : 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; } ); Gave the following output: Object = Win32::OLE=HASH(0x72a51c), Class = _VBObjClass ; VB.NET object Object = Win32::OLE=HASH(0x71b5a8), Class = IDictionary ; Dictionary object Create object with AutoItObject AutoItObject\Server.au3: #include "..\..\..\Includes\IRunningObjectTable.au3" #include "AutoitObject.au3" Example() Func Example() Local $aArray[1000][10] For $i = 0 To 1000 - 1 For $j = 0 To 10 - 1 $aArray[$i][$j] = $i & "/" & $j Next Next _AutoItObject_StartUp() Local $oObject = NewObject(), $sNameId = "DataTransfer" ROT_RegisterObject( Ptr( $oObject ), $sNameId ) Local $oDataTransfer = ObjGet( $sNameId ) $oDataTransfer.Item = $aArray RunWait( @AutoItExe & " /AutoIt3ExecuteScript " & "Client.au3" ) _AutoItObject_Shutdown() EndFunc Func NewObject() Local $oClassObject = _AutoItObject_Class() $oClassObject.AddProperty( "Item" ) Return $oClassObject.Object EndFunc Unique objectsWhen using ROT objects in real code, there is a particular question that needs to be addressed. The question is how to make sure that $sNameId, which clients use to access the object with the ObjGet() function, actually identifies a unique object. Running a server program twice in succession can easily create two ROT objects with the same $sNameId. But how do you actually access the ROT object that was created first and the ROT object that was created last? The answer to the question is to make sure that $sNameId also becomes unique so that you can distinguish between the two objects. To that end, the ROT_CreateGUID() function is created (copy of _WinAPI_CreateGUID()). The function can ensure a unique $sNameId as shown in the example above. The problem and solution is demonstrated in Examples\1) Basic\2) Multiple ROT objects.au3. Time stampsUsing the NoteChangeTime() and GetTimeOfLastChange() methods of the IRunningObjectTable interface, you can set and get timestamps on a ROT object. But these timestamps do not seem particularly useful. Therefore, the methods are not implemented. The UDFThe IRunningObjectTable UDF, Includes\IRunningObjectTable.au3, is a very small UDF with less than 150 lines of code: #include-once ; --- Interface definitions --- Global Const $sIID_IRunningObjectTable = "{00000010-0000-0000-C000-000000000046}" Global Const $dtag_IRunningObjectTable = _ "Register hresult(dword;ptr;ptr;dword*);" & _ "Revoke hresult(dword);" & _ "IsRunning hresult(ptr);" & _ "GetObject hresult(ptr;ptr*);" & _ "NoteChangeTime hresult(dword;struct*);" & _ "GetTimeOfLastChange hresult(ptr;ptr*);" & _ "EnumRunning hresult(ptr*);" Global Const $ROTFLAGS_REGISTRATIONKEEPSALIVE = 0x1 Global Const $ROTFLAGS_ALLOWANYCLIENT = 0x2 Global Const $sIID_IEnumMoniker = "{00000102-0000-0000-C000-000000000046}" Global Const $dtag_IEnumMoniker = _ "Next hresult(ulong;ptr*;ulong*);" & _ "Skip hresult(ulong);" & _ "Reset hresult();" & _ "Clone hresult(ptr*);" Global Const $sIID_IPersist = "{0000010C-0000-0000-C000-000000000046}" Global Const $dtag_IPersist = _ "GetClassID hresult(ptr*);" Global Const $sIID_IPersistStream = "{00000109-0000-0000-C000-000000000046}" Global Const $dtag_IPersistStream = $dtag_IPersist & _ "IsDirty hresult();" & _ "Load hresult(ptr);" & _ "Save hresult(ptr;bool);" & _ "GetSizeMax hresult(uint*);" Global Const $sIID_IMoniker = "{0000000F-0000-0000-C000-000000000046}" Global Const $dtag_IMoniker = $dtag_IPersistStream & _ "BindToObject hresult();" & _ "BindToStorage hresult();" & _ "Reduce hresult();" & _ "ComposeWith hresult();" & _ "Enum hresult();" & _ "IsEqual hresult();" & _ "Hash hresult();" & _ "IsRunning hresult(ptr;ptr;ptr);" & _ "GetTimeOfLastChange hresult(ptr;ptr;ptr);" & _ "Inverse hresult();" & _ "CommonPrefixWith hresult();" & _ "RelativePathTo hresult();" & _ "GetDisplayName hresult(ptr;ptr;wstr*);" & _ "ParseDisplayName hresult();" & _ "IsSystemMoniker hresult(ptr*);" ; --- Windows API functions --- Func ROT_GetRunningObjectTable() Return DllCall( "Ole32.dll", "long", "GetRunningObjectTable", "dword", 0, "ptr*", 0 )[2] EndFunc Func ROT_CreateFileMoniker( $sNameId ) Return DllCall( "Ole32.dll", "long", "CreateFileMoniker", "wstr", $sNameId, "ptr*", 0 )[2] EndFunc Func ROT_CreateBindCtx() Return DllCall( "Ole32.dll", "long", "CreateBindCtx", "dword", 0, "ptr*", 0 )[2] EndFunc ; --- UDF functions --- ; Failure: Returns 0 ; Success: Returns $iHandle ; Registers an object and its identifying moniker in the ROT Func ROT_RegisterObject( $pObject, $sNameId, $iFlags = $ROTFLAGS_REGISTRATIONKEEPSALIVE ) If $pObject = Default Then Local $oDict = ObjCreate( "Scripting.Dictionary" ) $pObject = Ptr( $oDict ) EndIf If Not $pObject Or Not $sNameId Then Return 0 Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Local $pMoniker = ROT_CreateFileMoniker( $sNameId ) If Not $pMoniker Then Return 0 Local $iHandle $oRunningObjectTable.Register( $iFlags, $pObject, $pMoniker, $iHandle ) Return $iHandle ? $iHandle : 0 EndFunc ; Returns unique GUID as string ; Copied from _WinAPI_CreateGUID Func ROT_CreateGUID() Local Static $tGUID = DllStructCreate( "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct" ) DllCall( "Ole32.dll", "long", "CoCreateGuid", "struct*", $tGUID ) Return "-" & DllCall( "Ole32.dll", "int", "StringFromGUID2", "struct*", $tGUID, "wstr", "", "int", 65536 )[2] EndFunc ; Failure: Returns 0 ; Success: Returns $aROT_List ; Enumerates objects and identifying monikers in the ROT Func ROT_Enumerate() Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Local $pEnumMoniker $oRunningObjectTable.EnumRunning( $pEnumMoniker ) Local $oEnumMoniker = ObjCreateInterface( $pEnumMoniker, $sIID_IEnumMoniker, $dtag_IEnumMoniker ) If Not IsObj( $oEnumMoniker ) Then Return 0 Local $pMoniker, $oMoniker, $pBindCtx, $sMonikerName, $i = 0 Local $oDict = ObjCreate( "Scripting.Dictionary" ) While( $oEnumMoniker.Next( 1, $pMoniker, NULL ) = 0 ) $pBindCtx = ROT_CreateBindCtx() $oMoniker = ObjCreateInterface( $pMoniker, $sIID_IMoniker, $dtag_IMoniker ) $oMoniker.GetDisplayName( $pBindCtx, NULL, $sMonikerName ) $oDict.Add( "Key" & $i, $sMonikerName ) $i += 1 WEnd Local $aROT_List = $oDict.Items() Return $aROT_List EndFunc ; Failure: Returns 0 ; Success: Returns 1 ; Removes an object and its identifying moniker from the ROT Func ROT_Revoke( $iHandle ) If Not $iHandle Then Return 0 Local $oRunningObjectTable = ObjCreateInterface( ROT_GetRunningObjectTable(), $sIID_IRunningObjectTable, $dtag_IRunningObjectTable ) If Not IsObj( $oRunningObjectTable ) Then Return 0 Return Not $oRunningObjectTable.Revoke( $iHandle ) * 1 EndFunc 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. IRunningObjectTable.7z
    4 points
  4. Sure ... banned permanently! 🤐 Jos
    2 points
  5. New UX Window in AutoIt v3 Watch Full Source Code : Link
    1 point
  6. Yes, you can use Firefox and GeckoDriver (Firefox's webdriver) to send emoji input to the target website.
    1 point
  7. You are not wrong. The more accurate description would be that AutoIt reads the text from the script (.au3 file) in the encoded format (usually UTF-8) and then internally stores it in UTF-16. Right, the data would be intact until the WebDriver recieves the string, this is where problem occurs if the proper encoding is not used. The issue could be in the WebDriver and/or the UDF. --- @Danp2 Upon further investigation of your output, it looks like it is an bug in ChromeDriver: https://stackoverflow.com/a/59139690
    1 point
  8. thanks for this solution, i am using chrome. so i just need to get firefox's webdriver and change to use it in the script, and it should just work? strange that chrome doesn't support that.. i guess, i could have debugged this myself, i just assumed this was due to something in AutoIt; while the real reason is Chrome WebDriver and looking in logs would have helped.. thanks for looking into it, @Danp2! i already translated 8 of my sites to 24 languages each... usually this took me 3-4hrs per site, now the process takes 40 minutes + 5 minutes to check and make sure all is translated and stuff. sometimes i have to fix 2-3 different translations that didn't get there in time, and all is good... before i would fall asleep 2-3 times while doing all this copy-pasting, cause it's sooooooo boring.. so 1 job would go on for 8-12hrs instead of 3.. now i just watch it happen.... on 2 computers simultaneously.. 😃 thanks, friends, for making autoit! 😃 and for all the help...
    1 point
  9. I'll take a look at this. In the mean time, you can try playing with the BinaryFormat option of _WD_Option, which is basically the value used as the second parameter for StringToBinary. Edit: Quickly tested and it works fine in Firefox. In Chrome, I got the following error -- __WD_Post: URL=HTTP://127.0.0.1:9515/session/d0ff79cbc0f8de62387082902d571e86/element/a8493eeb-3218-4e0c-8610-a9f677a05ded/value; $sData={"id":"a8493eeb-3218-4e0c-8610-a9f677a05ded", "text":"??????"} __WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"unknown error: ChromeDriver only supports characters in... __WD_Post ==> Timeout: {"value":{"error":"unknown error","message":"unknown error: ChromeDriver only supports characters in the BMP\n (Session info: chrome=81.0.4044.129)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00A05F73+2449267]\n\tOrdinal0 [0x00938361+1606497]\n\tOrdinal0 [0x0082F969+522601]\n\tOrdinal0 [0x007DFF51+196433]\n\tOrdinal0 [0x007C63E8+91112]\n\tOrdinal0 [0x007C5BCE+89038]\n\tOrdinal0 [0x007D9FAD+171949]\n\tOrdinal0 [0x007C39A6+80294]\n\tOrdinal0 [0x007DA1F1+172529]\n\tOrdinal0 [0x007E326C+209516]\n\tOrdinal0 [0x007D9E5B+171611]\n\tOrdinal0 [0x007C1DD8+73176]\n\tOrdinal0 [0x007C2E50+77392]\n\tOrdinal0 [0x007C2DE9+77289]\n\tOrdinal0 [0x0094D8D7+1693911]\n\tGetHandleVerifier [0x00AA4036+522726]\n\tGetHandleVerifier [0x00AA3D74+522020]\n\tGetHandleVerifier [0x00AB9187+609079]\n\tGetHandleVerifier [0x00AA48A6+524886]\n\tOrdinal0 [0x00945CBC+1662140]\n\tOrdinal0 [0x0094F23B+1700411]\n\tOrdinal0 [0x0094F3A3+1700771]\n\tOrdinal0 [0x00965215+1790485]\n\tBaseThreadInitThunk [0x76346359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77757C14+228]\n\tRtlGetAppContainerNamedObjectPath [0x77757BE4+180]\n"}} _WD_ElementAction: {"value":{"error":"unknown error","message":"unknown error: ChromeDriver only supports characters in... _WD_ElementAction ==> Timeout: {"value":{"error":"unknown error","message":"unknown error: ChromeDriver only supports characters in the BMP\n (Session info: chrome=81.0.4044.129)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00A05F73+2449267]\n\tOrdinal0 [0x00938361+1606497]\n\tOrdinal0 [0x0082F969+522601]\n\tOrdinal0 [0x007DFF51+196433]\n\tOrdinal0 [0x007C63E8+91112]\n\tOrdinal0 [0x007C5BCE+89038]\n\tOrdinal0 [0x007D9FAD+171949]\n\tOrdinal0 [0x007C39A6+80294]\n\tOrdinal0 [0x007DA1F1+172529]\n\tOrdinal0 [0x007E326C+209516]\n\tOrdinal0 [0x007D9E5B+171611]\n\tOrdinal0 [0x007C1DD8+73176]\n\tOrdinal0 [0x007C2E50+77392]\n\tOrdinal0 [0x007C2DE9+77289]\n\tOrdinal0 [0x0094D8D7+1693911]\n\tGetHandleVerifier [0x00AA4036+522726]\n\tGetHandleVerifier [0x00AA3D74+522020]\n\tGetHandleVerifier [0x00AB9187+609079]\n\tGetHandleVerifier [0x00AA48A6+524886]\n\tOrdinal0 [0x00945CBC+1662140]\n\tOrdinal0 [0x0094F23B+1700411]\n\tOrdinal0 [0x0094F3A3+1700771]\n\tOrdinal0 [0x00965215+1790485]\n\tBaseThreadInitThunk [0x76346359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77757C14+228]\n\tRtlGetAppContainerNamedObjectPath [0x77757BE4+180]\n"}}
    1 point
  10. That's great! I'm glad we were able to get the issues worked out so quickly. You're welcome!
    1 point
  11. Yes I was thinking the same, but I would strongly suggest to use ControlSend as it is way more robust and using the class, you can have the same script with multiple language : french, english, etc. : Opt("SendKeyDelay", 0) ;Run("cmd.exe") Local $handle = WinGetHandle("[CLASS:ConsoleWindowClass]") If Not $handle Then Exit MsgBox (0,"","Console not found") WinActivate ($handle) Local $hFile = FileOpen ("help.cmd", $FO_OVERWRITE) FileWrite ($hFile, _ "@echo off" & @CRLF & _ "echo this is the first line of explaination" & @CRLF & _ "echo this is the second line of explaination" & @CRLF & _ "echo this is the third line of explaination" & @CRLF & _ "echo this is the fourth line of explaination" & @CRLF & _ "echo this is the fifth line of explaination" & @CRLF ) FileClose ($hFile) ControlSend($handle, "", "", "help" & @CRLF) Sleep (500) FileDelete ("help.cmd") and calling the script help, is more appropriate for the user
    1 point
  12. "Slow" is a relative term. How well AutoIt handles it will depend on things like how efficient your code is, how many connections have to be handled, and the amount of traffic. The only way to know is to test it and see. FYI, If I were you I would NOT post the public IP address of my SOCKS server to the general public.
    1 point
  13. Hi Friends we're made new Login UI in AutoIt for those who like design. Watch full video (youtube) Link Download Source code: <snip> (p.s. Source code full free you can do anything with it) Please subscribe me on Youtube. Thanks : )
    1 point
  14. Attached already AutoIt Login UI by Se7enstars.zip
    1 point
  15. There are numerous ways to build the binary SOCKS4 request. Here's is just one, static way to build it: socks4_binary_request_example() Func socks4_binary_request_example() Local $xPacket ;Build SOCKS4 Request $xPacket = Binary("0x04") ;Version (SOCKS4) $xPacket &= Binary("0x01") ;Command (Connect) $xPacket &= Binary("0x1DF2") ;Port (7666) $xPacket &= Binary("0x7F000001") ;IP (127.0.0.1) $xPacket &= Binary("0x00") ;UserID () ConsoleWrite("SOCKS4 $xPacket = " & $xPacket & @CRLF) EndFunc Output SOCKS4 $xPacket = 0x04011DF27F00000100 It's just a guide to point you in the right direction once you gain the rest of the knowledge.
    1 point
  16. You're welcome! I look forward to providing more assistance once you get a better understanding of the underlying technical subjects. Not quite. In big-endian, 7666 in decimal is 0x1DF2 in hexadecimal, not 0x1D2F. 0x1D2F would be 7471. ConsoleWrite("7666 in hex (2 bytes/big-endian) = " & "0x" & Hex(7666, 4) & @CRLF) ConsoleWrite("Big-endian 0x1DF2 in decimal = " & Number("0x1DF2") & @CRLF) ConsoleWrite("Big-endian 0x1D2F in decimal = " & Number("0x1D2F") & @CRLF)
    1 point
  17. @TheXman You helped me a lot, thank you very much! This helps me a lot to understand the SOCKS protocol: https://en.wikipedia.org/wiki/SOCKS#SOCKS4a Im going to read it and try to understand it well. About the PORT THING, you were right too, it is : (0x1D) & 0x2F) to make 7666. I will study the sock protocol a lot to understand it well and after that i will try to implement it in autoit. After that if i get any problems i will post back there but not before, there is no point to implement SOCKS in autoit if i dont understand socks at all. You gave me a lot of help, thank and have a good day
    1 point
  18. You did not answer my questions. It appears to me that you may only have limited, if any, experience with the TCP conversation necessary to establish a proxy server connection. It also appears that you do not have a firm understanding of binary and hexadecimal numbering systems. If this is true, then your questions are, and will be, beyond the scope of this forum which is AutoIt General Help & Support. In other words, you require understanding of the TCP communication, the SOCKS4 protocol, and binary/hexadecimal numbering systems, before you can attempt to implement those technical skills in AutoIt. One of the easiest to understand descriptions of the SOCKS protocols can be found on Wikipedia. To answer your specific question, if you read the SOCKS4 protocol, you will see that part of the request packet is a 2-byte, network byte order (big-endian), port number in which you want to connect. I'm not quite sure that you understand the logic that you copied that is building the binary SOCKS4 request. The part that is defining the port, Chr(0x4C) & Chr(0x42) is concatenating 0x4c and 0x42 in order to create the 2-byte port value, 0x4C42. 0x4C42 in hex, interpreted as big-endian, is 19522 in decimal not 7666. The following 2 lines will give you an example of what I'm saying: ConsoleWrite("19522 in hex (2 bytes/big-endian) = " & "0x" & Hex(19522,4) & @CRLF) ConsoleWrite("Big-endian 0x4c42 in decimal = " & Number("0x4C42") & @CRLF) Output 19522 in hex (2 bytes/big-endian) = 0x4C42 Big-endian 0x4c42 in decimal = 19522
    1 point
  19. amu0373

    Script freezes

    Just to wrap up this thread. Function below to check Rasdial is absolutely stable. It has run for a week without any issue. Thanks @Nine & @careca for helping me out! #include "Date.au3" #include "Process.au3" Opt("TrayIconDebug", 1) ; Debugging info on Systray hover Main() Func Main()     Local Static $mCount = 0     While 1         ConsoleWrite("UserTunnel Up = " & CheckRasdial("AlwaysOn-UserTunnel") & @CRLF)         ConsoleWrite("DeviceTunnel Up = " & CheckRasdial("AlwaysOn-DeviceTunnel"))         Sleep (1000)         $mCount += 1         ConsoleWrite(" --> Looped " & $mCount & " times @ " & _NowCalc() & @CRLF & @CRLF)     WEnd EndFunc Func CheckRasdial($Service)     Local $iPID = Run(@ComSpec & " /c " & 'rasdial', "", @SW_HIDE, $STDOUT_CHILD)     ProcessWaitClose($iPID)     Local $sOutput = StdoutRead($iPID)     If StringInStr($sOutput, $Service) Then Return True     Return False EndFunc ;==>CheckRasdial
    1 point
  20. Almost . Here is a simplified description of what happens (to the experts : please be indulgent) : The .pvr file will be opened in binary mode (see FileOpen -> $FO_BINARY) ==> "A file can be read as binary (byte) data by using FileOpen() with the binary flag." Afterwards the read data will be assigned to a variable ($bFileString = FileRead($hSourceFile) ) by using FileRead . The naming $bFileString may be a bit misleading, as it is bytes, not characters. Keep in mind, that every file is in principle just a sequence of bytes. Finally, $bFileString will be written to a .bin file of the same name, leaving out the first 32 bytes (an existing .bin file will be overwritten). To achieve this, you can modify the script. Please take a closer look at the function BinaryMid (it is not very fast but may be easier for you to follow). A bit of searching with google should also help you. There are already contributions that cover this. Just create a script, experiment with it, and if you face problems, post it here for further assistance .
    1 point
  21. This really is a gem, I mean for what it does, as for how it does it, unfortunately for me, I can't understand even one percent of that stuff, but I'm fascinated by it anyway, after all, only a wizard like @trancexx, or rather, only the queen of developers can produce these special effects Thank you so much for this other pearl of yours
    1 point
  22. Thanks @Se7enstars, it's very useful and pretty.
    1 point
  23. Did you try something like this or is this exactly what you tried? If this is exactly what you tried, then of course it doesn't work, the Port (19522) in the request is OBVIOUSLY invalid if your server is server is listening on 7666. If this is truly a SOCKS4 proxy that you are trying to connect through, then the "127.0.0.1" string after the UserID is appears to be erroneous and not a part of the SOCKS4 request. This looks like a SOCK4A request with an IP address instead of a domain name. If you are going to connect to an IP address, then why not pass it in the IP address field? Even assuming that you had created a valid SOCKS4/A request, you didn't check for a response (TCPRecv) from the server to see if the request was granted or if the server replied with an error. Have you ever worked with proxy servers before? Have you ever made a good connection through this particular proxy server (68.18.105.55:10200)? Are you sure this is a SOCKS4/A proxy and not a SOCKS5 server?
    1 point
  24. I have worked on a workaround build in AutoIt3Wrapper to make Au3check/Au3Stripper/Tidy work with filenames containing doublebyte characters and have a beta version working. It works on the principle that all filenames containing characters that aren't supported by these utilities will be copied to @tempdir\AutoIt3WrapperRunTmpFiles\their_ANSI_Filename. Then within these temp files all #include statements that contains these filenames with be updated with it's tempfilename. After that the utility is ran. In case of Tidy and au3stripper, the tidied/stripped source is copied back from this tempdirectory to the correct filename as is expected. Would appreciate when you guys can test this and let me know whether it works as expected. This version 19.1127.1402.3 is available in Beta: AutoIt3Wrapper.au3 Jos
    1 point
  25. Melba23

    Daniel_FUD

    This (now ex)member has gained an unfortunate reputation on other fora of asking for help via PM and attaching a script which, when run, tries to steal your account information/credentials, etc for a whole list of applications before sending them to the OP. If you have received a PM from this (ex)member asking for help with a script DO NOT RUN IT - just delete the PM and/or the downloaded script ASAP. M23
    1 point
  26. New Modern Design UI in AutoIt in 118 line Please watch & like in Youtube: Link Full Source Code free: Link
    1 point
  27. Gianni

    Excel in art

    An "improper" "unusual" use of Excel the script allows the creation of artistic images by simply coloring the background of the individual cells of the Excel workbook. Although definitely useless ... I find it quite funny though have a good time many thanks to @UEZ , @Malkey , @water p.s. I think the pixelite + color to array process can be simplified, but I used the two ready-made functions provided by UEZ and Malkey. I thank both of you (credits and links in listing) p.p.s. strange behaviour: while excell is filling cells, if you move the mouse pointer off the excell window, the fill speed increases ... (?) ; =============================================================================================================================== ; Name ..........: Excel in art ; Description ...: This script allows the creation of artistic images in Excel from a choosed picture. ; The picture is done by simply coloring the background of the individual cells of an Excel workbook. ; Although definitely useless, I find it quite funny though ; ; Return values .: An artistic image in an Excel workbook ; Author ........: Addiego Gianni (chimp) ; Modified ......: ; Remarks .......: Many thanks to UEZ, Malkey and Water ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== #include <GDIPlus.au3> #include <Excel.au3> _PixelsToCells(50) ; <-- Parameter 50 is the cumber of horizontal Excel cells to be filled MsgBox(64, "All done", "Excel art is ready") Func _PixelsToCells($iHcells = 50) ; Check application object Local $oExcel = _Excel_Open() If Not IsObj($oExcel) Then MsgBox(16, "Error", "Sorry, You need to have 'Excel' intalled") ; Choose Image File Local $sPath = FileOpenDialog("Choose Image File", @ScriptDir & "", "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)") If $sPath = '' Then Exit MsgBox(16, "Error", "Sorry, no image was chosen") ; Create a new Excel workbook $oWorkbook = _Excel_BookNew($oExcel, 1) ; initialize GDI+ _GDIPlus_Startup() Local $hBmp = _GDIPlus_BitmapCreateFromFile($sPath) Local $iWidth = _GDIPlus_ImageGetWidth($hBmp) ; get image width ; Local $iHeight = _GDIPlus_ImageGetHeight($hBmp) ; not needed here Local $iStep = $iWidth / $iHcells ; calculate the pixelation factor Local $hBitmap_new = _GDIPlus_PixelateBitmap($hBmp, $iStep) ; pixelate the image Local $aPixelColors = _FileImageToArray($hBitmap_new) ; get pixel colors ; reduce Excel columns width Local $xx = 1, $yy = 1 For $iCol = 0 To UBound($aPixelColors, 2) - 1 Step $iStep $oWorkbook.Sheets(1).Columns($xx).ColumnWidth = 1 $xx += 1 Next ; reduce Excel rows height For $iRow = 0 To UBound($aPixelColors) - 1 Step $iStep $oWorkbook.Sheets(1).Rows($yy).RowHeight = 9 $yy += 1 Next $xx = 1 $yy = 1 For $iRow = 0 To UBound($aPixelColors) - 1 Step $iStep For $iCol = 0 To UBound($aPixelColors, 2) - 1 Step $iStep $oWorkbook.Sheets(1).Range(_Excel_ColumnToLetter($xx) & $yy).Interior.Color = Number("0x" & $aPixelColors[$iRow][$iCol]) $xx += 1 Next $yy += 1 $xx = 1 Next _GDIPlus_BitmapDispose($hBmp) _GDIPlus_Shutdown() EndFunc ;==>_PixelsToCells ; by UEZ ; https://www.autoitscript.com/forum/topic/167707-imagepixelate/?do=findComment&comment=1227509 Func _GDIPlus_PixelateBitmap($hBitmap, $iPixelate, $bSmooth = 1) Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $iNewW = Round($iWidth / $iPixelate, 0), $iNewH = Round($iHeight / $iPixelate, 0) Local $hBitmap_scaled = _GDIPlus_BitmapCreateFromScan0($iNewW, $iNewH) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_scaled) Local $iInterpolation = 5 If $bSmooth Then $iInterpolation = $GDIP_INTERPOLATIONMODE_BILINEAR _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $iInterpolation) _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap, 0, 0, $iNewW, $iNewH) _GDIPlus_GraphicsDispose($hCtxt) Local $hBitmap_pixelated = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_pixelated) _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_NearestNeighbor) _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap_scaled, 0, 0, $iNewW, $iNewH, -$iPixelate, -$iPixelate, $iWidth + 2 * $iPixelate, $iHeight + 2 * $iPixelate) _GDIPlus_GraphicsDispose($hCtxt) Return $hBitmap_pixelated EndFunc ;==>_GDIPlus_PixelateBitmap ; by Malkey ; https://www.autoitscript.com/forum/topic/112540-is-there-a-function-for-reading-images-into-2d-arrays/?do=findComment&comment=788472 Func _FileImageToArray($hImage) Local $Reslt, $stride, $format, $Scan0, $iIW, $iIH ; , $hImage Local $v_Buffer, $width, $height ; _GDIPlus_Startup() ; $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $iIW = _GDIPlus_ImageGetWidth($hImage) $iIH = _GDIPlus_ImageGetHeight($hImage) ProgressOn("Progress Bar", "Filling a " & $iIW & " x " & $iIH & " size array.", "0 percent") $Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iIW, $iIH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") Local $aArray[$height][$width] For $j = 0 To $iIH - 1 For $i = 0 To $iIW - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$j][$i] = StringRegExpReplace(Hex(DllStructGetData($v_Buffer, 1), 6), "(.{2})(.{2})(.{2})", "\3\2\1") ; To RGB format Next ProgressSet(Int(100 * $j / ($iIH)), Int(100 * $j / ($iIH)) & " percent") Next _GDIPlus_BitmapUnlockBits($hImage, $Reslt) ProgressOff() _GDIPlus_ImageDispose($hImage) Return $aArray EndFunc ;==>_FileImageToArray
    1 point
  28. Interesting enough, if you replace the MsgBox with this line then the phenomenon disappear : RunWait (@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, ''Hello World!'', ''Hi!'')"')
    1 point
×
×
  • Create New...