-
Posts
1,921 -
Joined
-
Last visited
-
Days Won
83
LarsJ last won the day on August 7
LarsJ had the most liked content!
About LarsJ
Profile Information
-
Member Title
The Cool Code Company
-
Location
Copenhagen
LarsJ's Achievements
-
SEKOMD reacted to a post in a topic: GUI/Tray Menu with icons and colors
-
MarkIT reacted to a post in a topic: AutoIt and Python Integration
-
robertocm reacted to a post in a topic: Automating Windows Explorer
-
Netol reacted to a post in a topic: UIASpy - UI Automation Spy Tool
-
ioa747 reacted to a post in a topic: Microsoft Edge - WebView2, embed web code in your native application
-
ioa747 reacted to a post in a topic: Microsoft Edge - WebView2, embed web code in your native application
-
ioa747 reacted to a post in a topic: Using ObjCreateInterface() and ObjectFromTag() Functions
-
Decibel reacted to a post in a topic: Kind LarsJ, how does UIA Spy identify these windows?
-
mLipok reacted to a post in a topic: Receive minimize window events from all windows?
-
ioa747 reacted to a post in a topic: Implementing ComboBox Controls
-
ListView marked cells selection via keys
LarsJ replied to UEZ's topic in AutoIt GUI Help and Support
LVN_ITEMCHANGED LVN_ITEMCHANGED LVN_KEYDOWN LVN_ITEMCHANGED LVN_KEYDOWN LVN_KEYDOWN LVN_KEYDOWN LVN_ITEMCHANGED LVN_KEYDOWN LVN_ITEMCHANGED LVN_KEYDOWN LVN_KEYDOWN LVN_ITEMCHANGED LVN_KEYDOWN LVN_KEYDOWN LVN_KEYDOWN LVN_KEYDOWN LVN_KEYDOWN When I run the code I get clear LVN_KEYDOWNs- 12 replies
-
- listview
- arrow keys
-
(and 1 more)
Tagged with:
-
ListView marked cells selection via keys
LarsJ replied to UEZ's topic in AutoIt GUI Help and Support
You might use a hook procedure to identify the key instead.Or test if you can still handle lvn_keydown inside LVN ITEMCHANGED.- 12 replies
-
- listview
- arrow keys
-
(and 1 more)
Tagged with:
-
ListView marked cells selection via keys
LarsJ replied to UEZ's topic in AutoIt GUI Help and Support
Identify keys with lvn_keydown or similar- 12 replies
-
- listview
- arrow keys
-
(and 1 more)
Tagged with:
-
It is easiest to read the value directly in the Edit control with UIASpy. Patterns are only used for actions. eg. to press a button
-
This is a performance issue. Optimize the _WS_Send() function in WebSocketAsio.au3 this way: Func _WS_Send($sData) Return DllCall($hWEBSOCKDLL, $c_ret_size_t, "websocket_send", "wstr", $sData, "USHORT", StringLen($sData), "BOOL", 0)[0] EndFunc Other functions involved in asynchronous callback must be similarly optimized. Also remove the Sleep(10) line in the For loop in reproduce.au3. It's exactly the same problem as in the Subclassing bug.
-
Switching from DLLCall X86 to X64
LarsJ replied to skijve's topic in AutoIt General Help and Support
Some work has already been done regarding newer versions of OpenCV code as well as 64 bit code. It seems to start in this post and continue through out the rest of the thread. By quickly skimming through the posts, it doesn't appear to be completely trivial, but also not completely unmanageable. May be it was an idea to start a new project under Projects and Collaboration to gather interested forces. After all, it's about the core areas of application of AutoIt, and therefore not uninteresting. -
I'm pretty sure Danyfirex means the Win32 (collective term for x86 and x64 code) implementation of the UI Automation code. It's already implemented in AutoIt.
-
Overview The example is named AutoIt and Python Integration. Integration here means data integration, where data e.g. arrays are passed back and forth between AutoIt and Python scripts. The technique is based on ROT objects registered in the Running Object Table (ROT). Relevant threads IRunningObjectTable AutoIt and Perl Integration AutoIt and VBScript Integration (middle of post) Execute VBScript method in AutoIt First post Running Object Table (ROT) A summary of the technique Two AutoIt Scripts Which data types can be passed? AutoIt and Python Integration Python Installation AutoIt and Python Simple examples Prime Numbers Python calculation of prime numbers and passing data to AutoIt Also prime number calculation with AutoIt and VB.NET code Runtimes Speed comparison of AutoIt, Python and VB.NET code Based on the prime number calculations above Python and VBScript Pass array between Python and VBScript 7z-file Running Object Table (ROT) The Running Object Table (ROT) is a system global table where objects can register themselves. This makes the objects available in processes other than the process in which the objects are created. These processes can be implemented in different programming languages. A ROT object is typically used to exchange data between the processes. An object is registered in the ROT through the IRunningObjectTable interface. A script that registers an object in the ROT is referred to as a server. A ROT object is usually available in the table as long as the server is running. IRunningObjectTable.au3 must be included in the server script. A script that uses an object in the ROT is referred to as a client. A client connects to a ROT object through functions such as GetObject(), GetActiveObject(), and the like. Therefore, a client doesn't depend on IRunningObjectTable.au3. A client and a server can exchange data through the ROT object. But two clients can also exchange data through a common server. Since IRunningObjectTable.au3 is an AutoIt include file, it's easy to create the server as an AutoIt script. As the data transfer takes place using COM objects, only COM compatible data can be transferred. If sender and receiver scripts are coded in different languages, then data exchange also depends on the data types being represented in both languages. Most script languages support simple data types such as integers, floats and strings as well as advanced data types such as arrays and dictionary objects. An advantage of using ROT objects is that internal data types of e.g. array elements are preserved during a data transfer. Below is demonstrated data exchange between AutoIt and Python. Eg. how to pass an array from AutoIt to Python, perform calculations with functions in the NumPy package, and return the results to AutoIt. But first there is a test on passing data between two AutoIt scripts. Two AutoIt ScriptsWhich data types can be exchanged through a ROT object between two AutoIt scripts running in two different processes? Examples in Examples\AutoItAutoIt\ folder. These are slight variations of the VarGetType() example in the help file. Server.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include "..\..\Includes\IRunningObjectTable.au3" Server() Func Server() ; Create a default ROT-object (Dictionary object) ; The script that creates the ROT object is the server ; The ROT object is available while the server is running Local $sDataTransferObject = "DataTransferObject", $oDict $oDict = ROT_CreateDefaultObject( $sDataTransferObject, 0 ) ; 0 -> Non-unique ; AutoIt data types Local $aArray[2] = [ 1, "Example" ] Local $mMap[] Local $dBinary = Binary( "0x00204060" ) Local $bBoolean = False Local $pPtr = Ptr( -1 ) Local $hWnd = WinGetHandle( AutoItWinGetTitle() ) Local $iInt = 1 Local $fFloat = 2.0 Local $oObject = ObjCreate( "Scripting.Dictionary" ) Local $sString = "Some text" Local $tStruct = DllStructCreate( "wchar[256]" ) Local $vKeyword = Default Local $fuFunc = ConsoleWrite Local $fuUserFunc = Test ; Add data to $oDict $oDict.Item( "$aArray" ) = $aArray $oDict.Item( "$mMap" ) = $mMap $oDict.Item( "$dBinary" ) = $dBinary $oDict.Item( "$bBoolean" ) = $bBoolean $oDict.Item( "$pPtr" ) = $pPtr $oDict.Item( "$hWnd" ) = $hWnd $oDict.Item( "$iInt" ) = $iInt $oDict.Item( "$fFloat" ) = $fFloat $oDict.Item( "$oObject" ) = $oObject $oDict.Item( "$sString" ) = $sString $oDict.Item( "$tStruct" ) = $tStruct $oDict.Item( "$vKeyword" ) = $vKeyword $oDict.Item( "$fuFunc" ) = $fuFunc $oDict.Item( "$fuUserFunc" ) = $fuUserFunc ; Create server GUI Local $hGui = GUICreate( "Server", 200, 70, 200, 50 ) ; Show GUI GUISetState() MsgBox( 0, "Variable Types on Server", _ "$aArray : " & @TAB & @TAB & VarGetType( $aArray ) & " variable type" & @CRLF & _ "$mMap : " & @TAB & @TAB & VarGetType( $mMap ) & " variable type" & @CRLF & _ "$dBinary : " & @TAB & VarGetType( $dBinary ) & " variable type" & @CRLF & _ "$bBoolean : " & @TAB & VarGetType( $bBoolean ) & " variable type" & @CRLF & _ "$pPtr : " & @TAB & @TAB & VarGetType( $pPtr ) & " variable type" & @CRLF & _ "$hWnd : " & @TAB & @TAB & VarGetType( $hWnd ) & " variable type" & @CRLF & _ "$iInt : " & @TAB & @TAB & VarGetType( $iInt ) & " variable type" & @CRLF & _ "$fFloat : " & @TAB & @TAB & VarGetType( $fFloat ) & " variable type" & @CRLF & _ "$oObject : " & @TAB & VarGetType( $oObject ) & " variable type" & @CRLF & _ "$sString : " & @TAB & VarGetType( $sString ) & " variable type" & @CRLF & _ "$tStruct : " & @TAB & VarGetType( $tStruct ) & " variable type" & @CRLF & _ "$vKeyword : " & @TAB & VarGetType( $vKeyword ) & " variable type" & @CRLF & _ "$fuFunc : " & @TAB & VarGetType( $fuFunc ) & " variable type" & @CRLF & _ "$fuUserFunc : " & @TAB & VarGetType( $fuUserFunc ) & " variable type" ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) EndFunc Func Test() EndFunc Run the script by double clicking. MsgBox output: Variable Types on Server $aArray : Array variable type $mMap : Map variable type $dBinary : Binary variable type $bBoolean : Bool variable type $pPtr : Ptr variable type $hWnd : Ptr variable type $iInt : Int32 variable type $fFloat : Double variable type $oObject : Object variable type $sString : String variable type $tStruct : DLLStruct variable type $vKeyword : Keyword variable type $fuFunc : Function variable type $fuUserFunc : UserFunction variable type Just leave the MsgBox running. Client.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> ; IRunningObjectTable.au3 UDF ; not needed in the client. Client() Func Client() ; Error monitoring. This will trap all COM errors while alive. Local $oErrorHandler = ObjEvent( "AutoIt.Error", "COMerror" ) ; Get default ROT-object (Dict obj) Local $oDict = ObjGet( "DataTransferObject" ) Local $aArray = $oDict.Item( "$aArray" ), $aArrayErr = @error Local $mMap = $oDict.Item( "$mMap" ), $mMapErr = @error Local $dBinary = $oDict.Item( "$dBinary" ), $dBinaryErr = @error Local $bBoolean = $oDict.Item( "$bBoolean" ), $bBooleanErr = @error Local $pPtr = $oDict.Item( "$pPtr" ), $pPtrErr = @error Local $hWnd = $oDict.Item( "$hWnd" ), $hWndErr = @error Local $iInt = $oDict.Item( "$iInt" ), $iIntErr = @error Local $fFloat = $oDict.Item( "$fFloat" ), $fFloatErr = @error Local $oObject = $oDict.Item( "$oObject" ), $oObjectErr = @error Local $sString = $oDict.Item( "$sString" ), $sStringErr = @error Local $tStruct = $oDict.Item( "$tStruct" ), $tStructErr = @error Local $vKeyword = $oDict.Item( "$vKeyword" ), $vKeywordErr = @error Local $fuFunc = $oDict.Item( "$fuFunc" ), $fuFuncErr = @error Local $fuUserFunc = $oDict.Item( "$fuUserFunc" ), $fuUserFuncErr = @error ConsoleWrite( "Variable Types on Client" & @CRLF ) ConsoleWrite( "$aArray : " & ( $aArrayErr ? "@error = " & $aArrayErr : VarGetType( $aArray ) & " variable type" ) & @CRLF ) ConsoleWrite( "$mMap : " & ( $mMapErr ? "@error = " & $mMapErr : VarGetType( $mMap ) & " variable type" ) & @CRLF ) ConsoleWrite( "$dBinary : " & ( $dBinaryErr ? "@error = " & $dBinaryErr : VarGetType( $dBinary ) & " variable type" ) & @CRLF ) ConsoleWrite( "$bBoolean : " & ( $bBooleanErr ? "@error = " & $bBooleanErr : VarGetType( $bBoolean ) & " variable type" ) & @CRLF ) ConsoleWrite( "$pPtr : " & ( $pPtrErr ? "@error = " & $pPtrErr : VarGetType( $pPtr ) & " variable type" ) & @CRLF ) ConsoleWrite( "$hWnd : " & ( $hWndErr ? "@error = " & $hWndErr : VarGetType( $hWnd ) & " variable type" ) & @CRLF ) ConsoleWrite( "$iInt : " & ( $iIntErr ? "@error = " & $iIntErr : VarGetType( $iInt ) & " variable type" ) & @CRLF ) ConsoleWrite( "$fFloat : " & ( $fFloatErr ? "@error = " & $fFloatErr : VarGetType( $fFloat ) & " variable type" ) & @CRLF ) ConsoleWrite( "$oObject : " & ( $oObjectErr ? "@error = " & $oObjectErr : VarGetType( $oObject ) & " variable type" ) & @CRLF ) ConsoleWrite( "$sString : " & ( $sStringErr ? "@error = " & $sStringErr : VarGetType( $sString ) & " variable type" ) & @CRLF ) ConsoleWrite( "$tStruct : " & ( $tStructErr ? "@error = " & $tStructErr : VarGetType( $tStruct ) & " variable type" ) & @CRLF ) ConsoleWrite( "$vKeyword : " & ( $vKeywordErr ? "@error = " & $vKeywordErr : VarGetType( $vKeyword ) & " variable type" ) & @CRLF ) ConsoleWrite( "$fuFunc : " & ( $fuFuncErr ? "@error = " & $fuFuncErr : VarGetType( $fuFunc ) & " variable type" ) & @CRLF ) ConsoleWrite( "$fuUserFunc : " & ( $fuUserFuncErr ? "@error = " & $fuUserFuncErr : VarGetType( $fuUserFunc ) & " variable type" ) & @CRLF ) ConsoleWrite( @CRLF & "@error = -2147221163 = 0x80040155" & @CRLF & " Interface not registered" & @CRLF ) #forceref $oErrorHandler EndFunc Func COMerror() EndFunc Run the script in SciTE with F5. The object event message handler, $oErrorHandler, is used to set an error code in @error. Console output: Variable Types on Client $aArray : Array variable type $mMap : @error = -2147221163 $dBinary : Binary variable type $bBoolean : Bool variable type $pPtr : Int32 variable type $hWnd : Int32 variable type $iInt : Int32 variable type $fFloat : Double variable type $oObject : Object variable type $sString : String variable type $tStruct : @error = -2147221163 $vKeyword : Keyword variable type $fuFunc : @error = -2147221163 $fuUserFunc : @error = -2147221163 @error = -2147221163 = 0x80040155 Interface not registered There are 3 COM incompatible data types that all fail with error code 0x80040155, Interface not registered: Map, DllStruct and Function. An inspection of these data types with code in InspectVariable.au3 from Accessing AutoIt Variables gives this result: InspectVariable.txt: $mMap Type = Map ptr = 0x009B5FF8 ($pVariant) vt = 0x0024 (VT_RECORD, pointer to record object) data = 0x00000000 $tStruct Type = DLLStruct ptr = 0x009E3C08 ($pVariant) vt = 0x0024 (VT_RECORD, pointer to record object) data = 0x00000000 $fuFunc Type = Function ptr = 0x009E3C98 ($pVariant) vt = 0x0024 (VT_RECORD, pointer to record object) data = 0x00000000 $fuUserFunc Type = UserFunction ptr = 0x009E3C98 ($pVariant) vt = 0x0024 (VT_RECORD, pointer to record object) data = 0x00000000 In all cases the variant data type is VT_RECORD used for user defined types (UDTs) and the data field, which should be a pointer to the IRecordInfo interface, is a NULL pointer. It's thus not possible to obtain more information about these data types. At least not through the techniques in Accessing AutoIt Variables. The bottom line seems to be that the data types are coded through COM incompatible custom implementations in the AutoIt internal C/C++ code. AutoIt and Python Integration The rather elusive code box at top of this post nevertheless indicates how to access a ROT object in Python through the GetObject() function. This allows data to be exchanged between AutoIt and Python. But first Python must be installed. Python InstallationPython 3.8.0 is the latest version that can be installed on Windows 7. To avoid spending too much time on installation, it's easiest to just download the Windows x86-64 executable installer (python-3.8.0-amd64.exe) at bottom of the page and install Python from there. Make sure that the path to the Python installation folder is added to environment variables. Necessary for AutoIt commands like Run and RunWait to find Python.exe without specifying the full path, which can be different from one PC to another. Upgrade PIP package manager: C:\>py -m pip install --upgrade pip Install PyWin32 package to access the Windows API C:\>py -m pip install --upgrade pywin32 Install NumPy package with support for arrays and matrices C:\>py -m pip install --upgrade numpy AutoIt and PythonExamples\AutoItPython\ contains 3 small AutoIt scripts and 2 Python scripts for a simple demonstration of passing arrays back and forth between AutoIt and Python. Open a command prompt and run the 5 scripts in a similar way: C:\>d: D:\>cd D:\...\Examples\AutoItPython D:\...\Examples\AutoItPython>subst z: . D:\...\Examples\AutoItPython>z: Z:\>"0) Server.au3" Z:\>"1) AutoIt send.au3" Z:\>"2) Python rec.py" (123, 456.789, 'String') 123 <class 'int'> 456.789 <class 'float'> String <class 'str'> ((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)) (1, 2, 3, 4) Z:\>"3) Python send.py" Z:\>"4) AutoIt rec.au3" Z:\>d: D:\...\Examples\AutoItPython>subst z: /d It should be enough to press 0+Tab to execute "0) Server.au3". Correspondingly for the other scripts. 0) Server.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include "IRunningObjectTable.au3" Server() Func Server() ; Create a default ROT-object (Dictionary object) ; The script that creates the ROT object is the server ; The ROT object is available while the server is running Local $sDataTransferObject = "DataTransferObject" ROT_CreateDefaultObject( $sDataTransferObject, 0 ) ; 0 -> Non-unique ; Create server GUI Local $hGui = GUICreate( "Server", 200, 70, 200, 50 ) ; Show GUI GUISetState() ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) EndFunc 1) AutoIt send.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Get default ROT-object (Dictionary object) Local $oDict = ObjGet( "DataTransferObject" ) ; Add 1d array to $oDict Local $aArray1 = [ 123, 456.789, "String" ] $oDict.Item( "aArray1" ) = $aArray1 ; Add 2d array to $oDict ; In AutoIt and Python, rows and columns are swapped ; The AutoIt array below will result in the following Python array ; aArray = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ] ] Local $aArray2 = [ _ [ 1, 5, 9 ], _ [ 2, 6, 10 ], _ [ 3, 7, 11 ], _ [ 4, 8, 12 ] ] $oDict.Item( "aArray2" ) = $aArray2 EndFunc 2) Python rec.py: import win32com.client import numpy as np # Get default ROT-object (Dictionary object) oDict = win32com.client.GetObject( "DataTransferObject" ) # Get 1d AutoIt array as List aArray1 = oDict( "aArray1" ) print( aArray1 ) print( "" ) # Print data types for item in aArray1: print( "{}\t{}".format( item, type( item ) ) ) print( "" ) # Get 2d array as NumPy array np.aArray2 = oDict( "aArray2" ) print( np.aArray2 ) print( np.aArray2[0] ) These are the _ArrayDisplay's created by 4) AutoIt rec.au3: Prime NumbersExamples\Prime numbers\1) Scripts\ contains scripts to calculate prime numbers using AutoIt, Python and VB.NET. Run au3-scripts in SciTE with F5. pyPrimes.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include "..\..\..\Includes\IRunningObjectTable.au3" #include "..\..\..\Includes\DataDisplay\Functions\ArrayDisplayEx\ArrayDisplayEx.au3" #include "..\..\..\Includes\DataDisplay\Functions\ArrayDisplayEx\ArrayDisplayEx_ColumnFormats.au3" ; Create a default ROT-object (Dictionary object) ; The script that creates the ROT object is the server ; The ROT object is available while the server is running Global $sDataTransferObject = "DataTransferObject" Global $oDict = ROT_CreateDefaultObject( $sDataTransferObject, 0 ) ; 0 -> Non-unique Example( 100 ) Example( 1000 ) Example( 10000 ) Func Example( $nPrimes ) Local $aAlignment = [ [ 0, "C" ], [ 1, "R" ] ] Local $aColWidthMin = [ [ 0, 65 ], [ 1, 80 ] ] Local $aColFormats = [ 0, "Int1000Sep", "," ] ; DATA SOURCE column index Local $aFeatures = [ [ "ColAlign", $aAlignment ], _ [ "ColWidthMin", $aColWidthMin ], _ [ "ColFormats", $aColFormats ], _ [ "1dColumns", 10 ] ] RunWait( "Python.exe pyPrimes.py " & """" & $nPrimes & """", "", @SW_HIDE ) Local $aPrimes = $oDict.Item( "aPrimes" ) _ArrayDisplayEx( $aPrimes, "Prime numbers", "#|Primes", 0, $aFeatures ) EndFunc pyPrimes.py: import sys import math as ma import numpy as np import win32com.client # Get default ROT-object (Dictionary object) oDict = win32com.client.GetObject( "DataTransferObject" ) def CalcPrimes( nPrimes ): # Define NumPy array to store prime numbers aPrimes = np.zeros( shape = ( nPrimes, ), dtype = np.int32 ) # Store first prime iPrime = 2 iPrimes = 0 aPrimes[iPrimes] = iPrime iPrimes += 1 iPrime += 1 # Calculate primes while iPrimes < nPrimes: i = 1 iMaxFactor = ma.ceil(ma.sqrt(iPrime)) while i < iPrimes and aPrimes[i] <= iMaxFactor: if ma.fmod( iPrime, aPrimes[i] ) == 0: i = iPrimes i += 1 if i < iPrimes + 1: aPrimes[iPrimes] = iPrime iPrimes += 1 iPrime += 2 oDict[ "aPrimes" ] = aPrimes CalcPrimes( int( sys.argv[1] ) ) RuntimesExamples\Prime numbers\2) Runtimes\ is a speed comparison of the 3 prime number calculations performed with the techniques in Runtimes and Speed Comparisons. Run Primes.au3 in SciTE with F5. Primes.txt: Calculation of Prime Numbers Calculation of Prime Numbers AutoIt vs Python vs VB.NET AutoIt vs Python vs VB.NET Code executed as 64-bit code Code executed as 64-bit code ================================== ================================== 100 prime numbers 100 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 7.1752 AutoIt calculation: 1.8151 Python calculation: 339.0743 Python calculation: 312.9130 VB.NET calculation: 0.1008 VB.NET calculation: 0.0481 500 prime numbers 500 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 16.3156 AutoIt calculation: 14.9084 Python calculation: 317.8483 Python calculation: 314.0434 VB.NET calculation: 0.1665 VB.NET calculation: 0.1207 1,000 prime numbers 1,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 38.2239 AutoIt calculation: 40.0983 Python calculation: 345.3165 Python calculation: 318.2725 VB.NET calculation: 0.5128 VB.NET calculation: 0.2229 2,000 prime numbers 2,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 108.7436 AutoIt calculation: 102.3103 Python calculation: 357.4340 Python calculation: 353.0137 VB.NET calculation: 0.7696 VB.NET calculation: 0.4523 5,000 prime numbers 5,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 351.2818 AutoIt calculation: 355.7042 Python calculation: 418.0871 Python calculation: 404.9797 VB.NET calculation: 1.6748 VB.NET calculation: 1.3370 10,000 prime numbers 10,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 919.5793 AutoIt calculation: 928.2449 Python calculation: 602.1903 Python calculation: 553.9019 VB.NET calculation: 3.9493 VB.NET calculation: 3.1382 20,000 prime numbers 20,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 2365.4960 AutoIt calculation: 2378.4718 Python calculation: 1161.5604 Python calculation: 991.8602 VB.NET calculation: 9.8814 VB.NET calculation: 8.0775 50,000 prime numbers 50,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 8748.3280 AutoIt calculation: 8598.7165 Python calculation: 3422.4653 Python calculation: 2717.4886 VB.NET calculation: 33.1839 VB.NET calculation: 27.4017 100,000 prime numbers 100,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: 22959.9331 AutoIt calculation: 22686.7254 Python calculation: 8589.2150 Python calculation: 6701.6450 VB.NET calculation: 83.8414 VB.NET calculation: 69.6644 250,000 prime numbers 250,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: 30198.3188 Python calculation: 23837.4175 VB.NET calculation: 293.9497 VB.NET calculation: 235.9579 500,000 prime numbers 500,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: 765.3462 VB.NET calculation: 600.5832 750,000 prime numbers 750,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: 1346.5033 VB.NET calculation: 1051.7918 1,000,000 prime numbers 1,000,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: 2011.5523 VB.NET calculation: 1567.1886 2,500,000 prime numbers 2,500,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: 7297.9896 VB.NET calculation: 5667.4302 5,000,000 prime numbers 5,000,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: 19501.3542 VB.NET calculation: 15133.7115 10,000,000 prime numbers 10,000,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: >10000.0000 VB.NET calculation: >10000.0000 16,000,000 prime numbers 16,000,000 prime numbers ---------------------------------- ---------------------------------- AutoIt calculation: >10000.0000 AutoIt calculation: >10000.0000 Python calculation: >10000.0000 Python calculation: >10000.0000 VB.NET calculation: >10000.0000 VB.NET calculation: >10000.0000 The measurements in the left column are carried out on a Windows 7, medium, 6½ year old PC. The measurements on the right on a Windows 10, medium (high end), 1½ year old PC. A comparison of AutoIt and Python code shows that AutoIt performs best for a small number of prime numbers. This is due to an overhead when passing data from Python to AutoIt. When calculating about 7,500 prime numbers and higher, Python code becomes faster than AutoIt code. Up to about 3 times faster in these measurements. This is probably due to differences in AutoIt and Python code interpreters. The performance optimization when using real compiled VB.NET code is quite clear. Up to 100 and 300 times faster than Python and AutoIt code respectively. Both Python and VB.NET code perform about 25% better on newer hardware. AutoIt code shows the same performance on old and new hardware. The lack of optimization can probably only be attributed to the Windows 10 operating system. Python and VBScriptExamples\PythonVBScript\ shows the exchange of array data between Python and VBScript through a ROT object created by an AutoIt server. Note the simplicity of the code. Open a command prompt and run the 5 scripts in a similar way: C:\>d: D:\>cd D:\...\Examples\PythonVBScript D:\...\Examples\PythonVBScript>subst z: . D:\...\Examples\PythonVBScript>z: Z:\>"0) Server.au3" Z:\>"1) Python send.py" Z:\>"2) VBScript rec.vbs" Z:\>"3) VBScript send.vbs" Z:\>"4) Python rec.py" (123, 456.789, 'String') 123 <class 'int'> 456.789 <class 'float'> String <class 'str'> Z:\> Z:\>d: D:\...\Examples\PythonVBScript>subst z: /d 1) Python send.py: import win32com.client # Get default ROT-object (Dictionary object) oDict = win32com.client.GetObject( "DataTransferObject" ) # Add 1d List to oDict aArray1 = [ 123, 456.789, "String" ] oDict[ "aArray1" ] = aArray1 2) VBScript rec.vbs: 'Get default ROT-object (Dictionary object) Set oDict = GetObject( "DataTransferObject" ) aArray1 = oDict( "aArray1" ) MsgBox( "aArray1(0) = " & aArray1(0) & vbTab & vbTab & "Variant type = " & VarType( aArray1(0) ) & " (vbLong)" & vbCrLf & _ "aArray1(1) = " & aArray1(1) & vbTab & "Variant type = " & VarType( aArray1(1) ) & " (vbDouble)" & vbCrLf & _ "aArray1(2) = " & aArray1(2) & vbTab & vbTab & "Variant type = " & VarType( aArray1(2) ) & " (vbString)" & vbCrLf ) This is the MsgBox created by 2) VBScript rec.vbs: 7z-file The 7z-file contains source code for UDFs and examples You need AutoIt 3.3.16.1 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. AutoItPython.7z
-
You cannot know in advance which automation options will work. If you want to make something that is generally applicable, then you will need to make some small tests for all 3 options. But I have no immediate ideas about possible test applications.
-
You do it this way. tst00.cmd: start "CmdIdentifierString" /wait tst00.exe tst00.au3: #AutoIt3Wrapper_Change2CUI=Y ;#RequireAdmin ; Maybe you need #RequireAdmin rights? ; Maybe exclude exe/folder from antivirus program? DllCall( "Kernel32.dll", "int", "AttachConsole", "dword", WinGetProcess( "CmdIdentifierString" ) ) Func CmdConsoleWrite( $sStr ) DllCall( "Kernel32.dll", "bool", "WriteConsoleW", "handle", _ DllCall( "Kernel32.dll", "handle", "GetStdHandle", "int", -11 )[0], _ ; -11 = STD_OUTPUT_HANDLE "wstr", $sStr, "dword", StringLen( $sStr ), "dword*", 0, "ptr", 0 ) EndFunc CmdConsoleWrite( @CRLF ) For $i = 1 To 5 CmdConsoleWrite( "This is test number " & $i & @CRLF ) If $i < 5 Then Sleep( 3000 ) Next Exit Run tst00.cmd in a Command Prompt or double-click. Tested on Windows 7 as 32/64 bit code.
-
You will need to find out what type of automation is supported by your application. Classic (AutoIt) automation, MSAA automation (Inspect.exe, dropdown control in upper left corner) or UI Automation (Inspect.exe or UIASpy). For both MSAA and UI Automation code, the rule of thumb is that it's only possible to automate a task that can be performed manually by an end user.
-
UI Automation code and application code simply must not be mixed together in the same executable code. Never ever use UI Automation code to automate an AutoIt application. Apparently the UI Automation code has a very negative impact on the AutoIt code. It can be seen, for example, through very poor UIASpy performance when UIASpy is used on an AutoIt application. If you want to compare AutoIt automation code and UI Automation code, use Notepad as the target application. If you want to automate an AutoIt application it's much much better to use AutoIt code.
-
mLipok, First issue. CreatePropertyCondition and $UIA_NativeWindowHandlePropertyId must be used like this: $oUIA.CreatePropertyCondition($UIA_NativeWindowHandlePropertyId, $hWnd, $pCondition1) A window handle value must be specified directly. Not a title. You should be able to see the window handle in UIASpy. mLipok, Second issue. You should be able to see the window handle in UIASpy. Do you see a correct handle or is the value also 0? Nisteo, It looks like you are referring to docu for .NET managed code. But this is standard unmanaged 32/64 bit code, collectively referred to as Win32 code in MS docu.
-
TreeView Extended Styles The MS docu for TreeView extended styles can be found here. Most styles revolve around visual features. This is an implementation of some of these styles: TVS_EX_AUTOHSCROLL Failed to get this style to work. May depend on the TVM_SETAUTOSCROLLINFO message. TVS_EX_DIMMEDCHECKBOXES, TVS_EX_EXCLUSIONCHECKBOXES, TVS_EX_PARTIALCHECKBOXES Depends on the TVS_CHECKBOXES style also being set. The extended CheckBoxes styles must be set before the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. These CheckBoxes look better on Windows 7 than on Windows 10. On Windows 10, some of the state images become very similar. Maybe it's possible to save the state images as icons on Windows 7 and load the icons as new state images on Windows 10. Not tested. TVS_EX_DOUBLEBUFFER The double buffer extended style is usually used to reduce flicker when using the vertical ScrollBar. Therefore, the style is interesting compared to virtual TreeViews. However, it's somewhat uncertain whether the style has any effect at all for these TreeViews, or whether it only works for standard TreeViews. TVS_EX_DRAWIMAGEASYNC Has not been implemented so far. TVS_EX_FADEINOUTEXPANDOS Fade in/out of collapse/expand Buttons when the TreeView control gains/loses focus. Also works better on Windows 7 than on Windows 10. TVS_EX_MULTISELECT According to MS docu this style is not supported. Not implemented. TVS_EX_NOINDENTSTATE No indentation of collapse/expand Buttons. Thus, these Buttons are aligned along the left edge of the TreeView. Failed to get this style to work. TVS_EX_NOSINGLECOLLAPSE Intended for internal use. Not implemented. TVS_EX_RICHTOOLTIP Seems to depend on custom drawn ToolTips. Not implemented. TreeViewExtendedStyles.au3 include #include-once #include <SendMessage.au3> #include <TreeViewConstants.au3> Global Const $TVS_EX_MULTISELECT = 0x0002 Global Const $TVS_EX_DOUBLEBUFFER = 0x0004 Global Const $TVS_EX_NOINDENTSTATE = 0x0008 Global Const $TVS_EX_RICHTOOLTIP = 0x0010 Global Const $TVS_EX_AUTOHSCROLL = 0x0020 Global Const $TVS_EX_FADEINOUTEXPANDOS = 0x0040 Global Const $TVS_EX_PARTIALCHECKBOXES = 0x0080 Global Const $TVS_EX_EXCLUSIONCHECKBOXES = 0x0100 Global Const $TVS_EX_DIMMEDCHECKBOXES = 0x0200 Global Const $TVS_EX_DRAWIMAGEASYNC = 0x0400 Global Const $TVM_SETEXTENDEDSTYLE = $TV_FIRST + 44 Global Const $TVM_GETEXTENDEDSTYLE = $TV_FIRST + 45 Func _GUICtrlTreeView_GetExtendedStyle( $hWnd ) Return IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_GETEXTENDEDSTYLE ) _ : GUICtrlSendMsg( $hWnd, $TVM_GETEXTENDEDSTYLE, 0, 0 ) EndFunc ; $iExStyle: Extended control styles ; $iExMask: Specifies which styles in $iExStyle are to be affected Func _GUICtrlTreeView_SetExtendedStyle( $hWnd, $iExStyle, $iExMask = 0 ) Local $iRet = IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _ : GUICtrlSendMsg( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _WinAPI_InvalidateRect( $hWnd ) Return $iRet EndFunc CheckBoxes.au3 example Examples in the Examples\Styles\ folder. Run the examples in SciTE with F5. This is the extended CheckBoxes example, CheckBoxes.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" #include "..\..\Includes\TreeViewExtendedStyles.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - CheckBoxes", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set CheckBoxes extended styles ; Click CheckBoxes several times to see the different styles _GUICtrlTreeView_SetExtendedStyle( $idTV, $TVS_EX_PARTIALCHECKBOXES+$TVS_EX_EXCLUSIONCHECKBOXES+$TVS_EX_DIMMEDCHECKBOXES ) ; Set CheckBoxes style ; Must be set AFTER extended styles ; Extended CheckBox styles depends on the TVS_CHECKBOXES style also being set. The extended CheckBox styles ; must be set BEFORE the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE )[0] + $TVS_CHECKBOXES ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The image shows the 5 CheckBoxes on Windows 7 with state image indices 1 - 5: TreeView Explorer Theme Example in the Examples\Theme\ folder. Run the example in SciTE with F5. ExplorerTheme.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <WinAPITheme.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - ExplorerTheme", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set Explorer theme _WinAPI_SetWindowTheme( $hTV, "Explorer", 0 ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The Explorer theme on Windows 7. Looks better on Windows 10. 7z-file The 7z-file contains source code for UDFs 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. TreeViewStyles.7z