Leaderboard
Popular Content
Showing content with the highest reputation on 09/05/2019 in all areas
-
The GUI looks like shown in the picture: It contains a main menu, a treeview in left pane that lists UI Automation elements, a listview in right pane that displays detail information for the selected element, and a splitterbar to adjust the width of the two panes. Detect element The "Detect element" main menu is used to detect elements under the mouse with function keys F1 - F4. See How to topics number 2. Left pane The left pane is a treeview that initially lists open programs and windows. Generally, the left pane shows UI Automation elements represented as treeview items. Right pane The right pane is a listview that displays detail information for the selected treeview element. The information is grouped into different types of information. Only the relevant information for each type is displayed. Invalid elements When a window is closed the elements in UIASpy becomes invalid. But the elements are not deleted in UIASpy and can still be handled and selected in the treeview. Detail information for an element that was calculated before the window was closed can still be seen in the listview. In this way it's possible for UIASpy to show information for eg. a context menu that is closed as soon as it loses focus. Listview features Listview features Help system With completion of the Help system, a lot of information has been moved from this post and other posts into the Help system. Sample code creation Sample code creation is implemented through the UI element Detail info listview page and through the Sample code main menu. Sample code creates code snippets based on data in one or more selected rows in the Detail info listview page or based on the clicked Sample code menu item. UI Automation code is largely based on COM interface objects and thus on the function ObjCreateInterface(), which is one of the advanced functions in AutoIt. The main purpose of Sample code functionality is to eliminate the complexity of ObjCreateInterface(). Sample code creation either through the Detail info listview page or through the Sample code main menu can create all the interface objects required in UI Automation code. Another purpose is of course to make it easier and faster to implement code for simple automation tasks. Through Sample code creation, you can more or less create all code in a simple automation task: Create UI Automation initial code Create condition and find application window Create condition and find control in window Get information about windows and controls Create pattern objects to perform actions Get information related to pattern objects Perform actions with pattern object methods Add a Sleep() statement if necessary Note that the UI element used in sample code is named after the selected element in the treeview. Also note that both the Sample code menu items and the sections in the Detail info listview page are placed in approximately the order they are used in a simple automation task. Sample code creation through Detail info listview page Sample code creation through Sample code main menu Supported applications Most browsers including Google Chrome To be able to spy on web content in Google Chrome it's necessary to enable accessibility by entering chrome://accessibility/ in the address bar of a new tab item, and then check the five check boxes that are located in a column in upper left corner down along the left edge. Then the accessibility tab can be closed again. It's a global setting that applies to all open and new tabs until Chrome is closed. Without accessibility enabled you are only able to investigate the outer elements of Chrome but not web content. Internet Explorer Microsoft Edge Mozilla Firefox Most Microsoft applications and applications developed with Microsoft software including Classic Windows applications based on the standard control library Modern Universal Windows Platform apps like the Windows 10 Calculator Programs implemented through .NET Framework eg. Windows Forms applications Most applications provided by major development companies Automation issues Automation issues How to topics If UI Automation or the UIASpy tool is new to you, then you should read the How to topics. Examples Examples that demonstrates the features of UIASpy: Automating Notepad. Very detailed example. Automating Notepad - Windows XP Examples about Sample code creation: Automating Notepad with Sample code - step by step Automating Notepad with Sample code - all at once Chrome - Clicking an extension. Compact summary example. Click Save As... issue in Notepad examples: Using Expand() instead of Invoke() Updates Windows 8, Windows 8.1 and Windows 10 updates Threads UI Automation UDFs contains all include files. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. UI Automation Events is about implementing event handlers and includes GUIs to detect events. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source files for UIASpy GUI. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. UIASpy.7z1 point
-
Hi, This UDF originaly started in this thread, on the latest post you can find rasim's examples and my initial BlockInputEx udf example. But eventualy i improved the UDF and i thought that it would be better to place it here, in Examples forum. This UDF supports few features that built-in BlockInput() function does not. Here is a quick "features list" if you can call it like this : Block seperately mouse or keyboard input.Block specific keyboard/mouse keys/clicks. [+] Not only hex keys are supported, string keys (such as {ENTER}) is also valid.Block all keyboard/mouse keys *except* specific keys/events.Block keys by CLASS Name (see UDF documentation).Block inputs only for specific window.BlockInput does not re-enables input after pressing Ctrl+Alt+Del.Note: This UDF, same as built-in BlockInput function, can not block Ctrl+Alt+Del, however, it will not re-enable the input. Example #1 (hWindows usage): #include <BlockInputEx.au3> ;================== hWindows usage Example ================== HotKeySet("{ESC}", "_Quit") ;This will trigger an exit (on any window except the window of Notepad). Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE) WinWait("[REGEXPCLASS:Notepad.*]") $hNotepad_Wnd = WinGetHandle("[REGEXPCLASS:Notepad.*]") ControlSetText($hNotepad_Wnd, "", "", _ "Now try to input some keys in here..." & @CRLF & _ "Well, that's the idea, you can't, don't you?" & @CRLF & @CRLF & ":)") ;Here we block *All* keyboard keys for specific window (in this case the Notepad's window). _BlockInputEx(3, "", "", $hNotepad_Wnd) ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncExample #2 (CLASSes usage): #include <BlockInputEx.au3> ;================== CLASSes usage Example ================== HotKeySet("{ESC}", "_Quit");This will trigger an exit ;Here we block Numeric keyboard keys, "Test" string (every char in this group), and UP / DOWN arrow keys. _BlockInputEx(3, "", "[:NUMBER:]|[Test]|{UP}|{DOWN}") ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncDownload (In the archive there is 11 nice examples including the two above): BlockInputEx_UDF_1.8.zip BlockInputEx_UDF_1.6.zip _BlockInputEx_UDF_1.5.zip _BlockInputEx_UDF_1.4.zip _BlockInputEx_UDF_1.3.zip _BlockInputEx_UDF_1.2.zip _BlockInputEx_UDF_1.1.zip _BlockInputEx_UDF.zip Enjoy! ================================================================= ChangeLog:1 point
-
Exe server (IDispatch Call)
argumentum reacted to wolf9228 for a topic
Exe server (IDispatch Call) http://msdn.microsoft.com/en-us/library/windows/desktop/ms683835(v=vs.85).aspx ;There are two main types of servers, in-process and out-of-process. In-process servers are implemented in a ;dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process ;servers can reside either on the local computer or on a remote computer. In addition, COM provides a mechanism that ;allows an in-process server (a DLL) to run in a surrogate EXE process to gain the advantage of being able to run the ;process on a remote computer. For more information, see DLL Surrogates. All project files Exe_Server.zip Program.au3 #include "Server32.au3" #include <Array.au3> StartRun() Func ProgramMain() $pDisp = DispatchCServerCreate() $Return = DispCall($pDisp,"long","Server_DataTypeA",$DISPATCH_METHOD,"BYTE",1,"BYTE*",0,"BOOLEAN",2,"BOOLEAN*",0,"SHORT",3, _ "SHORT*",0,"USHORT",4,"USHORT*",0,"WORD",5,"WORD*",0,"INT",6,"INT*",0,"LONG",7,"LONG*",0,"BOOL",True,"BOOL*",0,"UINT",8, _ "UINT*",0,"ULONG",9,"ULONG*",0) _ArrayDisplay($Return,"Server_DataTypeA") $LPARAM_IN = _WinAPI_MakeLong(10,20) $WPARAM_IN = _WinAPI_MakeLong(30,40) $Return = DispCall($pDisp,"long","Server_DataTypeB",$DISPATCH_METHOD,"DWORD",1,"DWORD*",0,"INT64",2,"INT64*",0,"UINT64",3, _ "UINT64*",0,"FLOAT",3.4,"FLOAT*",0,"DOUBLE",5.5,"DOUBLE*",0,"LPARAM",$LPARAM_IN,"LPARAM*",0,"WPARAM",$WPARAM_IN,"WPARAM*",0, _ "VBOOL",8,"VBOOL*",0) _ArrayDisplay($Return,"Server_DataTypeB") $Return = DispCall($pDisp,"long","Server_BSTR",$DISPATCH_METHOD,"BSTR",StrToBstr("BSTR_NI"),"BSTR*",0) $BSTR = $Return[2] _ArrayDisplay($Return,"Server_BSTR") MsgBox(0,"BSTR_OUT",BstrToStr($BSTR)) $Variant = DllStructCreate($tagVariant) DllStructSetData($Variant,"vt",GetDataTypeNu("LONG")) SetUnionOfVariant($Variant,"LONG",333) $Return = DispCall($pDisp,"long","Server_VARIANT",$DISPATCH_METHOD,"VARIANT",DllStructGetPtr($Variant)) _ArrayDisplay($Return,"Server_VARIANT") $BSTR = GetUnionOfVariant($Variant,"ptr") MsgBox(0,"VARIANT_OUT",BstrToStr($BSTR)) $ARRAY = SafeArrayCreate("long",1000) $Return = DispCall($pDisp,"long","Server_ARRAY",$DISPATCH_METHOD,"ARRAY",$ARRAY,"ARRAY*",0) $ARRAY_OUT = $Return[2] MsgBox(0,"ARRAY_OUT",$ARRAY_OUT) _ArrayDisplay($Return,"Server_ARRAY") $DoubleTime = GetDoubleTime(2014,1,7,10,3,20,10,0) $Return = DispCall($pDisp,"long","Server_DATE",$DISPATCH_METHOD,"DATE",$DoubleTime,"DATE*",0) $DATE_OUT = $Return[2] $SystemTime = GetSystemTime($DATE_OUT) _ArrayDisplay($SystemTime,"SystemTime") _ArrayDisplay($Return,"Server_DATE") $Return = DispCall($pDisp,"long","Server_CY",$DISPATCH_METHOD,"CY",GetCurrencyInt64(30,40),"CY*",0) $CY_OUT = $Return[2] $CurrencyStruct = GetCurrencyStruct($CY_OUT) $MsgText = "Server_CY" & @CRLF & @CRLF $MsgText &= "Lo = " & DllStructGetData($CurrencyStruct,1) & @CRLF $MsgText &= "Hi = " & DllStructGetData($CurrencyStruct,2) & @CRLF MsgBox(0,"CY_OUT",$MsgText) $DECIMAL = DllStructCreate($tagDEC) ;-------------- Set In ----------- DllStructSetData($DECIMAL,2,2) DllStructSetData($DECIMAL,3,3) DllStructSetData($DECIMAL,4,4) DllStructSetData($DECIMAL,5,5) DllStructSetData($DECIMAL,6,6) ;-------------- Set In ----------- $Return = DispCall($pDisp,"long","Server_DECIMAL",$DISPATCH_METHOD,"DECIMAL",DllStructGetPtr($DECIMAL)) $MsgText = "Server_DECIMAL" & @CRLF & @CRLF $MsgText &= "scale = " & DllStructGetData($DECIMAL,2) & @CRLF $MsgText &= "sign = " & DllStructGetData($DECIMAL,3) & @CRLF $MsgText &= "Hi32 = " & DllStructGetData($DECIMAL,4) & @CRLF $MsgText &= "Lo32 = " & DllStructGetData($DECIMAL,5) & @CRLF $MsgText &= "Mid32 = " & DllStructGetData($DECIMAL,6) & @CRLF MsgBox(0,"DECIMAL_OUT",$MsgText) Exit While True WEnd EndFunc Func StartRun() CoInitializeEx(0,0) if ($CmdLine[0]) Then $Command = $CmdLine[1] if ($Command == "ServerRun") Then ServerMain() Exit EndIf EndIf ProgramMain() Exit EndFunc Func ServerRun($TimeOut) if (IsServerReady()) Then Return True if (@Compiled) Then Run(FileGetShortName(@AutoItExe) & " ServerRun") Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath) & " ServerRun") EndIf $begin = TimerInit() While ($TimeOut > TimerDiff($begin)) $IsServerReady = IsServerReady() if ($IsServerReady) Then ExitLoop WEnd Return $IsServerReady EndFunc Func IsServerReady() $IFactory = CoGetClassObject($CServeClsid,$CLSCTX_LOCAL_SERVER,0,$IID_IClassFactory) ; Get ClassFactory if @error Then Return False InterfaceCall($IFactory,"long",3) ; Release Return True EndFunc Func DispatchCServerCreate() ServerRun(5000) $IFactory = CoGetClassObject($CServeClsid,$CLSCTX_LOCAL_SERVER,0,$IID_IClassFactory) ; Get ClassFactory if @error Then Return SetError(1,0,0) $Return = InterfaceCall($IFactory,"long",4,"ptr",0,"struct*",$IID_IDispatch,"ptr*",0) ; Call Factory_CreateInstance is Nu 4 if @error Or ($Return[0] <> 0) Then Return SetError(2,0,0) $pDisp = $Return[3] Return $pDisp EndFunc Server32.au3 #include "Class_Interface.au3" #include "TypeInfo.au3" #include <Array.au3> Global $TypeInfo = 0 Global $CServeClsid = CLSIDFromString("{B331A1D3-F796-4A60-B429-7A911142EA54}") Global $IID_IClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}") Global $IID_IDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}") Func ServerMain() $TypeInfo = MakeCServerTypeInfo() if @error Then Exit $FactoryPtr = NewIClassFactory() if @error Then Exit $dwRegister = CoRegisterClassObject($CServeClsid,$FactoryPtr,$CLSCTX_LOCAL_SERVER,$REGCLS_MULTIPLEUSE) if @error Then Exit While True WEnd EndFunc Func NewIClassFactory() Local $tagIClassFactory = "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;" & _ "ULONG_PTR CreateInstance;ULONG_PTR LockServer;UINT AddRefCount" $FactoryPtr = NewClass($tagIClassFactory) if @error Then Return SetError(1,0,0) SetClassMethod($FactoryPtr,"QueryInterface","Factory_QueryInterface","long","ptr;ptr;ptr") if @error Then Return SetError(2,0,0) SetClassMethod($FactoryPtr,"AddRef","Factory_AddRef","long","ptr") if @error Then Return SetError(3,0,0) SetClassMethod($FactoryPtr,"Release","Factory_Release","long","ptr") if @error Then Return SetError(4,0,0) SetClassMethod($FactoryPtr,"CreateInstance","Factory_CreateInstance","long","ptr;ptr;ptr;ptr") if @error Then Return SetError(5,0,0) SetClassMethod($FactoryPtr,"LockServer","Factory_LockServer","long","ptr;bool") if @error Then Return SetError(6,0,0) Factory_AddRef($FactoryPtr) Return $FactoryPtr EndFunc Func NewCServe() Local $tagServerClass = "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;" & _ "ULONG_PTR GetTypeInfoCount;ULONG_PTR GetTypeInfo;ULONG_PTR GetIDsOfNames;ULONG_PTR Invoke;" & _ "ULONG_PTR DataTypeA;ULONG_PTR DataTypeB;ULONG_PTR BSTR;ULONG_PTR VARIANT;ULONG_PTR ARRAY;" & _ "ULONG_PTR DATE;ULONG_PTR CY;ULONG_PTR DECIMAL;UINT AddRefCount" $ServerPtr = NewClass($tagServerClass) if @error Then Return SetError(1,0,0) SetClassMethod($ServerPtr,"QueryInterface","Server_QueryInterface","long","ptr;ptr;ptr") if @error Then Return SetError(2,0,0) SetClassMethod($ServerPtr,"AddRef","Server_AddRef","long","ptr") if @error Then Return SetError(3,0,0) SetClassMethod($ServerPtr,"Release","Server_Release","long","ptr") if @error Then Return SetError(4,0,0) SetClassMethod($ServerPtr,"GetTypeInfoCount","Server_GetTypeInfoCount","long","ptr;ptr") if @error Then Return SetError(5,0,0) SetClassMethod($ServerPtr,"GetTypeInfo","Server_GetTypeInfo","long","ptr;long;dword;ptr") if @error Then Return SetError(6,0,0) SetClassMethod($ServerPtr,"GetIDsOfNames","Server_GetIDsOfNames","long","ptr;ptr;ptr;long;dword;ptr") if @error Then Return SetError(7,0,0) SetClassMethod($ServerPtr,"Invoke","Server_Invoke","long","ptr;long;ptr;dword;word;ptr;ptr;ptr;ptr") if @error Then Return SetError(8,0,0) $MRegDataType = "PTR;BYTE;PTR;BOOLEAN;PTR;SHORT;PTR;USHORT;PTR;WORD;PTR;INT;PTR;LONG;PTR;BOOL;PTR;UINT;PTR;ULONG;PTR" SetClassMethod($ServerPtr,"DataTypeA","Server_DataTypeA","long",$MRegDataType) if @error Then Return SetError(9,0,0) $MRegDataType = "PTR;DWORD;PTR;INT64;PTR;UINT64;PTR;FLOAT;PTR;DOUBLE;PTR;LPARAM;PTR;WPARAM;PTR;SHORT;PTR" SetClassMethod($ServerPtr,"DataTypeB","Server_DataTypeB","long",$MRegDataType) if @error Then Return SetError(10,0,0) SetClassMethod($ServerPtr,"BSTR","Server_BSTR","long","PTR;PTR;PTR") if @error Then Return SetError(11,0,0) SetClassMethod($ServerPtr,"VARIANT","Server_VARIANT","long","PTR;PTR") if @error Then Return SetError(12,0,0) SetClassMethod($ServerPtr,"ARRAY","Server_ARRAY","long","PTR;PTR;PTR") if @error Then Return SetError(13,0,0) SetClassMethod($ServerPtr,"DATE","Server_DATE","long","PTR;double;PTR") if @error Then Return SetError(14,0,0) SetClassMethod($ServerPtr,"CY","Server_CY","long","PTR;INT64;PTR") if @error Then Return SetError(15,0,0) SetClassMethod($ServerPtr,"DECIMAL","Server_DECIMAL","long","PTR;PTR") if @error Then Return SetError(16,0,0) Server_AddRef($ServerPtr) Return $ServerPtr EndFunc Func MakeCServerTypeInfo() $InterfaceDataSt = MakeInterfaceData(15) MakeMethodData($InterfaceDataSt,1,"Server_QueryInterface",2,"long") MakeMethodData($InterfaceDataSt,2,"Server_AddRef",0,"long") MakeMethodData($InterfaceDataSt,3,"Server_Release",0,"long") MakeMethodData($InterfaceDataSt,4,"Server_GetTypeInfoCount",1,"long") MakeMethodData($InterfaceDataSt,5,"Server_GetTypeInfo",3,"long") MakeMethodData($InterfaceDataSt,6,"Server_GetIDsOfNames",5,"long") MakeMethodData($InterfaceDataSt,7,"Server_Invoke",8,"long") MakeMethodData($InterfaceDataSt,8,"Server_DataTypeA",20,"long") MakeMethodData($InterfaceDataSt,9,"Server_DataTypeB",16,"long") MakeMethodData($InterfaceDataSt,10,"Server_BSTR",2,"long") MakeMethodData($InterfaceDataSt,11,"Server_VARIANT",1,"long") MakeMethodData($InterfaceDataSt,12,"Server_ARRAY",2,"long") MakeMethodData($InterfaceDataSt,13,"Server_DATE",2,"long") MakeMethodData($InterfaceDataSt,14,"Server_CY",2,"long") MakeMethodData($InterfaceDataSt,15,"Server_DECIMAL",1,"long") MakeParamData($InterfaceDataSt,1,"ptr","riid","ptr","ppvObject") MakeParamData($InterfaceDataSt,4,"ptr","pctinfo") MakeParamData($InterfaceDataSt,5,"long","itinfo","DWORD","lcid","ptr","pptinfo") MakeParamData($InterfaceDataSt,6,"ptr","riid","ptr","rgszNames","long","cNames","DWORD","lcid","ptr","rgdispid") MakeParamData($InterfaceDataSt,7,"ptr","dispidMember","ptr","riid","DWORD","lcid","WORD","wFlags", _ "ptr","pdispParams","ptr","pvarResult","ptr","pExcepInfo","ptr","puArgErr") MakeParamData($InterfaceDataSt,8,"BYTE","BYTE_IN","BYTE*","BYTE_OUT","BOOLEAN","BOOLEAN_IN","BOOLEAN*","BOOLEAN_OUT" _ ,"SHORT","SHORT_IN","SHORT*","SHORT_OUT","USHORT","USHORT_IN","USHORT*","USHORT_OUT","WORD","WORD_IN","WORD*","WORD_OUT" _ ,"INT","INT_IN","INT*","INT_OUT","LONG","LONG_IN","LONG*","LONG_OUT","BOOL","BOOL_IN","BOOL*","BOOL_OUT","UINT","UINT_IN", _ "UINT*","UINT_OUT","ULONG","ULONG_IN","ULONG*","ULONG_OUT") MakeParamData($InterfaceDataSt,9,"DWORD","DWORD_IN","DWORD*","DWORD_OUT","INT64","INT64_IN","INT64*","INT64_OUT","UINT64", _ "UINT64_IN","UINT64*","UINT64_OUT","FLOAT","FLOAT_IN","FLOAT*","FLOAT_OUT","DOUBLE","DOUBLE_IN","DOUBLE*","DOUBLE_OUT", _ "LPARAM","LPARAM_IN","LPARAM*","LPARAM_OUT","WPARAM","WPARAM_IN","WPARAM*","WPARAM_OUT","VBOOL","VBOOL_IN","VBOOL*","VBOOL_OUT") MakeParamData($InterfaceDataSt,10,"BSTR","BSTR_IN","BSTR*","BSTR_OUT") MakeParamData($InterfaceDataSt,11,"VARIANT","VARIANT_IN_OUT") MakeParamData($InterfaceDataSt,12,"ARRAY","ARRAY_IN","ARRAY*","ARRAY_OUT") MakeParamData($InterfaceDataSt,13,"DATE","DATE_IN","DATE*","DATE_OUT") MakeParamData($InterfaceDataSt,14,"CY","CY_IN","CY*","CY_OUT") MakeParamData($InterfaceDataSt,15,"DECIMAL","DECIMAL_IN_OUT") $TypeInfo = CreateDispTypeInfo($InterfaceDataSt) if @error Then Return SetError(1,0,0) Return $TypeInfo EndFunc Func Factory_QueryInterface($Interface,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if IsEqualIID($riid,"{00000000-0000-0000-C000-000000000046}") _ ; IUnknown Or IsEqualIID($riid,"{00000001-0000-0000-C000-000000000046}") Then ; IClassFactory SetOut("ULONG_PTR",$ppvObject,$Interface) Else Return 0x80004002 ; E_NOINTERFACE EndIf Factory_AddRef($Interface) Return 0 ; NOERROR EndFunc Func Factory_AddRef($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") + 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) Return $AddRefCount EndFunc Func Factory_Release($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") - 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) if ($AddRefCount = 0) Then DeleteClass($Interface) Return $AddRefCount EndFunc Func Factory_CreateInstance($Interface,$pUnkOuter,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if ($pUnkOuter) Then Return 0x80040110 ;CLASS_E_NOAGGREGATION $ServerPtr = NewCServe() if Not($ServerPtr) Then Return 0x80000002 ;E_OUTOFMEMORY $hr = InterfaceCall($ServerPtr,"long",1,"ptr",$riid,"ptr",$ppvObject) ; QueryInterface $hr = $hr[0] Server_Release($ServerPtr) Return $hr EndFunc Func Factory_LockServer($Interface,$fLock) Return 0 ; NOERROR EndFunc Func Server_QueryInterface($Interface,$riid,$ppvObject) if ($ppvObject = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ULONG_PTR",$ppvObject,0) if IsEqualIID($riid,"{00000000-0000-0000-C000-000000000046}") _ ; IUnknown Or IsEqualIID($riid,"{00020400-0000-0000-C000-000000000046}") Then ; IDispatch SetOut("ULONG_PTR",$ppvObject,$Interface) Else Return 0x80004002 ; E_NOINTERFACE EndIf Server_AddRef($Interface) Return 0 ; NOERROR EndFunc Func Server_AddRef($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") + 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) Return $AddRefCount EndFunc Func Server_Release($Interface) $AddRefCount = (ClassGetData($Interface,"AddRefCount") - 1) ClassSetData($Interface,"AddRefCount",$AddRefCount) if ($AddRefCount = 0) Then DeleteClass($Interface) Return $AddRefCount EndFunc Func Server_GetTypeInfoCount($Interface,$pctinfo) if ($pctinfo = 0) Then Return 0x80000001 ;E_NOTIMPL SetOut("UINT",$pctinfo,1) Return 0 ; NOERROR EndFunc Func Server_GetTypeInfo($Interface,$itinfo,$lcid,$pptinfo) if ($pptinfo = 0) Then Return 0x80070057 ;E_INVALIDARG SetOut("ptr",$pptinfo,0) if ($itinfo <> 0) Then Return 0x8002000B ; DISP_E_BADINDEX InterfaceCall($TypeInfo,"long",2) ; AddRef SetOut("ptr",$pptinfo,$TypeInfo) Return 0 ; NOERROR EndFunc Func Server_GetIDsOfNames($Interface,$riid,$rgszNames,$cNames,$lcid,$rgdispid) $hr = DllCall($OleAut32,"long","DispGetIDsOfNames","ptr",$TypeInfo,"ptr",$rgszNames,"long",$cNames,"ptr",$rgdispid) $hr = $hr[0] Return $hr EndFunc Func Server_Invoke($Interface,$dispidMember,$riid,$lcid,$wFlags,$pdispParams,$pvarResult,$pExcepInfo,$puArgErr) $hr = DllCall($OleAut32,"long","DispInvoke","ptr",$Interface,"ptr",$TypeInfo,"int",$dispidMember,"WORD",$wFlags _ ,"ptr",$pdispParams,"ptr",$pvarResult,"ptr",$pExcepInfo,"ptr",$puArgErr) $hr = $hr[0] Return $hr EndFunc Func Server_DataTypeA($Interface,$BYTE_IN,$BYTE_OUT,$BOOLEAN_IN,$BOOLEAN_OUT,$SHORT_IN,$SHORT_OUT,$USHORT_IN,$USHORT_OUT _ ,$WORD_IN,$WORD_OUT,$INT_IN,$INT_OUT,$LONG_IN,$LONG_OUT,$BOOL_IN,$BOOL_OUT,$UINT_IN,$UINT_OUT,$ULONG_IN,$ULONG_OUT) SetOut("BYTE",$BYTE_OUT,1) SetOut("BOOLEAN",$BOOLEAN_OUT,True) SetOut("SHORT",$SHORT_OUT,2) SetOut("USHORT",$USHORT_OUT,4) SetOut("WORD",$WORD_OUT,5) SetOut("INT",$INT_OUT,6) SetOut("LONG",$LONG_OUT,7) SetOut("BOOL",$BOOL_OUT,False) SetOut("UINT",$UINT_OUT,8) SetOut("ULONG",$ULONG_OUT,9) $MsgText = "Server_DataTypeA" & @CRLF & @CRLF $MsgText &= "BYTE_IN ==> " $MsgText &= $BYTE_IN & @CRLF $MsgText &= "BOOLEAN_IN ==> " $MsgText &= $BOOLEAN_IN & @CRLF $MsgText &= "SHORT_IN ==> " $MsgText &= $SHORT_IN & @CRLF $MsgText &= "USHORT_IN ==> " $MsgText &= $USHORT_IN & @CRLF $MsgText &= "WORD_IN ==> " $MsgText &= $WORD_IN & @CRLF $MsgText &= "INT_IN ==> " $MsgText &= $INT_IN & @CRLF $MsgText &= "LONG_IN ==> " $MsgText &= $LONG_IN & @CRLF $MsgText &= "BOOL_IN ==> " $MsgText &= $BOOL_IN & @CRLF $MsgText &= "UINT_IN ==> " $MsgText &= $UINT_IN & @CRLF $MsgText &= "ULONG_IN ==> " $MsgText &= $ULONG_IN & @CRLF MsgBox(0,"Server_DataTypeA",$MsgText) Return 100 EndFunc Func Server_DataTypeB($Interface,$DWORD_IN,$DWORD_OUT,$INT64_IN,$INT64_OUT,$UINT64_IN,$UINT64_OUT,$FLOAT_IN,$FLOAT_OUT,$DOUBLE_IN _ ,$DOUBLE_OUT,$LPARAM_IN,$LPARAM_OUT,$WPARAM_IN,$WPARAM_OUT,$VBOOL_IN,$VBOOL_OUT) SetOut("DWORD",$DWORD_OUT,10) SetOut("INT64",$INT64_OUT,11) SetOut("UINT64",$UINT64_OUT,12) SetOut("FLOAT",$FLOAT_OUT,13.5) SetOut("DOUBLE",$DOUBLE_OUT,14.6) SetOut("LPARAM",$LPARAM_OUT,_WinAPI_MakeLong(50, 60)) SetOut("WPARAM",$WPARAM_OUT,_WinAPI_MakeLong(70, 80)) SetOut("SHORT",$VBOOL_OUT,17) $MsgText = "Server_DataTypeB" & @CRLF & @CRLF $MsgText &= "DWORD_IN ==> " $MsgText &= $DWORD_IN & @CRLF $MsgText &= "INT64_IN ==> " $MsgText &= $INT64_IN & @CRLF $MsgText &= "UINT64_IN ==> " $MsgText &= $UINT64_IN & @CRLF $MsgText &= "FLOAT_IN ==> " $MsgText &= $FLOAT_IN & @CRLF $MsgText &= "DOUBLE_IN ==> " $MsgText &= $DOUBLE_IN & @CRLF $MsgText &= "LPARAM_IN ==> " $MsgText &= $LPARAM_IN & @CRLF $MsgText &= "LPARAM_HiWord ==> " $MsgText &= _WinAPI_HiWord($LPARAM_IN) & @CRLF $MsgText &= "LPARAM_LoWord ==> " $MsgText &= _WinAPI_LoWord($LPARAM_IN) & @CRLF $MsgText &= "WPARAM_IN ==> " $MsgText &= $WPARAM_IN & @CRLF $MsgText &= "WPARAM_HiWord ==> " $MsgText &= _WinAPI_HiWord($WPARAM_IN) & @CRLF $MsgText &= "WPARAM_LoWord ==> " $MsgText &= _WinAPI_LoWord($WPARAM_IN) & @CRLF $MsgText &= "SHORT_IN Or VBOOL_IN ==> " $MsgText &= $VBOOL_IN & @CRLF MsgBox(0,"Server_DataTypeB",$MsgText) Return 200 EndFunc Func Server_BSTR($Interface,$BSTR_IN,$BSTR_OUT) SetOut("PTR",$BSTR_OUT,StrToBstr("BSTR_OUT")) MsgBox(0,"BSTR_IN",BstrToStr($BSTR_IN)) Return 400 EndFunc Func Server_VARIANT($Interface,$VARIANT_IN_OUT) $Variant = DllStructCreate($tagVariant,$VARIANT_IN_OUT) $Long = GetUnionOfVariant($Variant,"long") MsgBox(0,"VARIANT_IN",$Long) DllStructSetData($Variant,"vt",GetDataTypeNu("BSTR")) SetUnionOfVariant($Variant,"ptr",StrToBstr("VARIANT_OUT")) Return 500 EndFunc Func Server_ARRAY($Interface,$ARRAY_IN,$ARRAY_OUT) SetOut("PTR",$ARRAY_OUT,SafeArrayCreate("byte",1,1000)) MsgBox(0,"ARRAY_IN",$ARRAY_IN) Return 700 EndFunc Func Server_DATE($Interface,$DATE_IN,$DATE_OUT) $DoubleTime = GetDoubleTime(2014,1,7,10,3,20,10,0) SetOut("double",$DATE_OUT,$DoubleTime) $TimeArray = GetSystemTime($DATE_IN) $MsgText = "Server_DATE" & @CRLF & @CRLF $MsgText &= $TimeArray[0][1] & " = " & $TimeArray[0][0] & @CRLF $MsgText &= $TimeArray[1][1] & " = " & $TimeArray[1][0] & @CRLF $MsgText &= $TimeArray[2][1] & " = " & $TimeArray[2][0] & @CRLF $MsgText &= $TimeArray[3][1] & " = " & $TimeArray[3][0] & @CRLF $MsgText &= $TimeArray[4][1] & " = " & $TimeArray[4][0] & @CRLF $MsgText &= $TimeArray[5][1] & " = " & $TimeArray[5][0] & @CRLF $MsgText &= $TimeArray[6][1] & " = " & $TimeArray[6][0] & @CRLF $MsgText &= $TimeArray[7][1] & " = " & $TimeArray[7][0] MsgBox(0,"DATE_IN",$MsgText) Return 800 EndFunc Func Server_CY($Interface,$CY_IN,$CY_OUT) SetOut("Int64",$CY_OUT,GetCurrencyInt64(10,20)) $CurrencyStruct = GetCurrencyStruct($CY_IN) $MsgText = "Server_CY" & @CRLF & @CRLF $MsgText &= "Lo = " & DllStructGetData($CurrencyStruct,1) & @CRLF $MsgText &= "Hi = " & DllStructGetData($CurrencyStruct,2) & @CRLF MsgBox(0,"CY_IN",$MsgText) Return 900 EndFunc Func Server_DECIMAL($Interface,$DECIMAL_IN_OUT) $DECIMAL = DllStructCreate($tagDEC,$DECIMAL_IN_OUT) $MsgText = "Server_DECIMAL" & @CRLF & @CRLF $MsgText &= "scale = " & DllStructGetData($DECIMAL,2) & @CRLF $MsgText &= "sign = " & DllStructGetData($DECIMAL,3) & @CRLF $MsgText &= "Hi32 = " & DllStructGetData($DECIMAL,4) & @CRLF $MsgText &= "Lo32 = " & DllStructGetData($DECIMAL,5) & @CRLF $MsgText &= "Mid32 = " & DllStructGetData($DECIMAL,6) & @CRLF MsgBox(0,"DECIMAL_IN",$MsgText) ;-------------- Set Out ----------- DllStructSetData($DECIMAL,2,7) DllStructSetData($DECIMAL,3,8) DllStructSetData($DECIMAL,4,9) DllStructSetData($DECIMAL,5,10) DllStructSetData($DECIMAL,6,11) ;-------------- Set Out ----------- Return 1000 EndFunc Class_Interface.au3 #include "Constants.au3" #include "DataType.au3" Func NewClass($tagClass) $ClassStA = DllStructCreate($tagClass) if @error Then Return SetError(1,0,0) $ClassStB = DllStructCreate("ULONG_PTR") if @error Then Return SetError(2,0,0) DllStructSetData($ClassStB,1,DllStructGetPtr($ClassStA)) $ClassStBPtr = DllStructGetPtr($ClassStB) $UBound = (UBound($StOfClassArray) - 1) $StOfClassArray[$UBound][0] = $ClassStA $StOfClassArray[$UBound][1] = $ClassStB $StOfClassArray[$UBound][2] = $ClassStBPtr ReDim $StOfClassArray[$UBound + 2][4] Return $ClassStBPtr EndFunc Func SetClassMethod($ClassStBPtr,$MethodName,$FuncName,$ReturnDataType,$ParamsDataType) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,False) $ClassStA = $StOfClassArray[$Element][0] DllStructGetData($ClassStA,$MethodName) if @error Then Return SetError(2,0,False) $RegCallbackFunc = DllCallbackRegister($FuncName,$ReturnDataType,$ParamsDataType) if Not($RegCallbackFunc) Then Return SetError(3,0,False) $CallbackFuncPtr = DllCallbackGetPtr($RegCallbackFunc) $RegFuncArray = $StOfClassArray[$Element][3] if Not IsArray($RegFuncArray) Then Dim $RegFuncArray[1] Else ReDim $RegFuncArray[(UBound($RegFuncArray) + 1)] EndIf $RegFuncArray[(UBound($RegFuncArray) - 1)] = $RegCallbackFunc $StOfClassArray[$Element][3] = $RegFuncArray DllStructSetData($ClassStA,$MethodName,$CallbackFuncPtr) Return True EndFunc Func ClassSetData($ClassStBPtr,$ElementName,$Value) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,False) $ClassStA = $StOfClassArray[$Element][0] DllStructSetData($ClassStA,$ElementName,$Value) if @error Then Return SetError(2,0,False) Return True EndFunc Func ClassGetData($ClassStBPtr,$ElementName) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,0) $ClassStA = $StOfClassArray[$Element][0] $Value = DllStructGetData($ClassStA,$ElementName) if @error Then Return SetError(2,0,0) Return $Value EndFunc Func ClassGetElementPtr($ClassStBPtr,$ElementName) $Element = FindClassSt($ClassStBPtr) if @error Then Return SetError(1,0,0) $ClassStA = $StOfClassArray[$Element][0] $ElementPtr = DllStructGetPtr($ClassStA,$ElementName) if @error Then Return SetError(2,0,0) Return $ElementPtr EndFunc Func FindClassSt($ClassStBPtr) For $Element = 0 To (UBound($StOfClassArray) - 2) if ($ClassStBPtr = $StOfClassArray[$Element][2]) Then Return $Element Next Return SetError(1,0,-1) EndFunc Func DeleteClass($ClassStBPtr) Local $UBound = UBound($StOfClassArray) Dim $NewStOfClassArray[$UBound][4] Local $iElement = 0 , $TestDelete = False For $Element = 0 To ($UBound - 2) if ($ClassStBPtr = $StOfClassArray[$Element][2]) Then $RegFuncArray = $StOfClassArray[$Element][3] For $nElement = 0 To UBound($RegFuncArray) - 1 $RegCallbackFunc = $RegFuncArray[$nElement] DllCallbackFree($RegCallbackFunc) Next $TestDelete = True Else $NewStOfClassArray[$iElement][0] = $StOfClassArray[$Element][0] $NewStOfClassArray[$iElement][1] = $StOfClassArray[$Element][1] $NewStOfClassArray[$iElement][2] = $StOfClassArray[$Element][2] $NewStOfClassArray[$iElement][3] = $StOfClassArray[$Element][3] $iElement += 1 EndIf Next if ($TestDelete) Then if ($UBound > 1) Then ReDim $NewStOfClassArray[$UBound - 1][4] $StOfClassArray = $NewStOfClassArray Return True Else Return SetError(1,0,False) EndIf EndFunc Func SetOut($DataType,$OutPtr,$SetValue) Return DllStructSetData(DllStructCreate($DataType,$OutPtr),1,$SetValue) EndFunc Func GetOut($DataType,$OutPtr) Return DllStructGetData(DllStructCreate($DataType,$OutPtr),1) EndFunc Func IsEqualIID($IID_A,$IID_B) if Not IsString($IID_A) Then $IID_A = _WinAPI_StringFromGUID($IID_A) if $IID_A == "" Then Return SetError(1,0,False) Else if Not IsDllStruct(_WinAPI_GUIDFromString($IID_A)) Then Return SetError(1,0,False) EndIf if Not IsString($IID_B) Then $IID_B = _WinAPI_StringFromGUID($IID_B) if $IID_B == "" Then Return SetError(2,0,False) Else if Not IsDllStruct(_WinAPI_GUIDFromString($IID_B)) Then Return SetError(2,0,False) EndIf if ($IID_A == $IID_B) Then Return True Else Return False EndIf EndFunc Func DispCall($pDisp,$RtType,$MemberName,$MemberType,$Type1 = "",$Param1 = 0,$Type2 = "",$Param2 = 0 _ ,$Type3 = "",$Param3 = 0, $Type4 = "", $Param4 = 0,$Type5 = 0 ,$Param5 = 0, $Type6 = "", $Param6 = 0 _ ,$Type7 = "",$Param7 = 0,$Type8 = "", $Param8 = 0,$Type9 = "",$Param9 = 0,$Type10 = "", $Param10 = 0 _ ,$Type11= "",$Param11= 0,$Type12= "", $Param12= 0,$Type13= "",$Param13 = 0,$Type14 = "",$Param14 = 0 _ ,$Type15= "",$Param15= 0,$Type16= "", $Param16= 0,$Type17= "",$Param17 = 0,$Type18 = "",$Param18 = 0 _ ,$Type19= "",$Param19= 0,$Type20= "", $Param20= 0,$Type21= "",$Param21 = 0,$Type22 = "",$Param22 = 0 _ ,$Type23= "",$Param23= 0,$Type24= "", $Param24= 0,$Type25= "",$Param25 = 0,$Type26 = "",$Param26 = 0 _ ,$Type27= "",$Param27= 0,$Type28= "", $Param28= 0,$Type29= "",$Param29 = 0,$Type30 = "",$Param30 = 0) if ((@NumParams > 4) And (Mod((@NumParams - 4),2) <> 0)) Then Return SetError(1,0,0) Local $NumParams = ((@NumParams - 4) / 2) $ptNameSt = DllStructCreate("WCHAR[" & (StringLen($MemberName) + 1) & "]") DllStructSetData($ptNameSt,1,$MemberName) $StArrayName = DllStructCreate("ptr") DllStructSetData($StArrayName,1,DllStructGetPtr($ptNameSt)) $HRESULT = InterfaceCall($pDisp,"long",6,"struct*",$IID_NULL,"struct*",$StArrayName,"UINT",1,"DWORD",0,"long*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(2,0,0) ; Call Server_GetIDsOfNames Is Nu 6 Local $dispID = $HRESULT[5] $rgvarg = DllStructCreate("byte[" & ($VariantSize * $NumParams) & "]") $rgvargPtr = DllStructGetPtr($rgvarg) Local $nReturn[$NumParams + 1][2] , $Variant = 0 , $RtVariant = 0 , $DISPID_PROPERTYPUT = -3 For $i = 0 To $NumParams if ($i = 0) Then $RtVariant = DllStructCreate($tagVariant) $Variant = $RtVariant $Value = "" $DataType = $RtType $DataTypeNu = GetDataTypeNu($DataType) if @error Then Return SetError(3,0,0) Else $Variant = DllStructCreate($tagVariant,$rgvargPtr + (($NumParams - $i) * $VariantSize)) $Value = Eval("Param" & $i) $DataType = Eval("Type" & $i) $DataTypeNu = GetDataTypeNu($DataType) if @error Then Return SetError(3,0,0) EndIf $BOOLREF = @extended $DataType = StringReplace($DataType,"*","") $nReturn[$i][0] = $BOOLREF Switch $DataType Case "BSTR","DISPATCH","UNKNOWN","ARRAY" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",$Value) EndSwitch Case "VARIANT","DECIMAL" if Not IsPtr($Value) Or $Value = Ptr(0) Then Return SetError(4,0,0) $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",$Value) Case "CY" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("INT64") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"INT64",$Value) EndSwitch Case "DATE" Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("double") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"double",$Value) EndSwitch Case "ERROR" ;Scode Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("long") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"long",$Value) EndSwitch Case "VBOOL" ;VARIANT_BOOL short A 16-bit ;typedef short VARIANT_BOOL; Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef("short") SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"short",$Value) EndSwitch Case Else Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef($DataType) SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,$DataType,$Value) EndSwitch EndSwitch DllStructSetData($Variant,"vt",$DataTypeNu) Next $DISPPARAMS = DllStructCreate($tagDISPPARAMS) DllStructSetData($DISPPARAMS,"cArgs",$NumParams) DllStructSetData($DISPPARAMS,"rgvarg",$rgvargPtr) if BitAND($MemberType,$DISPATCH_PROPERTYPUT) Then $rgdispidNamedArgsSt = DllStructCreate("long") DllStructSetData($rgdispidNamedArgsSt,1,$DISPID_PROPERTYPUT) DllStructSetData($DISPPARAMS,"rgdispidNamedArgs",DllStructGetPtr($rgdispidNamedArgsSt)) DllStructSetData($DISPPARAMS,"cNamedArgs",1) EndIf $HRESULT = InterfaceCall($pDisp,"long",7,"long",$dispID,"struct*",$IID_NULL,"DWORD",0, _ "WORD",$MemberType,"struct*",$DISPPARAMS,"struct*",$RtVariant,"ptr*",0,"UINT*",0) ; Call Server_Invoke Is Nu 7 if @error Or $HRESULT[0] <> 0 Then Return SetError(5,0,0) Local $vReturn[($NumParams + 1)] For $i = 0 To $NumParams $BOOLREF = $nReturn[$i][0] $Value = $nReturn[$i][1] if ($i = 0) Then if ($BOOLREF) Then if IsDllStruct($Value) Then $Value = GetByRefValue($Value) $vReturn[$i] = $Value Else $vReturn[$i] = GetUnionOfVariant($RtVariant,$RtType) EndIf Else if ($BOOLREF) Then if IsDllStruct($Value) Then $Value = GetByRefValue($Value) $vReturn[$i] = $Value Else $vReturn[$i] = $Value EndIf EndIf Next Return $vReturn EndFunc Func InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0,$Type2 = 0,$Param2 = 0 _ ,$Type3 = 0,$Param3 = 0, $Type4 = 0,$Param4 = 0 ,$Type5 = 0 ,$Param5 = 0,$Type6 = 0,$Param6 = 0 _ ,$Type7 = 0,$Param7 = 0, $Type8 = 0,$Param8 = 0,$Type9 = 0,$Param9 = 0,$Type10 = 0,$Param10 = 0 _ ,$Type11= 0,$Param11= 0,$Type12= 0,$Param12= 0,$Type13= 0,$Param13 = 0,$Type14 = 0,$Param14 = 0 _ ,$Type15= 0,$Param15= 0,$Type16= 0,$Param16= 0,$Type17= 0,$Param17 = 0,$Type18 = 0,$Param18 = 0 _ ,$Type19= 0,$Param19= 0,$Type20= 0,$Param20= 0,$Type21= 0,$Param21 = 0,$Type22 = 0,$Param22 = 0 _ ,$Type23= 0,$Param23= 0,$Type24= 0,$Param24= 0,$Type25= 0,$Param25 = 0,$Type26 = 0,$Param26 = 0 _ ,$Type27= 0,$Param27= 0,$Type28= 0,$Param28= 0,$Type29= 0,$Param29 = 0,$Type30 = 0,$Param30 = 0) ;;Return Array Of DllCallAddress ;Only Call Virtual Method Form any Class Or From any Interface ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) ;See the examples ;-------------------------------------------------------------------;C++ Example1 ;C++ Example1 ;class iClass ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;void MethodB() ;{ ;MessageBox(0,"MethodB","MSG",0); ;} ;virtual void VirtualMethodA() ;{ ;MessageBox(0,"VirtualMethodA","MSG",0); ;} ;}; ;-----------------------------------------------------------;Virtual Methods Table ;Virtual Methods Table ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;virtual void VirtualMethodA() ==> Virtual Method Number Is 3 ;-----------------------------------------------------------;Virtual Methods Table ;-------------------------------------------------------------------;C++ Example1 ;//////////////////////////////////////////////////////////////////////////////// ;-------------------------------------------------------------------;C++ Example2 ;C++ Example2 ;class iClassA ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;}; ;class iClassB : public iClassA ;{ ;public: ;void MethodD() ;{ ;MessageBox(0,"MethodD","MSG",0); ;} ;virtual void VirtualMethodF() ;{ ;MessageBox(0,"VirtualMethodF","MSG",0); ;} ;virtual void VirtualMethodE() ;{ ;MessageBox(0,"VirtualMethodE","MSG",0); ;} ;}; ;//////////////////////////////////////////////////////////////////////////////// ;//////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassA Class ;Virtual Methods Table Of iClassA Class ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;------------------------------------------;Virtual Methods Table Of iClassA Class ;//////////////////////////////////////////////////////////////////////////////// ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassB Class ;class iClassB : public iClassA ;base class ==> iClassA ;derived class ==> iClassB ;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx ;When preceding the name of a base class, the public keyword specifies that the public ;and protected members of the base class are public and protected members, respectively, ;of the derived class. ;------------------------------------------------------------------------------------- ;Virtual Methods Table Of iClassB Class ;virtual void VirtualMethodB() In (iClassA) ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() In (iClassA) ==> Virtual Method Number Is 2 ;virtual void VirtualMethodF() In (iClassB) ==> Virtual Method Number Is 3 ;virtual void VirtualMethodE() In (iClassB) ==> Virtual Method Number Is 4 ;------------------------------------------;Virtual Methods Table Of iClassB Class ;-------------------------------------------------------------------;C++ Example2 ;//////////////////////////////////////////////////////////////////////////////// if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) if (@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0) Then Return SetError(2,0,0) Local $iMethAddress = GetMethodAddress($Inface,$MethodNum) if Not ($iMethAddress) Then Return SetError(3,0,0) Local $iDataType = "",$iFuncParam = "",$iCommand = "",$iReturn = 0 ;Why use Inface Param In DllCallAddress Function Because the Function of the method ;starts from the (Interface Or class) ;See here ;int class::MethodFunction( int Param ){return 0;}; $iCommand = 'DllCallAddress("' & $ReturnType & '",Eval("iMethAddress"),"ptr",Eval("Inface"),' For $i = 1 To ((@NumParams - 3) / 2) $iDataType = Eval("Type" & $i) $iCommand &= '"' & $iDataType & '",' $iFuncParam = 'Eval("Param' & $i & '"),' $iCommand &= $iFuncParam Next $iCommand = StringTrimRight($iCommand,1) $iCommand &= ")" $iReturn = Execute($iCommand) if @error Then Return SetError(4,0,0) Local $nReturn[UBound($iReturn) -1] , $j = 0 For $i = 0 To UBound($iReturn) - 1 if ($i = 1) Then ContinueLoop ;Skip $Inface Element $nReturn[$j] = $iReturn[$i] $j += 1 Next Return SetError(0,0,$nReturn) EndFunc Func GetMethodAddress($Inface,$MethodNum) ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) Local $iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then Return SetError(2,0,0) Return SetError(0,0,$iMethAddress) EndFunc Func GetCount_Of_VirtualMethods($Inface) Local $iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 , $MethodNum = 1 if Not IsPtr($Inface) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- While 1 ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",DllStructGetData($OutCastStruct1,1) + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then $MethodNum -= 1 ExitLoop Else $MethodNum += 1 EndIf WEnd Return SetError(0,0,$MethodNum) EndFunc Func IsBadCodePtr($lpfn) Local $iReturn $iReturn = DllCall("Kernel32.dll","BOOL","IsBadCodePtr","ptr",$lpfn) if @error Then Return SetError(1,0,0) Return SetError(0,0,$iReturn[0]) EndFunc Func GetObjFromGuid($dwClsContext,$StrIID,$StrCLSID) $clsid = CLSIDFromString($StrCLSID) if @error Then Return SetError(2,0,0) $riid = IIDFromString($StrIID) if @error Then Return SetError(3,0,0) $Rt = DllCall($Ole32,"long","CoCreateInstance","ptr",DllStructGetPtr($clsid), _ "ptr",0,"DWORD",$dwClsContext,"ptr",DllStructGetPtr($riid),"ptr*",0) if @error Or $Rt[0] <> 0 Then Return SetError(4,0,$Rt[0]) Return SetError(0,0,$Rt[5]) EndFunc Func CoGetClassObject($rclsid,$dwClsContext,$pServerInfo,$riid) $HRESULT = DllCall($Ole32,"long","CoGetClassObject","struct*",$rclsid, _ "DWORD",$dwClsContext,"ptr",$pServerInfo,"struct*",$riid,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,$HRESULT[0]) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRegisterClassObject($rclsid,$pUnk,$dwClsContext,$flags) $HRESULT = DllCall($Ole32,"long","CoRegisterClassObject","struct*",$rclsid _ ,"ptr",$pUnk,"DWORD",$dwClsContext,"DWORD",$flags,"DWORD*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,$HRESULT[0]) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRegisterPSClsid($riid,$rclsid) $HRESULT = DllCall($Ole32,"long","CoRegisterPSClsid","struct*",$riid,"struct*",$rclsid) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[0]) EndFunc Func CoGetPSClsid($riid) $HRESULT = DllCall($Ole32,"long","CoGetPSClsid","struct*",$riid,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[2]) EndFunc Func CoCreateGuid($ClipPut = False) Local $nGUID = DllStructCreate($tagnGUID) $HRESULT = DllCall($Ole32,"long","CoCreateGuid","struct*",$nGUID) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) if ($ClipPut) Then ClipPut(_WinAPI_StringFromGUID($nGUID)) Return SetError(0,0,_WinAPI_StringFromGUID($nGUID)) EndFunc Func RegisterActiveObject($punk,$rclsid,$dwFlags) $HRESULT = DllCall($Ole32,"long","RegisterActiveObject","ptr",$punk _ ,"struct*",$rclsid,"DWORD",$dwFlags,"DWORD*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$HRESULT[5]) EndFunc Func CoRevokeClassObject($dwRegister) $HRESULT = DllCall($Ole32,"long","CoRevokeClassObject","DWORD",$dwRegister) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,False) Return SetError(0,0,True) EndFunc Func CoInitializeEx($pvReserved,$dwCoInit) $HRESULT = DllCall($Ole32,"int","CoInitializeEx","ptr",$pvReserved,"DWORD",$dwCoInit) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,False) Return SetError(0,0,True) EndFunc Func CLSIDFromString($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","CLSIDFromString","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func IIDFromString($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","IIDFromString","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func CLSIDFromProgID($psz) Local $nGUID = DllStructCreate($tagnGUID) $Oleerror = DllCall($Ole32,"int","CLSIDFromProgID","WSTR",$psz,"struct*",$nGUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$nGUID) EndFunc Func MIDL_DEFINE_GUID($Elm1,$Elm2,$Elm3,$iElm1,$iElm2,$iElm3,$iElm4,$iElm5,$iElm6,$iElm7,$iElm8) $vGUID = DllStructCreate($tagnGUID) DllStructSetData($vGUID,1,$Elm1) DllStructSetData($vGUID,2,$Elm2) DllStructSetData($vGUID,3,$Elm3) DllStructSetData($vGUID,4,$iElm1,1) DllStructSetData($vGUID,4,$iElm2,2) DllStructSetData($vGUID,4,$iElm3,3) DllStructSetData($vGUID,4,$iElm4,4) DllStructSetData($vGUID,4,$iElm5,5) DllStructSetData($vGUID,4,$iElm6,6) DllStructSetData($vGUID,4,$iElm7,7) DllStructSetData($vGUID,4,$iElm8,8) Return $vGUID EndFunc DataType.au3 #include-once #include "Constants.au3" Func GetDataTypeNu($DataType,$SafeArray_vt = False) ;$SafeArray_vt See SafeArrayCreate Func ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms683835%28v=vs.85%29.aspx ;There are two main types of servers, in-process and out-of-process. In-process servers are implemented in a ;dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process ;servers can reside either on the local computer or on a remote computer. In addition, COM provides a mechanism that ;allows an in-process server (a DLL) to run in a surrogate EXE process to gain the advantage of being able to run the ;process on a remote computer. For more information, see DLL Surrogates. ;(in Exe Server) Ptr Of Proc Or Ptr Of Out Struct Not Allowed Only ;Ptr Of Data Type like (int* DllStructGetPtr(DllStructCreate("int")) ,SHORT* DllStructGetPtr(DllStructCreate("SHORT")) ) or ;((ARRAY A SAFEARRAY pointer),(DISPATCH pointer),(UNKNOWN pointer),(BSTR pointer)) Or ;Ptr Of VARIANT Struct Or Ptr Of DECIMAL Struct ; See code in thes Func ;VARIANT structure ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx ;VARENUM enumeration ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221170%28v=vs.85%29.aspx Local $DataTypeNu , $VT_BYREF = 0x4000 Local $BOOLREF = (StringInStr($DataType,"*") <> 0) $DataType = StringReplace(StringUpper($DataType),"*","") Switch $DataType Case "NONE" $DataTypeNu = 24 Case "BYTE","BOOLEAN" ;Autoit BOOLEAN like BYTE 17 $DataTypeNu = 17 Case "SHORT" $DataTypeNu = 2 Case "USHORT","WORD" $DataTypeNu = 18 Case "INT","LONG","BOOL" ; Autoit BOOL like LONG 22 $DataTypeNu = 22 Case "UINT","ULONG","DWORD" $DataTypeNu = 23 Case "INT64" $DataTypeNu = 20 Case "UINT64" $DataTypeNu = 21 Case "FLOAT" $DataTypeNu = 4 Case "DOUBLE" $DataTypeNu = 5 ;--------------------------------------------------------------------------------------------- ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt. Case "HWND" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "HANDLE" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "LPARAM","INT_PTR","LONG_PTR","LRESULT" ;32 or 64bit signed integer if (@AutoItX64) Then $DataTypeNu = 20 ;VT_I8 Else $DataTypeNu = 3 ;VT_I4 EndIf Case "PTR","UINT_PTR","ULONG_PTR","DWORD_PTR","WPARAM";32 or 64bit unsigned integer if (@AutoItX64) Then $DataTypeNu = 21 ;VT_UI8 Else $DataTypeNu = 19 ;VT_UI4 EndIf ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Case "VBOOL" ;VARIANT_BOOL short A 16-bit ; ;(C++ 6.0 wtypes.h typedef short VARIANT_BOOL) [in,out] ([in] short) or ([out] short pointer (short*)) $DataTypeNu = 11 ;--------------------------------------------------------------------------------------------- Case "BSTR" ;[in,out] See SysAllocString Func ([in] A BSTR pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 8 Case "VARIANT" ;pointer Of VARIANT structure ;[in,out] ([in,out] VARIANT pointer Only) $DataTypeNu = 12 if Not($SafeArray_vt) Then $BOOLREF = True ; (Data Type Of VARIANT structure With ByRef Only) ;( Data Type Of $SafeArray_vt WithOut ByRef Only) See SafeArrayCreate Func Case "ARRAY" ; A SAFEARRAY pointer [in,out] ([in] SAFEARRAY pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 0x2000 Case "DISPATCH" ;Interface [in,out] ([in] DISPATCH pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 9 Case "UNKNOWN" ;Interface [in,out] ([in] UNKNOWN pointer) or ([out] pointer* (Ptr*)) $DataTypeNu = 13 Case "DATE" ;DATE See GetDoubleTime Func [in,out] ([in] double) or ([out] double pointer (double*)) $DataTypeNu = 7 Case "CY" ; Currency See GetCurrencyInt64 Func [in,out] ([in] INT64) or ([out] INT64 pointer (INT64*)) $DataTypeNu = 6 Case "ERROR" ;Scode [in,out] ([in] long) or ([out] long pointer (long*)) $DataTypeNu = 10 Case "DECIMAL" ;DECIMAL See GetDecimalSt Func / pointer Of DECIMAL structure ;[in,out] ([in,out] DECIMAL pointer Only) $DataTypeNu = 14 if Not($SafeArray_vt) Then $BOOLREF = True ; (Data Type Of DECIMAL structure With ByRef Only) ;( Data Type Of $SafeArray_vt WithOut ByRef Only) See SafeArrayCreate Func Case Else Return SetError(1,0,-1) EndSwitch if ($BOOLREF) Then $DataTypeNu = BitOR($VT_BYREF,$DataTypeNu) Return SetError(0,$BOOLREF,$DataTypeNu) EndFunc Func MakByRef($DataType = "ptr") Return DllStructCreate(String($DataType & " ByRef")) EndFunc Func GetByRefValue($ByRefSt) Return DllStructGetData($ByRefSt,1) EndFunc Func SetUnionOfVariant($VariantSt,$DataType,$Value) Return DllStructSetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1,$Value) EndFunc Func GetUnionOfVariant($VariantSt,$DataType) Return DllStructGetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1) EndFunc Func BstrToStr($BSTR,$FreeBstr = True) $BstrLen = SysStringLen($BSTR) if @error Then Return SetError(1,0,"") $StringSt = DllStructCreate("WCHAR[" & ($BstrLen + 1) & "]",$BSTR) $nString = DllStructGetData($StringSt,1) if ($FreeBstr) Then SysFreeString($BSTR) Return SetError(0,$BstrLen,$nString) EndFunc Func StrToBstr($String) Return SetError(@error,0,SysAllocString($String)) EndFunc Func SysAllocString($psz) Local $DataType = "PTR" if IsString($psz) Then $DataType = "WSTR" $BSTR = DllCall($OleAut32,"ptr","SysAllocString",$DataType,$psz) if @error Or $BSTR[0] = 0 Then Return SetError(1,0,0) Return $BSTR[0] ;BSTR Ptr EndFunc Func SysStringLen($psz) $UINT = DllCall($OleAut32,"UINT","SysStringLen","ptr",$psz) if @error Then Return SetError(1,0,0) Return $UINT[0] EndFunc Func SysFreeString($bstrString) DllCall($OleAut32,"none","SysFreeString","ptr",$bstrString) EndFunc Func GetSystemTime($DoubleTime) $lpSystemTime = DllStructCreate($vtagSYSTEMTIME) $BOOL = DllCall($OleAut32,"int","VariantTimeToSystemTime","DOUBLE",$DoubleTime,"struct*",$lpSystemTime) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Local $TimeArray[8][2] $TimeArray[0][1] = "Year" $TimeArray[0][0] = DllStructGetData($lpSystemTime,1) $TimeArray[1][1] = "Month" $TimeArray[1][0] = DllStructGetData($lpSystemTime,2) $TimeArray[2][1] = "DayOfWeek" $TimeArray[2][0] = DllStructGetData($lpSystemTime,3) $TimeArray[3][1] = "Day" $TimeArray[3][0] = DllStructGetData($lpSystemTime,4) $TimeArray[4][1] = "Hour" $TimeArray[4][0] = DllStructGetData($lpSystemTime,5) $TimeArray[5][1] = "Minute" $TimeArray[5][0] = DllStructGetData($lpSystemTime,6) $TimeArray[6][1] = "Secon" $TimeArray[6][0] = DllStructGetData($lpSystemTime,7) $TimeArray[7][1] = "Milliseconds" $TimeArray[7][0] = DllStructGetData($lpSystemTime,8) Return $TimeArray EndFunc Func GetDoubleTime($wYear,$wMonth,$wDayOfWeek,$wDay,$wHour,$wMinute,$wSecond,$wMilliseconds) $SYSTEMTIME = DllStructCreate($vtagSYSTEMTIME) DllStructSetData($SYSTEMTIME,1,$wYear) DllStructSetData($SYSTEMTIME,2,$wMonth) DllStructSetData($SYSTEMTIME,3,$wDayOfWeek) DllStructSetData($SYSTEMTIME,4,$wDay) DllStructSetData($SYSTEMTIME,5,$wHour) DllStructSetData($SYSTEMTIME,6,$wMinute) DllStructSetData($SYSTEMTIME,7,$wSecond) DllStructSetData($SYSTEMTIME,8,$wMilliseconds) $BOOL = DllCall($OleAut32,"int","SystemTimeToVariantTime","struct*",$SYSTEMTIME,"DOUBLE*",0) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) $DoubleTime = $BOOL[2] Return $DoubleTime EndFunc Func GetCurrencyInt64($Lo,$Hi) $StCY = DllStructCreate($tagCY) DllStructSetData($StCY,1,$Lo) DllStructSetData($StCY,2,$Hi) Return DllStructGetData(DllStructCreate("INT64",DllStructGetPtr($StCY)),1) EndFunc Func GetCurrencyStruct($Int64Value) $Int64ValueSt = DllStructCreate("INT64") DllStructSetData($Int64ValueSt,1,$Int64Value) $TempStCY = DllStructCreate($tagCY,DllStructGetPtr($Int64ValueSt)) $StCY = DllStructCreate($tagCY) DllStructSetData($StCY,1,DllStructGetData($TempStCY,1)) DllStructSetData($StCY,2,DllStructGetData($TempStCY,2)) Return $StCY EndFunc Func GetDecimalSt($scale,$sign,$Hi32,$Lo32,$Mid32) $DEC = DllStructCreate($tagDEC) DllStructSetData($DEC,2,$scale) DllStructSetData($DEC,3,$sign) DllStructSetData($DEC,4,$Hi32) DllStructSetData($DEC,5,$Lo32) DllStructSetData($DEC,6,$Mid32) Return $DEC EndFunc Func SafeArrayCreate($DataType,$cElements,$lLbound = 0) ;Array Manipulation Functions ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221145%28v=vs.85%29.aspx $vt = GetDataTypeNu($DataType,True) ;True $SafeArray_vt if @error Then Return SetError(1,0,0) if (@extended or $vt = 0x2000) Then Return SetError(2,0,0) ;(@extended VT_BYREF) (0x2000 VT_ARRAY ==> SAFEARRAY Data Type Number) $SAFEARRAY = DllCall($OleAut32,"ptr","SafeArrayCreate","USHORT",$vt,"UINT",1,"struct*",SABOUND($cElements,$lLbound)) if @error Or $SAFEARRAY[0] = 0 Then Return SetError(3,0,0) Return $SAFEARRAY[0] ;$vt or $DataTypeNu ;The base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the ;variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types ;for the array. All other types are legal. ;cElements ;The number of elements in the dimension. ;lLbound ;The lower bound of the dimension. EndFunc Func SABOUND($cElements,$lLbound) $SAFEARRAYBOUND = DllStructCreate($tagSAFEARRAYBOUND) DllStructSetData($SAFEARRAYBOUND,1,$cElements) DllStructSetData($SAFEARRAYBOUND,2,$lLbound) Return $SAFEARRAYBOUND EndFunc TypeInfo.au3 #include <WinAPI.au3> #include "DataType.au3" Func CreateDispTypeInfo($Struidata) $HRESULT = DllCall($OleAut32,"long","CreateDispTypeInfo","struct*",$Struidata,"DWORD",0,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) $pptinfo = $HRESULT[3] Return $pptinfo EndFunc Func MakeInterfacedata($cMembersCount) if $cMembersCount < 1 Then Return SetError(1,0,0) $AllocMethodData = GetAllocOfMethodsData($cMembersCount) if @error Then Return SetError(2,0,0) $StSize = DllStructGetSize(DllStructCreate($tagInterfacedata)) $LPVOID = CoTaskMemAlloc($StSize) $InterfacedataSt = DllStructCreate($tagInterfacedata,$LPVOID) DllStructSetData($InterfacedataSt,"MethodData",$AllocMethodData) DllStructSetData($InterfacedataSt,"cMembers",$cMembersCount) Return $InterfacedataSt EndFunc Func MakeMethodData(ByRef $InterfacedataSt,$MethodNumber,$MethodName,$ParametersCount,$ReturnType,$CALLCONV = $CC_STDCALL) if ($MethodName == "") Or (Not IsString($MethodName)) Then Return SetError(1,0,False) $vtReturn = GetDataTypeNu($ReturnType) If @error Then Return SetError(2,0,False) $cMembers = DllStructGetData($InterfacedataSt,"cMembers") if $ParametersCount > 30 or $ParametersCount < 0 or $MethodNumber > _ $cMembers Or $MethodNumber < 1 Then Return SetError(3,0,False) $MethodsData = DllStructGetData($InterfacedataSt,"MethodData") $MethodDataSt = GetStructOfMethodsData($MethodNumber,$MethodsData) if @error Then Return SetError(4,0,False) $MethodNameLen = StringLen($MethodName) $AllocszName = AllocFromStruct("WCHAR[" & ($MethodNameLen + 1) & "]") if @error Then Return SetError(5,0,False) $szNameSt = StructFromAlloc($AllocszName,"WCHAR[" & ($MethodNameLen + 1) & "]") if @error Then Return SetError(6,0,False) DllStructSetData($szNameSt,1,$MethodName) Local $ppdata = 0 if ($ParametersCount) Then $ppdata = GetAllocOfParamsData($ParametersCount) DllStructSetData($MethodDataSt,"szName",$AllocszName) ; Alloc METHOD name DllStructSetData($MethodDataSt,"ppdata",$ppdata) ; Alloc Parameters DllStructSetData($MethodDataSt,"dispid",$MethodNumber) ; METHOD Id start from 1 DllStructSetData($MethodDataSt,"iMeth",($MethodNumber - 1)) ;The index of the method in the VTBL start from 0 DllStructSetData($MethodDataSt,"cc",$CALLCONV) ; calling convention DllStructSetData($MethodDataSt,"cArgs",$ParametersCount) ; args for Parameters DllStructSetData($MethodDataSt,"wFlags",$DISPATCH_METHOD) ; METHOD Flag DllStructSetData($MethodDataSt,"vtReturn",$vtReturn) ;Number Of Return Type Return True EndFunc Func MakeParamData(ByRef $InterfacedataSt,$MethodNumber, $ParamType1 = 0,$ParamName1 = 0,$ParamType2 = 0,$ParamName2 = 0, _ $ParamType3 = 0 ,$ParamName3 = 0 , $ParamType4 = 0 , $ParamName4 = 0 , $ParamType5 = 0 , $ParamName5 = 0,$ParamType6 = 0, _ $ParamName6 = 0 ,$ParamType7 = 0 ,$ParamName7 = 0, $ParamType8 = 0 , $ParamName8 = 0 , $ParamType9 = 0 , $ParamName9 = 0, _ $ParamType10 = 0 ,$ParamName10 = 0 ,$ParamType11= 0 ,$ParamName11= 0 ,$ParamType12= 0 , $ParamName12= 0 ,$ParamType13= 0, _ $ParamName13 = 0 ,$ParamType14 = 0 ,$ParamName14 = 0 ,$ParamType15= 0 ,$ParamName15= 0 , $ParamType16= 0,$ParamName16= 0, _ $ParamType17= 0 ,$ParamName17 = 0 ,$ParamType18 = 0 ,$ParamName18 = 0 ,$ParamType19= 0 ,$ParamName19= 0 ,$ParamType20= 0, _ $ParamName20= 0 ,$ParamType21= 0 ,$ParamName21 = 0 ,$ParamType22 = 0 ,$ParamName22 = 0 ,$ParamType23= 0 ,$ParamName23= 0, _ $ParamType24= 0 ,$ParamName24= 0 ,$ParamType25= 0 ,$ParamName25 = 0 ,$ParamType26 = 0 ,$ParamName26 = 0 ,$ParamType27= 0, _ $ParamName27= 0 , $ParamType28= 0 ,$ParamName28= 0 ,$ParamType29= 0 ,$ParamName29 = 0 ,$ParamType30 = 0,$ParamName30 = 0 ) Local $ParametersCount = ((@NumParams - 2)/2) if (@NumParams > 2) And (Mod((@NumParams - 2),2) <> 0) Then Return SetError(1,0,False) $cMembers = DllStructGetData($InterfacedataSt,"cMembers") if $MethodNumber > $cMembers Or $MethodNumber < 1 Then Return SetError(2,0,False) $MethodsData = DllStructGetData($InterfacedataSt,"MethodData") $MethodDataSt = GetStructOfMethodsData($MethodNumber,$MethodsData) if @error Then Return SetError(3,0,False) $cArgs = DllStructGetData($MethodDataSt,"cArgs") if ($cArgs <> $ParametersCount) Then Return SetError(4,0,False) if $ParametersCount = 0 And $cArgs = 0 Then Return True $ppdata = DllStructGetData($MethodDataSt,"ppdata") ; Test Loop For $i = 1 To $ParametersCount $ParamType = Eval("ParamType" & $i) $ParamName = Eval("ParamName" & $i) GetDataTypeNu($ParamType) if @error Then Return SetError(5,0,False) if ($ParamName == "" Or (Not IsString($ParamName))) Then Return SetError(6,0,False) $ParamDataSt = GetStructOfParamsData($ppdata,$i) if @error Then Return SetError(7,0,False) Next For $i = 1 To $ParametersCount $ParamType = Eval("ParamType" & $i) $ParamTypeNu = GetDataTypeNu($ParamType) $ParamName = Eval("ParamName" & $i) $ParamNameLen = StringLen($ParamName) $AllocName = AllocFromStruct("WCHAR[" & ($ParamNameLen + 1) & "]") $szNameSt = StructFromAlloc($AllocName,"WCHAR[" & ($ParamNameLen + 1) & "]") DllStructSetData($szNameSt,1,$ParamName) $ParamDataSt = GetStructOfParamsData($ppdata,$i) DllStructSetData($ParamDataSt,"szName",$AllocName) ; Alloc Param name DllStructSetData($ParamDataSt,"vt",$ParamTypeNu) ;Number Of Param Type Next Return True EndFunc Func GetAllocOfMethodsData($cMembers) if $cMembers < 1 Then Return SetError(1,0,0) $MethodsDataSize = (DllStructGetSize(DllStructCreate($tagMethodData)) * $cMembers) if Not($MethodsDataSize) Then Return SetError(2,0,0) $LPVOID = CoTaskMemAlloc($MethodsDataSize) Return $LPVOID EndFunc Func GetStructOfMethodsData($MethodNumber,$ArrayhLock) if $MethodNumber < 1 Then Return SetError(1,0,0) $MethodDataSize = DllStructGetSize(DllStructCreate($tagMethodData)) $MethodsDataSt = DllStructCreate($tagMethodData,$ArrayhLock + ($MethodDataSize * ($MethodNumber - 1))) if Not IsDllStruct($MethodsDataSt) Then Return SetError(2,0,0) Return $MethodsDataSt EndFunc Func GetAllocOfParamsData($cArgs) if $cArgs < 1 Then Return SetError(1,0,0) $ParamsDataSize = (DllStructGetSize(DllStructCreate($tagParamData)) * $cArgs) if Not($ParamsDataSize) Then Return SetError(2,0,0) $LPVOID = CoTaskMemAlloc($ParamsDataSize) Return $LPVOID EndFunc Func GetStructOfParamsData($ArrayhLock,$ParamNumber) if $ParamNumber < 1 Then Return SetError(1,0,0) $ParamDataSize = DllStructGetSize(DllStructCreate($tagParamData)) $ParamsDataSt = DllStructCreate($tagParamData,$ArrayhLock + ($ParamDataSize * ($ParamNumber - 1))) if Not IsDllStruct($ParamsDataSt) Then Return SetError(2,0,0) Return $ParamsDataSt EndFunc Func AllocFromStruct($tagSt) $StSize = DllStructGetSize(DllStructCreate($tagSt)) if Not ($StSize) Then Return SetError(1,0,0) $LPVOID = CoTaskMemAlloc($StSize) Return $LPVOID EndFunc Func StructFromAlloc($hLock,$tagSt) $NewSt = DllStructCreate($tagSt,$hLock) if Not IsDllStruct($NewSt) Then Return SetError(1,0,0) Return $NewSt EndFunc Func CoTaskMemAlloc($cb) $LPVOID = DllCall($Ole32,"ptr","CoTaskMemAlloc","int",$cb) if @error Or $LPVOID[0] = 0 Then Return SetError(1,0,0) Return $LPVOID[0] EndFunc Func CoTaskMemFree($pv) DllCall($Ole32,"NONE","CoTaskMemFree","ptr",$pv) EndFunc Constants.au3 #include-once #include <WinAPI.au3> Global $Ole32 = DllOpen("Ole32.dll") Global $OleAut32 = DllOpen("OleAut32.dll") Global $Kernel32 = DllOpen("Kernel32.dll") Global $tagVariant = "USHORT vt;WORD wReserved1;WORD wReserved2;WORD wReserved3;byte union[8]" Global $tagDISPPARAMS = "ptr rgvarg;ptr rgdispidNamedArgs;UINT cArgs;UINT cNamedArgs" Global $tagMethodData = "ptr szName;ptr ppdata;UINT dispid;UINT iMeth;UINT cc;UINT cArgs;WORD wFlags;WORD vtReturn;" Global $tagParamData = "ptr szName;WORD vt;" Global $tagInterfacedata = "ptr MethodData;UINT cMembers" Global $vtagSYSTEMTIME = "WORD wYear;WORD wMonth;WORD wDayOfWeek;WORD wDay;WORD wHour;WORD wMinute;" & _ "WORD wSecond;WORD wMilliseconds" Global $tagCY = "ULONG Lo;long Hi" Global $tagDEC = "USHORT wReserved;BYTE scale;BYTE sign;ULONG Hi32;ULONG Lo32;ULONG Mid32;" Global $tagSAFEARRAYBOUND = "ULONG cElements;LONG lLbound" Global $tagnGUID = "ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" Global $VariantSize = DllStructGetSize(DllStructCreate($tagVariant)) Global $SizeOfUlong_Ptr = DllStructGetSize(DllStructCreate("ULONG_PTR")) Global $IID_NULL = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") Global $StOfClassArray[1][4] ; flags for RegisterActiveObject Global $ACTIVEOBJECT_STRONG = 0x0 Global $ACTIVEOBJECT_WEAK = 0x1 ;wFlags MemberType Global $DISPATCH_METHOD = 0x1, _ $DISPATCH_PROPERTYGET = 0x2 , _ $DISPATCH_PROPERTYPUT = 0x4 , _ $DISPATCH_PROPERTYPUTREF = 0x8 ;wFlags MemberType ;enum $tagCALLCONV Global $CC_FASTCALL = 0 Global $CC_CDECL = 1 Global $CC_MSCPASCAL = $CC_CDECL + 1 Global $CC_PASCAL = $CC_MSCPASCAL Global $CC_MACPASCAL = $CC_PASCAL + 1 Global $CC_STDCALL = $CC_MACPASCAL + 1 Global $CC_FPFASTCALL = $CC_STDCALL + 1 Global $CC_SYSCALL = $CC_FPFASTCALL + 1 Global $CC_MPWCDECL = $CC_SYSCALL + 1 Global $CC_MPWPASCAL = $CC_MPWCDECL + 1 Global $CC_MAX = $CC_MPWPASCAL + 1 ;enum $tagCALLCONV ;tagCLSCTX ;$dwClsContext Global $CLSCTX_INPROC_SERVER=0x1 , _ $CLSCTX_INPROC_HANDLER=0x2 , _ $CLSCTX_LOCAL_SERVER=0x4 , _ $CLSCTX_INPROC_SERVER16=0x8 , _ $CLSCTX_REMOTE_SERVER=0x10 , _ $CLSCTX_INPROC_HANDLER16=0x20 , _ $CLSCTX_RESERVED1=0x40 , _ $CLSCTX_RESERVED2=0x80 , _ $CLSCTX_RESERVED3=0x100 , _ $CLSCTX_RESERVED4=0x200 , _ $CLSCTX_NO_CODE_DOWNLOAD=0x400 , _ $CLSCTX_RESERVED5=0x800 , _ $CLSCTX_NO_CUSTOM_MARSHAL=0x1000 , _ $CLSCTX_ENABLE_CODE_DOWNLOAD=0x2000 , _ $CLSCTX_NO_FAILURE_LOG=0x4000 , _ $CLSCTX_DISABLE_AAA=0x8000 , _ $CLSCTX_ENABLE_AAA=0x10000 , _ $CLSCTX_FROM_DEFAULT_CONTEXT=0x20000 , _ $CLSCTX_ACTIVATE_32_BIT_SERVER=0x40000 , _ $CLSCTX_ACTIVATE_64_BIT_SERVER=0x80000 , _ $CLSCTX_ENABLE_CLOAKING=0x100000 , _ $CLSCTX_APPCONTAINER=0x400000 , _ $CLSCTX_ACTIVATE_AAA_AS_IU=0x800000 , _ $CLSCTX_PS_DLL=0x80000000 ;$dwClsContext ;tagCLSCTX ;tagREGCLS ;flags Global $REGCLS_SINGLEUSE = 0, _ $REGCLS_MULTIPLEUSE = 1, _ $REGCLS_MULTI_SEPARATE = 2, _ $REGCLS_SUSPENDED = 4, _ $REGCLS_SURROGATE = 8 ;flags ;tagREGCLS1 point -
Direct JavaScript Action
ComradVlad reacted to Danp2 for a topic
You didn't state which browser you're using. For IE, take a look at _IEFormElementOptionSelect in the help file.1 point -
Creating a "brushed up" Task Scheduler UDF?
FrancescoDiMuro reacted to water for a topic
Looks good. I too tried to connect to my local computer ... the result was that my account got locked - something went wrong with userid/password. Seems connecting to another computer will be something we will figure out when everything else is rock-stable.1 point -
Creating a "brushed up" Task Scheduler UDF?
FrancescoDiMuro reacted to water for a topic
The Windows Task Scheduler does not provide a method to move tasks. But with the XML Export/Import it is easily possible. Export the task to a file or array, import the file/array and specify the new task path. If successful delete the "old" task. I will soon release the new functions so you can play with them1 point -
Creating a "brushed up" Task Scheduler UDF?
seadoggie01 reacted to FrancescoDiMuro for a topic
@seadoggie01 He was talking about Task creation here1 point -
AutoIt3Wrapper.au3 gets deleted?
Earthshine reacted to Jos for a topic
Funny they start flagging readable sourcecode files. They are really getting lazy, aren't they. It is actually an Heuristic issue which is strange for the Run function as that doesn't do that much really. https://support.avg.com/answers?id=9060N0000005PC8QAM1 point -
Dice Logic - What is the deal here?
Earthshine reacted to SlackerAl for a topic
Don't re-seed the RNG each time you use it (I'm excluding uses in cryptography / security here because there are issues of future state prediction from a known start point). The seed is setting the start-point/input-value for the RNG, which is really a predictable list of pseudo random numbers. You need a random seed initially so that you do not always generate the same sequence of pseudo random numbers, but if you re-seed using the same value (accidentally or otherwise), as Nine has pointed out, you are just restarting your list of pseudo random numbers at the same point. Setting the seed to a known value is at its most useful if you want to use the repeatability of the pseudo random sequence to procedurally generate data that appears random, but is repeatable e.g. terrain within a game. Setting it randomly once will prevent your application from always producing its "random" events in the same order. Although it's possible to see the same parts of the pseudo random numbers repeated, if the RNG range is sufficiently large, this should not be apparent to the user. Edit: added the word "randomly" to a couple of places to avoid any confusion.1 point -
Thank you for your advice, it doesn't work yet but with this change it works: $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='secondary_tags']/ul/li/input")1 point
-
This won't work because that ID belongs to the div, not the input element. You could try this instead -- $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='secondary_tags']/input")1 point
-
Creating a "brushed up" Task Scheduler UDF?
FrancescoDiMuro reacted to Musashi for a topic
Errorcode 800A0046 (QWord Hex) => 70 (Word Dec) C:\Users\Username>net helpmsg 70 Result : Der Remoteserver wurde angehalten oder wird gerade gestartet. (The remote server has been stopped or is being started.) If you enter "800A0046 permission denied" at google you get various results, for example https://stackoverflow.com/questions/56117328/vbscript-error-code-800a0046-permission-denied No idea whether that's helpful or not 🤔 (the errorcode topic is a PITA anyway).1 point -
Creating a "brushed up" Task Scheduler UDF?
FrancescoDiMuro reacted to water for a topic
Maybe this helps? http://www.sarayoo.info/how-to-create-or-manage-scheduled-tasks-on-a-remote-computer-in-windows/1 point -
BTW Wolf9228 has some pretty awesome code for this here the function for making the DISPPARAMS structure is mostly his1 point
-
All I managed to do reliably with the callbyname function is crash AutoIt However I did manage to make call by name work It's not going to work for you I doubt because its 600 lines of code but hey I'll post it anyways So basically I recreated the method by which autoit calls members (well any com program really) its definitely beta code and it's barely tested HAVE FUN1 point
-
Why AutoIt, and not another language like C# or Python?
DaveScotese reacted to iamtheky for a topic
1) From idea on the shitter --> proof of concept is rarely measured in anything other than minutes. 2) The helpfile is gd amazing (which often facilitates #1). 3) people who have to maintain your uncommented code in the future get the luxury of 1 and 2.1 point -
Why AutoIt, and not another language like C# or Python?
EnigmaScript reacted to mLipok for a topic
I will answer by reverse your question. I do not know C# and do not know Python. From 2004 my only one programming language is AutoIt. I have my own small bussines and I hire 3 people. AutoIt scripts which I made for my clients, are generating about 1/4 of my company incomes. Why I should use other programming language ? EDIT: currently in 2020 I hire 4 people1 point -
Get Number using RegEx
keeeniiic reacted to FrancescoDiMuro for a topic
@keeeniiic If the number is always in that position of the string, you could do something like this: #include <Array.au3> #include <StringConstants.au3> Global $strString = "&Adresse" & @CRLF & _ "306812" & @CRLF & _ "701015" $arrResult = StringRegExp($strString, '(?s)&Adresse.*?\d+.*?(\d+)', $STR_REGEXPARRAYGLOBALMATCH) If IsArray($arrResult) Then _ArrayDisplay($arrResult)1 point -
I wrote this using Python 3 and the results were the same in Windows 10. import win32gui hwnd = win32gui.FindWindow(None, 'Untitled - Notepad') x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd) win32gui.MoveWindow(hwnd, x0, y0, 800, 600, True) In Windows 7, WinGetPos and WinGetClientSize return same height and width and this problem doesn't exist in Windows 7. But in Windows 10, WinGetClientSize height is 14 pixels shorter than WinGetPos height and WinGetClinetSize width is 7 pixels shorter than WinGetPos width. This script below will fix this problem in Windows 10 while still working fine in Windows 7 and 8. Func _resize($x, $y) $hWnd = WinGetHandle("[ACTIVE]") ;get handle of active window WinSetState($hWnd, '', @SW_RESTORE) ;some windows will retrun wrong width and height if maximized $wpos = WinGetPos($hWnd) $csiz = WinGetClientSize($hWnd) If @OSVersion == 'WIN_10' Then If $csiz[0] <> $wpos[2] And @OSVersion == 'WIN_10' Then $xf = 14 $yf = 7 Else $xf = 0 $yf = 0 EndIf Else $xf = 0 $yf = 0 EndIf WinMove($hWnd, '', Default, Default, $w+$xf, $h+$yf) EndFunc And this is how to use it. _resize(800,600) I also tested this in Windows 10 with different DPI and it works. @Bilgus, thanks for helping me with this.1 point
-
Creating a "brushed up" Task Scheduler UDF?
FrancescoDiMuro reacted to AdamUL for a topic
@water Your welcome, glad I could help. @Professor_Bernd Here are some examples of _TS_Open that I used to connect to the different computers. ;Connect to a computer in AD where the current user is in a the local Admininstrators group ;on that computer, via domain or local group, or directly. Use AD computer name. Global $oService = _TS_Open("COMPUTERNAME") ;Connect to a computer in AD where the entered user (AdminUser) is an AD user, and is in a the ;local Admininstrators group on that computer, via domain or local group, or directly. Use AD computer name. Global $oService = _TS_Open("COMPUTERNAME", "AdminUser", "AD", "Password") ;Connect to a computer in AD where the entered local user (Administrator) is NOT an AD user, ;and is in a the local Admininstrators group on that computer, via local group, or directly. Use AD computer name. Global $oService = _TS_Open("COMPUTERNAME", "Administrator", ".", "Password") ;Non-domain computer where the entered local user (Administrator) is in a the local Admininstrators group ;on that computer. Use IP address or DNS name to connect. Global $oService = _TS_Open("192.168.0.1", "Administrator", ".", "Password") Adam1 point -
What Jos meant is you need to refresh the active window, take a look at this : #include <Constants.au3> Opt("MustDeclareVars", 1) Const $pagename = "Google" HotKeySet("{END}", "_Exit") AdlibRegister("MyAdLibFunc", 10000); check every 10 secs While 1 Sleep(100) WEnd Func MyAdLibFunc() Local Static $iCount = 0 $iCount += 1 ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF) Local $sActiveWindowTitle = WinGetTitle("[ACTIVE]") ConsoleWrite("now " & $sActiveWindowTitle & @CRLF) If StringInStr($sActiveWindowTitle, $pagename) Then ConsoleWrite(StringInStr($sActiveWindowTitle, $pagename & @CRLF)) Else ConsoleWrite(StringInStr($sActiveWindowTitle, $pagename & @CRLF)) Exit EndIf EndFunc ;==>MyAdLibFunc Func _Exit () Exit EndFunc1 point
-
Ok, well, you aren't updating the $sActiveWindowTitle variable with the current situation so you keep on testing the start status. Jos1 point
-
WebDriver UDF - Help & Support
Matze1985 reacted to danylarson for a topic
Hi Dan, Great Thanks for your help. I improved the function : as you can see i replaced the "StartElement" parameter by an option value parameter (that i did not understood well sorry...) The option value parameter is the value you want to select on your listbox. You Can try the new function on the demo code and improve it for sure Func DemoNavigation() _WD_Window($sSession, "maximize") _WD_Navigate($sSession, "https://www.nvidia.fr/Download/index.aspx?lang=fr") _WD_OptionSelectElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id='selProductSeriesType']/option", "tesla") EndFunc The new function : Func _WD_OptionSelectElement($sSession, $sStrategy, $sSelector, $OptionValue) Local $aElements Local $DicElements Local $i Local $Rslt Local $sElement $DicElements = objcreate("Scripting.Dictionary") ;~ $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@id='selProductSeriesType']/option", '', True) $aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSelector, '', True) ;~ _ArrayDisplay($aElements) For $i = 0 to Ubound($aElements) - 1 $IdElement = $aElements[$i] ;~ print($IdElement) $TmpElement = _WD_ElementAction($sSession, $IdElement, 'text', 'value') $DicElements.Add(String($i),String($TmpElement)) ;~ print($ValueElement) Next for $i = 1 To $DicElements.Count $TmpElement = $DicElements(String($i)) if $TmpElement = $OptionValue then $Rslt = $i + 1 Exitloop Else $Rslt = 0 EndIf Next If $Rslt <> 0 Then $sElement = _WD_FindElement($sSession, $sStrategy, $sSelector & "[" & $Rslt & "]", "") If @error = $_WD_ERROR_Success Then _WD_ElementAction($sSession, $sElement, 'click') EndIf Else Consolewrite("Value : " & $OptionValue & " is not present on the element : " & $sSelector & "") EndIf EndFunc1 point -
Automating Notepad This example is a response to a request by mLipok for a simple Notepad automation. Task: Create a simple script to fill up "Edit1" with HelloWorld, click "Save As...", enter filename and finally save it to disc. This involves automating Notepad or more generally an Edit control, it involves automating a menu and a Save As dialog. Note that "Edit1" (from AutoIt Window Info tool) is not a valid control identification in UI Automation code. Do not open Notepad in advance. This will be done in the code. Start the code by opening Notepad and create the UI Automation object through IUIAutomation interface. I almost always create the Desktop element. Note how you first get a pointer to the element (GetRootElement method of $oUIAutomation object), and then creates the object that represents the element through IUIAutomationElement interface. UI Automation elements are nearly always created this way through a pointer. #include "..\..\Includes\CUIAutomation2.au3" Example() Func Example() ; Open Notepad Run( "Notepad" ) Sleep( 1000 ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) EndFunc Open Examples\Notepad\Notepad.au3 (empty) in SciTE. Add the code, run the code with F5 and leave Notepad open. Check that SciTE output is OK. Next step is to get the Notepad window as an UI Automation element. Open UIASpy (included in zip-file, keep UIASpy open throughout the entire example), place mouse cursor over Notepad title bar and press F2: (You can delete other windows in UIASpy by right-clicking treeview top windows (level one items).) $UIA_ClassNamePropertyId = "Notepad" is used to create a property condition to identify Notepad. Note that you can copy this line in UIASpy listview: Select the line in the listview, click "Right pane" item in main menu, click "Copy all or selected items to clipboard", paste the line into your code editor. Add this code to the existing code: ; --- Notepad window --- ConsoleWrite( "--- Notepad window ---" & @CRLF ) Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) EndFunc Note again how we first get a pointer to Notepad (FindFirst method of $oDesktop object, $oDesktop because the Desktop is the parent element of Notepad) and then creates the object. Also note that $oDesktop and $oNotepad are created in exactly the same way. Close the previous Notepad, run the code and leave Notepad open. Check that SciTE output is OK. Now, the actual automation starts: Fill up "Edit1" with HelloWorld. An automation task is almost always done in two or three steps: 1. Create condition to find element 2. Find the UI Automation element 3. Extract info or perform action Each of these steps can usually be done in 1 - 3 lines of UI Automation code. All three steps can usually be done in less that 10 lines of UI Automation code (common AutoIt debug/info code not included). To get the Notepad window above we only used two steps. The first automation task is to perform an action to fill out the Edit control with "HelloWorld". Place mouse cursor in the Edit control and press F1: (If there are two or more Notepad windows in UIASpy, you can delete the old windows (red) by right-clicking the treeview.) This time we can use $UIA_AutomationIdPropertyId = "15" to create a property condition to identify the Edit control. Add this code: ; --- Fill Edit element --- ConsoleWrite( "--- Fill Edit element ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pEdit, $oEdit $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) EndFunc $oNotepad.FindFirst means that the search for the Edit control starts in the Notepad window. $oEdit reprecents the Edit control. Close the previous Notepad, run the code and leave Notepad open. Check that SciTE output is OK. The Edit control must be filled with "HelloWorld". This is an action that has to be performed on the Edit control. The following actions are available: (Scroll down UIASpy listview to see Control Patterns (actions).) The interesting action or pattern here is the ValuePattern. The action is created and performed this way: Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) EndFunc $oEdit.GetCurrentPattern means that a pattern is created that performs actions on the Edit control. GetCurrentPattern method returns a pointer where from the ValuePattern object ($oValue) can be created. $UIA_ValuePatternId and the ValuePattern interface is defined in CUIAutomation2.au3. The $oValue object represents the ValuePattern interface for the Edit control. $oValue.SetValue( "HelloWorld" ) sets the text in the Edit control. An action or pattern is almost always created and performed this way. Add the code, close the previous Notepad, run the code and leave Notepad open. Open File menu. Place mouse cursor over the File menu and press F1: (Scroll down UIASpy listview to see Control Patterns (actions) in bottom of image.) ; --- Open File menu --- ConsoleWrite( "--- Open File menu ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pCondition2 ; $UIA_NamePropertyId is LOCALIZED and maybe CASE SENSITIVE $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "File", $pCondition2 ) ; File <<<<<<<<<<<<<<<<<<<< If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pFile, $oFile $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pFile ) $oFile = ObjCreateInterface( $pFile, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oFile ) Then Return ConsoleWrite( "$oFile ERR" & @CRLF ) ConsoleWrite( "$oFile OK" & @CRLF ) Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) EndFunc The Invoke action or pattern is used to click and open the File menu. Note the similarity between the code for InvokePattern and ValuePattern above. When a menu, dialog box or child window is opened it need some time to open. You must add a Sleep statement. Add the code, change "File" to the corresponding word in your own language (copy the word from the listview), close the previous Notepad (don't save), run the code and leave Notepad open. Click "Save As..." menu. If the File menu that was opened above is closed, then open it manually with a mouse click. Place mouse cursor over the "Save As..." menu and press F1: ; --- Click "Save As..." menu --- ConsoleWrite( "--- Click ""Save As..."" menu ---" & @CRLF ) ; Reuse $pCondition1 above ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "4", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAs, $oSaveAs $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAs ) $oSaveAs = ObjCreateInterface( $pSaveAs, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAs ) Then Return ConsoleWrite( "$oSaveAs ERR" & @CRLF ) ConsoleWrite( "$oSaveAs OK" & @CRLF ) $oSaveAs.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 1000 ) EndFunc Note how similar the "Open File menu" code and the "Click Save As... menu" code is. Note also the long Sleep because it's a "Save As" dialog with a large number of elements. Add the code, close the previous Notepad (don't save), run the code and leave Notepad and Save As open. Save As window. Place mouse cursor over Save As title bar and press F2: ; --- Save As window --- ConsoleWrite( "--- Save As window ---" & @CRLF ) ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAsWin, $oSaveAsWin $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAsWin ) $oSaveAsWin = ObjCreateInterface( $pSaveAsWin, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAsWin ) Then Return ConsoleWrite( "$oSaveAsWin ERR" & @CRLF ) ConsoleWrite( "$oSaveAsWin OK" & @CRLF ) EndFunc The rest of the automation tasks is about the Save As window. Therefore we want to use the Save As window as the starting point. Not Notepad. Add the code, close the previous Save As and Notepad (don't save), run the code and leave Notepad and Save As open. Set File name. Place mouse cursor over File name Edit control and press F1: ; --- Set File name --- ConsoleWrite( "--- Set File name ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1001", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld.txt" ) EndFunc $oSaveAsWin.FindFirst searches in the Save As window. $oEdit is now the File name Edit control in the Save As window. The file name is set to "HelloWorld.txt". Add the code, close the previous Save As and Notepad (don't save), run the code and leave Notepad and Save As open. Click Save button. Place mouse cursor over Save button and press F1: ; --- Click Save button --- ConsoleWrite( "--- Click Save button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSave, $oSave $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pSave ) $oSave = ObjCreateInterface( $pSave, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSave ) Then Return ConsoleWrite( "$oSave ERR" & @CRLF ) ConsoleWrite( "$oSave OK" & @CRLF ) $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() EndFunc Add the code, close the previous Save As and Notepad (don't save) and run the code. All code (Examples\Notepad\NotepadAll.au3): #include "..\..\Includes\CUIAutomation2.au3" Example() Func Example() ; Open Notepad Run( "Notepad" ) Sleep( 1000 ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Notepad window --- ConsoleWrite( "--- Notepad window ---" & @CRLF ) Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) ; --- Fill Edit element --- ConsoleWrite( "--- Fill Edit element ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pEdit, $oEdit $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) ; --- Open File menu --- ConsoleWrite( "--- Open File menu ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pCondition2 ; $UIA_NamePropertyId is LOCALIZED and maybe CASE SENSITIVE $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "File", $pCondition2 ) ; File <<<<<<<<<<<<<<<<<<<< If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pFile, $oFile $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pFile ) $oFile = ObjCreateInterface( $pFile, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oFile ) Then Return ConsoleWrite( "$oFile ERR" & @CRLF ) ConsoleWrite( "$oFile OK" & @CRLF ) Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) ; --- Click "Save As..." menu --- ConsoleWrite( "--- Click ""Save As..."" menu ---" & @CRLF ) ; Reuse $pCondition1 above ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "4", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAs, $oSaveAs $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAs ) $oSaveAs = ObjCreateInterface( $pSaveAs, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAs ) Then Return ConsoleWrite( "$oSaveAs ERR" & @CRLF ) ConsoleWrite( "$oSaveAs OK" & @CRLF ) $oSaveAs.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 1000 ) ; --- Save As window --- ConsoleWrite( "--- Save As window ---" & @CRLF ) ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAsWin, $oSaveAsWin $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAsWin ) $oSaveAsWin = ObjCreateInterface( $pSaveAsWin, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAsWin ) Then Return ConsoleWrite( "$oSaveAsWin ERR" & @CRLF ) ConsoleWrite( "$oSaveAsWin OK" & @CRLF ) ; --- Set File name --- ConsoleWrite( "--- Set File name ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1001", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld.txt" ) ; --- Click Save button --- ConsoleWrite( "--- Click Save button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSave, $oSave $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pSave ) $oSave = ObjCreateInterface( $pSave, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSave ) Then Return ConsoleWrite( "$oSave ERR" & @CRLF ) ConsoleWrite( "$oSave OK" & @CRLF ) $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Notepad window --- $pCondition OK $oNotepad OK --- Fill Edit element --- $pCondition OK $oEdit OK $oValue OK --- Open File menu --- $pCondition1 OK $pCondition2 OK $pCondition OK $oFile OK $oInvoke OK --- Click "Save As..." menu --- $pCondition2 OK $pCondition OK $oSaveAs OK $oInvoke OK --- Save As window --- $pCondition OK $oSaveAsWin OK --- Set File name --- $pCondition OK $oEdit OK $oValue OK --- Click Save button --- $pCondition1 OK $pCondition2 OK $pCondition OK $oSave OK $oInvoke OK Maybe somebody can show how to implement such a Notepad automation with the functions in UIAWrappers.au3 and with classic code. Summary The two most important objects in UI Automation code are the $oUIAutomation and $oUIElement objects created from IUIAutomation and IUIAutomationElement interfaces. An UI Automation element object that represents a window or control is always created with the IUIAutomationElement interface through a pointer to the element object: $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) An UI Automation task is almost always done in two or three steps: 1. Create condition to find element 2. Find the UI Automation element 3. Extract info or perform action Each of these steps can usually be done in 1 - 3 lines of UI Automation code. All three steps can usually be done in less that 10 lines of UI Automation code (common AutoIt debug/info code not included). UI Automation actions (patterns) are performed through pattern interfaces, objects and methods. The code is nearly always implemented this way: Fill an Edit control: Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) $oEdit is an Edit control. The $oValue object represents the ValuePattern interface for the Edit control. $oValue.SetValue() sets the text in the Edit control. Click a menu item: Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) $oFile is a File menu. The $oInvoke object represents the InvokePattern interface for the File menu. $oInvoke.Invoke() clicks the File menu. Sleep( 100 ) gives the File menu time to open. Click a button control: $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() $oSave is a Save button. The $oInvoke object represents the InvokePattern interface for the Save button. $oInvoke.Invoke() clicks the Save button. When writing UI Automation code, it's easiest to write the code in small steps and test the code after each step. Error management based on checking objects with IsObj() and ConsoleWrite() is required and sufficient. It's very rare necessary to use an actual object (COM) error handler. Too small Sleep times after a menu, dialog or window is opened is a common error.1 point
-
Multi-monitor aware window centring function. Can handle various work area setups as outlined below: Those are the variants I've tested. #include <Math.au3> #include <WinAPI.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Func activeWindowCenter() Const $window = WinGetHandle('[ACTIVE]') Const $monitorInfo = _WinAPI_GetMonitorInfo(_WinAPI_MonitorFromWindow($window)) Const $area[] = [DllStructGetData($monitorInfo[1], 1), DllStructGetData($monitorInfo[1], 3), DllStructGetData($monitorInfo[1], 2), DllStructGetData($monitorInfo[1], 4)] Const $size = WinGetPos($window) If @error Then Return EndIf If BitAND(_WinAPI_GetWindowLong($window, $GWL_STYLE), $WS_MAXIMIZE) Then Return EndIf Const $areaWidth = _Max($area[0], $area[1]) - _Min($area[0], $area[1]) Const $windowOffsetX = ($areaWidth - $size[2]) / 2 Const $x = _Min($area[0], $area[1]) + $windowOffsetX Const $areaHeight = _Max($area[2], $area[3]) - _Min($area[2], $area[3]) Const $windowOffsetY = ($areaHeight - $size[3]) / 2 Const $y = _Min($area[2], $area[3]) + $windowOffsetY WinMove($window, '', $x, $y, $size[2], $size[3], 2) EndFunc Here's simple usage: ; include the definition HotKeySet('#o', 'activeWindowCenter') While 1 Sleep(1000) WEnd1 point
-
Try this: #include <GDIPlus.au3> #include <Memory.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> _GDIPlus_Startup() Global $u, $aBitmapAnim[8] For $u = 0 To 7 $aBitmapAnim[$u] = _GDIPlus_BitmapCreateFromMemory(Execute("_EyeBlink_" & $u & "png()")) Next Global $hWnd = GUICreate("Display Windows Title Icon from file by UEZ 2011", -1, -1, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME) GUISetState(@SW_SHOW, $hWnd) PlayAnim() AdlibRegister("PlayAnim", 2500) While 1 If GUIGetMsg("") = -3 Then AdlibUnRegister("PlayAnim") For $u = 0 To 7 _GDIPlus_BitmapDispose($aBitmapAnim[$u]) Next _GDIPlus_Shutdown() GUIDelete($hWnd) Exit EndIf WEnd Func PlayAnim() Local $u, $hIcon_New For $u = 0 To 7 $hIcon_New = _WinAPI_SetWindowTitleIcon($aBitmapAnim[$u], $hWnd) Sleep(60) _WinAPI_DestroyIcon($hIcon_New) Next For $u = 7 To 0 Step -1 $hIcon_New = _WinAPI_SetWindowTitleIcon($aBitmapAnim[$u], $hWnd) Sleep(80) _WinAPI_DestroyIcon($hIcon_New) Next EndFunc ;====================================================================================== ; Function Name: _WinAPI_SetWindowTitleIcon ; Description: Loads an image, scales it to desired width or height and creates an icon handle ; ; Parameters: $sFile: image file to be loaded or bitmap handle ; $hWnd: GUI handle where the new icon should be displayed ; $iW: new image (icon) width. Default values is 32 ; $iH: new image (icon) height. Default values is 32 ; ; Requirement(s): GDIPlus.au3, _WinAPI_GetClassLongEx() and _WinAPI_SetClassLongEx() ; Return Value(s): Success: HICON handle, Error: 0 (see below) ; Error codes: 1: Code is running as x64 - not supported yet ; 2: $sFile value is empty ; 3: $hWnd is not a windows handle ; 4: filename doesn't exist or $sFile is not a valid bitmap handle ; 5: unable to create image from file ; 6: unable to create thumbnail from image handle ; 7: unable to create HICON from bitmap handle ; 8: unable to set ClassLongEx from GUI handle ; ; Limitation: only x86 compatible currently ; ; Author(s): UEZ, Yashied for _WinAPI_GetClassLongEx() and _WinAPI_SetClassLongEx() ; Version: v0.98 Build 2016-11-21 Beta ; ; Remarks: When finished release icon with _WinAPI_DestroyIcon() ;======================================================================================= Func _WinAPI_SetWindowTitleIcon($sFile, $hWnd, $iW = 16, $iH = 16) If @AutoItX64 Then Return SetError(1, 0, 0) If $sFile = "" Then Return SetError(2, 0, 0) If Not IsHWnd($hWnd) Then Return SetError(3, 0, 0) ;~ Local Const $GCL_HICON = -14, $GCL_HICONSM = -34 Local $hImage, $bExtHandle = False If Not FileExists($sFile) Then If _GDIPlus_ImageGetType($sFile) = -1 Then Return SetError(4, @error, 0) $hImage = $sFile ;interpret $sFile as a bitmap handle $bExtHandle = True Else $hImage = _GDIPlus_ImageLoadFromFile($sFile) If @error Then Return SetError(5, @error, 0) EndIf Local Const $hImageScaled = _GDIPlus_ImageScale($hImage, $iW, $iH) If @error Then Return SetError(6, @error, 0) If Not $bExtHandle Then _GDIPlus_ImageDispose($hImage) Local Const $hIconNew = _GDIPlus_HICONCreateFromBitmap($hImageScaled) If @error Then _GDIPlus_ImageDispose($hImageScaled) Return SetError(7, @error, 0) EndIf ;~ _WinAPI_SetClassLongEx($hWnd, $GCL_HICONSM, $hIconNew) _SendMessage($hWnd, $WM_SETICON, 1, $hIconNew) If @error Then _GDIPlus_ImageDispose($hImageScaled) Return SetError(8, @error, 0) EndIf _GDIPlus_ImageDispose($hImageScaled) Return $hIconNew EndFunc ;==>_WinAPI_SetWindowTitleIcon Func __Exit__() _GDIPlus_Shutdown() EndFunc ;==>__Exit__ #Region Animation Frames Func _EyeBlink_0png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_0png $EyeBlink_0png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL/SURBVDhPPVNbK7RRFN5hhrhCDjfiQpIhkpIcCvVNIYeEZBxzPiWSQxjGtiM5hgjRCCmJpAYZLggpJaVcULjRXCi/4Pn2WvV9b+3W+6537bWetZ5nCaXUn6WlJbW2tqZ2d3fV8vIyn9vbW/X09KSurq6Uw+FQe3t7iuI2NjbU4eEh+10ulxJjY2Mzq6ur0Jewvr6OlZUVWK1W7O/v4/HxES8vL9DBOD4+xtbWFihWJ8D9/T1+fn4gRkZGJF1oaWlBQ0MDmpubkZmZiezsbHR1dWF6ehrd3d2QUmJxcRG6IBYWFnB0dASNEkL/lE1NTcjIyEBaWhrCwsJgNBrh4eEBT09Ptm5ubggODkZqairq6+uh22YkZ2dnELqirKqqQmxsLHx9feHu7s4Xo6KiEBoaisDAQPj7+0MI8T8poRsaGsLOzg6ExWLhBNHR0VwpKCiIWygvL2dUJSUl0DEwmUz8TUkpWW5uLiYmJiDy8vJkeno6/Pz84OXlhbi4OFRWVjJUsmazmS/TDGpqahi+j48PvL29UVtbC6GdkjL/gxoZGYnOzk60tbWhvb0d+fn57Lu5ucH4+DjbhIQERpGSkgJRUVEhCU54eDhCQkI4uK+vD729vcwK2YGBAVRXV2N7exvf39/clsFgQExMDERjY6MsLi5GUlISEhMT+VB1okz/Y3qpHZrJx8cHtHjYFxAQgIiICAjNtaTArKwspqm0tJQrb25usnA6OjpAQz45OQE9Dw8PKCoq4mHT4MXg4KDs6emBHiaSk5NRVlaGqakpaNnC6XTi+fkZb29v+P39ZWWSiChhfHw864akLG02G8MsLCxETk4O9zw/P88oTk9PWcoXFxf8rneCGSEUBQUFEJpLOTk5CUJBSYgqOlSlv7+fZ0F7cHl5yZbEMzc3h7q6Op6R0HAlVRseHgYhGR0dBSWkpSK9UxvX19eM4vz8nH16c9Ha2spqFLOzszN2u50rEeSDgwPW+N3dHV5fX/H19YXPz0+8v7/zN20h0UlF7HY7/gIkL01ljYA2awAAAABJRU5ErkJggg==' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_0png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_0.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_0png Func _EyeBlink_1png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_1png $EyeBlink_1png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL/SURBVDhPPVNbK7RRFN5hhrhCDjfiQpIhkpIcCvVNIYeEZBxzPiWSQxjGtiM5hgjRCCmJpAYZLggpJaVcULjRXCi/4Pn2WvV9b+3W+6537bWetZ5nCaXUn6WlJbW2tqZ2d3fV8vIyn9vbW/X09KSurq6Uw+FQe3t7iuI2NjbU4eEh+10ulxJjY2Mzq6ur0Jewvr6OlZUVWK1W7O/v4/HxES8vL9DBOD4+xtbWFihWJ8D9/T1+fn4gRkZGJF1oaWlBQ0MDmpubkZmZiezsbHR1dWF6ehrd3d2QUmJxcRG6IBYWFnB0dASNEkL/lE1NTcjIyEBaWhrCwsJgNBrh4eEBT09Ptm5ubggODkZqairq6+uh22YkZ2dnELqirKqqQmxsLHx9feHu7s4Xo6KiEBoaisDAQPj7+0MI8T8poRsaGsLOzg6ExWLhBNHR0VwpKCiIWygvL2dUJSUl0DEwmUz8TUkpWW5uLiYmJiDy8vJkeno6/Pz84OXlhbi4OFRWVjJUsmazmS/TDGpqahi+j48PvL29UVtbC6GdkjL/gxoZGYnOzk60tbWhvb0d+fn57Lu5ucH4+DjbhIQERpGSkgJRUVEhCU54eDhCQkI4uK+vD729vcwK2YGBAVRXV2N7exvf39/clsFgQExMDERjY6MsLi5GUlISEhMT+VB1okz/Y3qpHZrJx8cHtHjYFxAQgIiICAjNtaTArKwspqm0tJQrb25usnA6OjpAQz45OQE9Dw8PKCoq4mHT4MXg4KDs6emBHiaSk5NRVlaGqakpaNnC6XTi+fkZb29v+P39ZWWSiChhfHw864akLG02G8MsLCxETk4O9zw/P88oTk9PWcoXFxf8rneCGSEUBQUFEJpLOTk5CUJBSYgqOlSlv7+fZ0F7cHl5yZbEMzc3h7q6Op6R0HAlVRseHgYhGR0dBSWkpSK9UxvX19eM4vz8nH16c9Ha2spqFLOzszN2u50rEeSDgwPW+N3dHV5fX/H19YXPz0+8v7/zN20h0UlF7HY7/gIkL01ljYA2awAAAABJRU5ErkJggg==' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_1png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_1.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_1png Func _EyeBlink_2png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_2png $EyeBlink_2png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALvSURBVDhPPVPJK/1RFL8hSfEylSysqGfKwlRCKb0FilDmzESEMmwow/U1ZRaZFo+QhcgcCSHThhXKwkbKxp/wcT+nfr9Xt/N95577OZ/zOeeokZERx9zcnLW4uGhtbm6KXVlZse7u7qyXlxfr8vLSOjk5sba2tizG8W53d1f8Pz8/lhocHJwwTiwtLcHpdIodGhrC/v4+DADe3t5wfX2Ng4MDrK2tyb0BwMPDA35/f6F6e3t1X18f2tvb0dzcjJaWFmRmZqKoqAjmDgS3LAtTU1NYWFiA1hozMzPY29vD/f09VGdnp25oaEB6ejrS0tIQHh4Ob29veHp6iv13wsLCkJubi7a2NgEkk9PTU6jGxkZdVlaGmJgYBAUFwcXFBUopBAYGwt/fH15eXgJGH09AQAAKCwvR3d2NjY0NqPLycm0OIiIi4ObmBh8fH8TGxiInJwdJSUnIzs5GXl4eQkJCEB0dDZvNBg8PDxQUFMDoB2Vo6dTUVPj6+sLd3V2AWH9FRQVKS0vhcDiE/sDAgGRubW39n6iurg6qsrJSp6SkiMPPz0+CTVmgLrRkYrfbpRMEubi4QFRUlJTDd1ICaZJicHAwQkNDpSNGXNTU1Ijt6uoCdWIbv7+/RUxXV1dERkZC1dbWajri4uKQkJCA+Ph41NfXY3Z2Vijym0AlJSX4/PyEGR5hR8ZMpkw2zSC2MTk5GcXFxfKQ/WdGzgX1ODw8BH83NzfCgOWyNGXaoTs6OpCVlYXExETk5+djfHxc+nx+fo7n52e8vr5K5qenJ5hxRnV1tXSE8coIo/v7+4Um25WRkSHDMjo6ivn5eWxvb8PsggwNAfmfYlJcJlXDw8PaLJSIRepVVVUwuoileAQ5Pj7G1dUVjo6OsL6+LmPNGCZVY2Njenp6Gj09PSATohufaMAHt7e3eHx8lNrZQi7Z8vIympqaJIGanJycWF1dFdW5jTs7Ozg7O5Nte39/x9fXlxx24OPjQ8A4woa5iXfiD81gThB4HifAAAAAAElFTkSuQmCC' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_2png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_2.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_2png Func _EyeBlink_3png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_3png $EyeBlink_3png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMFSURBVDhPPVNbK7RhFH1wIZPkQpGQYxGKQhlJou/CMUQkh8YMwswoowk55fWInEKR04Q0JOVUFEqTcsoFNyKlZChX/sHy7P31fVNv72H2s/Zea+0lxsbG/iwsLMiVlRXpdDrlxsaG3NnZkTc3N/Lh4UFeXFzIk5MTub29Lefm5qTD4ZAHBwfS5XLJ7+9vKUZGRqZWV1eh/sDm5iboeXl5GWdnZ3h6esLz8zMuLy9xdHQEBY6lpSXs7+9DNcDPzw/E4OCgJqVEX18furu7YbPZUFtbi/b2dszPz3MxHSLQxcVFDA0NYXZ2FmoKBhFdXV2axWJBRUUFSkpKkJGRgZCQEAQHByM8PBxRUVGIiYlBbm4uqK6/vx/Dw8NQlHF6egrR1tam1dXVQa/XIzIyEp6enhBCwNvbGz4+Pvz87/Lw8EBCQgIaGxvR29uLra0tCIPBoNXX1yM+Pp4P+Pr6IjQ0FJmZmUhOTkZ2djZycnIQGBiIoKAgBqE7nVH6QZSVlWlUEBAQAC8vLx6bqFRXV6OyspIPx8bGcsf8/HyUlpbyNNSkpaUFQiFpKSkp0Ol08Pf3R2JiIkwmE1+tra0oLi5GXFwclG0YGBhgUSMiIhiEwIXRaNQIlcQKCwvju9VqZTcaGhrQ2dkJJTRqamqwvr6O9/d35OXlMQA1YwDqkpSUhNTUVNA0JNLMzAxP0dzczEBVVVV4e3vD5+cnv5NW0dHREB0dHVpTUxPzy8rKYu70Tr6vra3BbDaDXKJFop/aTBQVFcHPz+8vgBJHozFJuPT0dJSXl2N8fJx9Pj8/x/39PR4fH+F2u3F7ewu19jwBCZuWlgahlkKj7aKPyhHmRxqojDANlQ8cHh5C5YHXe3d3l7e2oKAAhYWFEKOjoxoV2+32/3yJgtIGPT093PH4+JhdIBASkiYkfahWTE5OarTbZBFNQrmYmJjgUNHB6+tr3N3d4erqivnTNJQNspiyI6anp6coZSqqjL63t8fcie/Lyws+Pj7w9fXF9r2+vnKAKLW0hQ6HA79Eck5SZY7tyAAAAABJRU5ErkJggg==' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_3png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_3.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_3png Func _EyeBlink_4png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_4png $EyeBlink_4png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL+SURBVDhPJVNZKIRRFL5Rtpo8EKUsUx5QJNkSxTxMKXuRyJKypBFSiGwz153sa/OgZiwREcoSWRNZkjxRiAcP5EGePH/uOf469XfvOef7zne/IwYHB81Op1PNzs6qzc1NdXR0pG5ubtT9/T3HwcGB2t/fV8vLy2pyclLNz8+rnZ0ddXFxob6/v5UYGBgY04dYWFjA1tYWrq6u8PDwgLe3N3x9feHx8RFnZ2d8Nzc3B5fLhd3dXdze3uL39xfCZrPJoaEh6EaYnp6GRsLe3h4uLy+5+Pn5GdfX19jY2IDD4UBPTw+mpqawvb2Nu7s7iK6uLtnR0QGLxYK2tjb09fVhZGSEk5eWlqDp4vDwEHoMZtnb28s59H98fAzR3Nwsq6urkZeXh4KCAmRkZCAmJgYBAQEIDAyE0WiEyWRCZWUlGhoa0NLSgsbGRrS3t2NtbQ2ipqZGVlRUwGw2IyIiAu7u7vDy8oKPjw+8vb3h6ekJPz8/hIWFITIyEnFxccjNzUVVVRXsdjtESUmJpIOEhAQuFkLAzc0Nvr6+zIAaeXh4ICQkBAaDgZkFBQUhNTUVtbW1/wySk5MZlRIIlYqDg4ORkpKC2NhY/ieNiAUFAVHjzMxMiPr6ellcXMw0qZgQkpKSWBNiRuOVlZWxDiSeUooBiGlUVNR/Az0Gz0aUQ0NDkZWVBSklysvLQXfUqKioCO/v7+yRxMREbkDMhKYm8/PzER0djfj4eOTk5KCwsBDj4+P8jKS6HhPn5+egTzsVaWlp3IAARWdnp6RnoSK6yM7ORmtrK5tK2xhPT0/4/PzEz88Pu5Q8Qoz8/f0RHh7+70Sr1cooJEp6ejo3m5iYYNuurq7ye6+srLBLyYX0hCQ86UK7IIeHh9mFWg+emxLq6uo4NABoV8j/6+vrmJmZgWbNeaWlpRCakiS6lEjR398P2g1isLi4yIukt5M1OD09hd5YZkHNm5qaIEZHR8cokbxPSLR1JycnvCgvLy+s/MfHB8fr6ysvGYnb3d2taxz4A9+TThkJSD2rAAAAAElFTkSuQmCC' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_4png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_4.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_4png Func _EyeBlink_5png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_5png $EyeBlink_5png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL/SURBVDhPPVNbKLRRFD0pHog8YES5JHny4BaSEA1FHpRB45Zyi+QSklvxOWUGI8S4zowIpRBJLg+YEB6IiEJRCq/e13/2Lv/D7vvOae+11t5nbWEymfRzc3PSZrPJzc1NeXh4KK+uruTt7S3H3t6e3NnZkWtra3JsbIzz6HxyciJ/fn6kGBwctDgcDiwuLmJ7exvn5+d4eHjA29sbvr+/8fj4iOPjY2xtbcFut2N2dpbzLi8v8fv7C9Hf36+ZzWZQWK1WrK6u4uDggBPu7u5wf3/PoBsbG5icnERPTw9GR0cZ5Pr6GqK7u1vr6upCQ0MD+vr6GGhgYABSSii5XKha4y+de3t7GWRhYQGqXYiWlhatrq4OBQUFKC0tRXZ2NnJychhwZmaGi9fX1zE9PY329naofNTX16O5uRkrKysQNTU1mgrk5uYiMTER6enpDNTU1MRzubi4wNPTE15eXrC8vMzgeXl5KC4uZjWivLxco4u0tDREREQgKiqK/zMzM9Ha2spSj46O8P7+jq+vL0xNTSEmJgapqakoKyuDUHI0vV4PDw8PuLm5wd3dHd7e3vD09ISfnx8iIyORn5+Pzs5OBmxsbOQ2/f39kZGRAaF61SoqKhAQEAAhxP8gIIrAwECEhoYiODiYi7y8vKDT6eDq6orw8HAI1SvPIDk5mVldXFxYCbGHhIQgKCiI1dE/tZqQkMA5RMKkSpZWW1uLrKwshIWFwcfHh4vj4+N54vSkExMTUO7E6ekpiOxPra+vL0RHR4dWXV2NuLg4viC5VEwvQU9HZlKWxfPzMz8bkSUlJXErlCsUg0bGIB9QG9HR0YiNjUVRURGbyWKxsPOU5fnc1tbGQyXClJQUCOU8bWhoCORGQjcajTAYDKyAhltZWYmRkRHQvtAeDA8PQ6lGSUkJCgsLIdSFRj3+2ZeYiFVtHubn59nzTqcT+/v7vCNkacqvqqpiRwqFbiGH0SKR83Z3d7ng5uYGr6+v+Pj4YBN9fn7yhp6dnWFpaYkVj4+P4x+sH1WKKPyLHwAAAABJRU5ErkJggg==' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_5png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_5.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_5png Func _EyeBlink_6png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_6png $EyeBlink_6png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL1SURBVDhPPVNLKPxRFL6EhJKVR2g2pNmwIAsWQ8yCxTQLyVuU8ooJE+XddRliWGAS5dHkkeeCUN7FoBQ2lEfJithh+bnn6P9fnO7vd+95fN853xH9/f3myclJNTU1pdbW1tTu7q46OztTl5eX6vb2lv9XVlbU/Py8GhsbU+RLfoeHh+rt7U0Jh8PhnJ6extzcHDY2NnBycoLr62vc39/j5eUFd3d3ODo6wvr6OmZnZzE+Po7V1VWcn5/j8/MToqenRw4ODqKvrw8ul4udyPng4AAXFxfQSHB8fMx3ExMT6OrqwsjICBfTSCHa2tpkZ2cnqqur0dLSAiklRkdHsbS0hL29Pa6uabC53W5+b21thabDd6KpqUk2NDQgPz8fhYWFfBYXFzMiSkLVCQ1VJKqE1mazoa6uDjMzMxA1NTWyvr4eubm5yMzMhMlkgsViQXd3N3Z2dnBzc4PX11c8Pz9jeXkZvb29aG5uRmlpKZ+iqqpKUnB2djZSU1NhNptRUlLCCHSn8fT0BN1tfH194fHxEU6nExUVFcjLy2PEQsORBQUFiIiIgNFoZBSEQFPDwsICrq6uGMHHxwdPZXNzE2VlZUhJSUFWVhaEhi+JU3x8PLy8vJCQkMB0qNt6/pzg/f0d39/f+Pn5wcPDA7R2EBUVxQW5iZTAarUiICCAk0RGRjIVu92O7e1tDiLb398HTSwtLQ3+/v4IDw+H6OjokI2NjcjJyUFsbCyEEGw+Pj4ICQlBcnIyamtrmW9cXNz/d7KwsLA/IbW3t6O8vJyrBgUF8SMh8fX1RWBgIMMNDQ2Fn58f3/8rEBMTAzEwMCC1gbSQkZHBAd7e3uxI3wQzOjqa6QUHB/M/9SspKYn9xdDQkBweHmaYiYmJPA0KpAoEkWgYDAbmTV2vrKxkIdHkioqK/hLQDiiloDXBE6DsxD09PZ0Fo+UOKkLKW1xc5F0gypSIEjhJ47QoemV59nTqlcXW1hY8Hg9vHm0nier09JQlTfvgcrnwC28cWcgdYmhNAAAAAElFTkSuQmCC' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_6png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_6.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_6png Func _EyeBlink_7png($bSaveBinary = False, $sSavePath = @ScriptDir) Local $EyeBlink_7png $EyeBlink_7png &= 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL4SURBVDhPPVNJKLZhFH3M80LJFMlCZCl2NsJPKUNmRRnKsCAylYy9XhlCQnwyJyXjQiQZMkYhLAwrlCixsLA8/3Ousrg93/c+9zn33HPuVV1dXf8sFos5Pj5uLi0tmdvb2+bR0ZF5fn5u3tzcmDs7O/J9bm7OHBkZMZnL/3t7e+bb25upOjs7+6ampjAzM4PV1VXs7+/j8vISd3d3eHp6wv39PQ4PD7G2tobZ2VkMDw9DA+D09BQfHx9Q7e3tRk9PD/QplwRbWVmBroyzszMJghJgbGwMbW1tGBgYkGLHx8dQjY2NRlNTE0pKSlBdXY2WlhYMDg5icXERu7u70O1At4WNjQ1hwEINDQ0CsrW1BVVTU2NUVVUhOzsbOTk5yMzMRG5uLrQ2WF5exsnJiQQByI5smV9RUYHJyUmosrIyo7y8HBkZGYiJiUFUVBRSUlJgGIZUuL29xevrK15eXrC+vg6tGerr61FQUIDa2tpfgLS0NMTHxyMyMlLO/Px8dHd3i3jPz8/4+vrCz8+PiDo6OorS0lJhS6aqsrLS4A8fHx+EhoYiNjYWycnJgr6wsIDr62th8Pn5KQCbm5vQRaVYQkLCLwB7Cg8Ph7W1NcLCwkSP1tZWsevi4gLv7+/4/v6WeHh4EB0CAgKkoKqrqzM0CFJTU+Hq6gobGxsEBweLJmyDfpMBQaiHHiQkJibC0dERvr6+UM3NzQbtS09PR0hICJRSEk5OTlKFgrIirY6OjoaLi8tfjre3N1RHR4dB74uKihAXFwc3Nze5tLKygr29PZydnREYGAg/Pz/Y2dn9PSbToKAgKE1TJpGi0QG2wccMBwcHeHh4wN/fXyoTjPd8SK1ou+rt7TU4VRyMiIgIeHl5SbKtrS08PT3h7u4u3ygY77OyssRGnnl5eVD9/f0GvTVNE4WFhUhKShItSJvO0Nbi4mLRgLvCpSNjzgq1I0Df/Pw89DqD5/T0NIaGhjAxMSGzzxHmLlxdXeHx8REHBweSq3dIO2LBf6J6WgSaqy/EAAAAAElFTkSuQmCC' Local $bString = Binary(_WinAPI_Base64Decode($EyeBlink_7png)) If $bSaveBinary Then Local $hFile = FileOpen($sSavePath & "\EyeBlink_7.png", 18) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_EyeBlink_7png Func _WinAPI_Base64Decode($sB64String) ;code by trancexx Local $a_Call = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") Local $a = DllStructCreate("byte[" & $a_Call[5] & "]") $a_Call = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $a, "dword*", $a_Call[5], "ptr", 0, "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, "") Return DllStructGetData($a, 1) EndFunc ;==>_WinAPI_Base64Decode #EndRegion Br, UEZ1 point
-
This is something I've been working on for the past more than a month. Las few days I finally got time for my self and finished the mailer. How to work with it? Just start the script and snoop around the GUI. It's all there, you just have to read text and pictures. But to make it simple: Start the script (app)Write the title of the messageChoose the format of the mail (text or HTML)Write the mailSwitch to tab2 ('Account Settings')Click on the light ball (ask if you have some questions)Click on the 'Save Settings'Switch to tab3 ('Sending Options')Fill the formChoose between the servers (you can leave default)Hit 'Send Mail'Monitor (F2 to abort at any time)Do it againThat's it. It's actually very powerful tool. I won't tell you what's capable of (I'm scared). Don't be an ass and use it for the things you shouldn't be using it for. You can grab files with your mouse and drop them on GUI. Dropped will be added as attachment(s) to your message if you are on tab1. Ahh, I forgot to say. Built-in server works asynchronously. The script (ZIP format because of included images): Mailer AutoIt.zip Probably the best mailing tool around! edit: New script with added functionalities.1 point
-
How to found PixelSearch left to right loop - (Locked)
KSDPK reacted to JLogan3o13 for a topic
Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team0 points -
Yes... but more important have you? You were able to fill it initially, so surely you can up we the appropriate statement at the right place to update that variable each loop you check for it. Jos0 points