Leaderboard
Popular Content
Showing content with the highest reputation on 03/31/2019 in all areas
-
2 points
-
example 10 is also containing notepad in these example below a regex to differentiate on english and dutch version of notepad. Full library works with a string regexp in Func _UIA_getObjectByFindAll a full match In getFirstObject so if you use _UIA_getFirstObjectOfElement you will not have regex matching The difference is mainly a choice on speed over flexibility _UIA_setVar("NOTEPAD.mainwindow","classname:=Notepad") _UIA_setVar("NOTEPAD.edit","classname:=Edit") _UIA_setVar("NOTEPAD.mnuFile","name:=((File)|(Bestand))") _UIA_setVar("NOTEPAD.mnuSave","name:=((Save.*)|(Opslaan.*))") _UIA_setVar("NOTEPAD.btnClose","name:=((Close)|(Sluiten))") _UIA_setVar("NOTEPAD.dlgSave","name:=((Save as.*)|(Opslaan als.*))") _UIA_setVar("NOTEPAD.dlgSave.edtFilename","name:=((Filename:)|(Bestandsnaam:));indexrelative:=1") _UIA_setVar("NOTEPAD.dlgSave.btnSave","name:=((Save)|(Opslaan));ControlType:=Button") _UIA_setVar("NOTEPAD.dlgSave.btnYes","name:=((Yes)|(Ja));ControlType:=Button") regexptitle so will not trigger a special matching on regex it just transforms to property name and all matching with findall will use regex matching.1 point
-
As you can see, your last access date equals the creation date. By default (at least for Win7), the last access notification is disable. To enable it you need to go to the registry and modify the key : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem change NtfsDisableLastAcessUpdate from 1 to 0 Should work after (untested). Don't forget, you will need to reboot !1 point
-
Windows 8, Windows 8.1 and Windows 10 updates This is an update of the Windows 7 constants and definitions in CUIAutomation2.au3 which includes new constants and definitions added in Windows 8, Windows 8.1 and Windows 10 up to and including version 1809. All constants and definitions (both old and new) are found in UIA_Constants.au3. There is 50% more data. New CLSID_CUIAutomation8 instead of CLSID_CUIAutomation. Many new versions of the main objects $oUIAutomation and $oUIAutomationElement (abbreviated as $oUIElement in UIASpy). CUIAutomation2.au3 is still included. It's necessary to execute the existing examples. There are a few changes in UIA_Constants.au3 compared to CUIAutomation2.au3. Among other things is "dtag" changed to "dtag_". All properties are calculated in UIASpy_ElemInfo.au3. Not all old properties were calculated in the previous version of the file. In the new version, all both new and old properties are calculated. The file has become quite large. In the updated UIASpy code in the zip-file at bottom of first post, UIASpy always starts up in Windows 7 mode regardless of the Windows OS version. Even if your Windows OS version is Windows 10, UIASpy starts up in Windows 7 mode. Ie. the code generated as Sample code through the Detail info listview page and the Sample code menu can be executed under Windows XP, Windows Vista, Windows 7 and later versions. However, in Windows 7 mode, updated UIA code in newer Windows versions isn't available. Options | Windows | Mode menu If your Windows OS version is Windows 8 or later you can through the Options | Windows | Mode menu choose to generate UIA code that is compatible with a specific Windows OS version and thus access updated UIA code in this Windows version. But the code is only executable on this specific Windows version and later versions. On Windows 8 there is access to new properties, patterns, objects and methods added in Windows 8 as well as all the previous ones from Windows 7. CLSID_CUIAutomation8 is available from Windows 8. New main objects are $oUIAutomation2 and $oUIElement2. On Windows 8.1 there is access to new properties, patterns, objects and methods added in Windows 8.1 as well as all the previous ones from Windows 8 and so on. New main objects in Windows 8.1 are $oUIAutomation3 and $oUIElement3. A single new main object in first version of Windows 10 (1507) is $oUIElement4. In Windows 10 First mode, the generated code can be executed on all Windows 10 versions. New main objects in last version of Windows 10 (1809) are $oUIAutomation4 (1607), $oUIAutomation5 (1607), $oUIAutomation6 (1809), and $oUIElement5 (1703), $oUIElement6 (1703), $oUIElement7 (1703), $oUIElement8 (1803), $oUIElement9 (1809). In Windows 10 Last mode, the generated code can be executed on Windows 10 version 1809 and later. Note that $oUIAutomation6 (1809) gives access to all new methods and properties in $oUIAutomation6 and all previous methods and properties in $oUIAutomation5, $oUIAutomation4, $oUIAutomation3, $oUIAutomation2 and $oUIAutomation. See UIA_Constants.au3. And $oUIElement9 (1809) gives access to all new methods and properties in $oUIElement9 and all previous methods and properties in $oUIElement8 - $oUIElement. See UIA_Constants.au3. In UIASpy, all objects and methods are accessed through the Sample code | Objects/methods menu. Note that this menu does not differentiate between Windows versions. All objects and methods are always available. Of course, if you try to use a Windows 10 object on Windows 7, creating the object will fail. But not the other way around. Also note that there are no new methods added to UIASpy for $oUIAutomation3, 4, 5 or 6 objects. These methods are merely event handler methods not used in conventional automation, which is what UIASpy is all about. When you select Windows mode through the Options | Windows | Mode menu, UIASpy will generate correct Sample code for this Windows version and use the correct CLSID_CUIAutomation version and the correct versions of the main objects. See UIA updates. UIASpy.ini In UIASpy.ini, through the WindowsMode key, you can specify the Windows mode you want when UIASpy starts up. Use these values: Windows 7 (default), Windows 8, Windows 8.1, Windows 10 First (1507) and Windows 10 Last (1809).1 point
-
This is the exact opposite of modular programming.1 point
-
I haven't the zip file, but probably these three listings were in that zip: DragDropEvent.au3 ; =============================================================================================================================== ; File : DragDropEvent.au3 (2012/3/15) ; Purpose : Convert OLE drag-and-drop event to "Windows Message" that AutoIt3 can handle by GUIRegisterMsg ; Provide 4 message: $WM_DRAGENTER, $WM_DRAGOVER, $WM_DRAGLEAVE, and $WM_DROP ; Author : Ward ; =============================================================================================================================== #Include-once #Include <Memory.au3> #Include <SendMessage.au3> #Include <WindowsConstants.au3> ; =============================================================================================================================== ; Public Functions: ; ; DragDropEvent_Startup() ; DragDropEvent UDF startup. ; ; DragDropEvent_Register($hWnd, $hWndToReceiveMsg = $hWnd) ; Register a window or control that can be the target. $hWndToReceiveMsg is needed only when $hWnd is a control. ; ; DragDropEvent_Revoke($hWnd) ; Revokes the registration of the specified window or control. ; ; DragDropEvent_GetHWnd($wParam) ; Can invoke by all message handler, to get what window or control is the target. ; ; DragDropEvent_GetX($wParam) ; DragDropEvent_GetY($wParam) ; DragDropEvent_GetKeyState($wParam) ; Can invoke by all message handler except $WM_DRAGLEAVE, to get the modifier keys and mouse position. ; ; DragDropEvent_IsText($wParam) ; DragDropEvent_IsFile($wParam) ; Can invoke by $WM_DRAGENTER or $WM_DROP, to check what data is being dragged. ; ; DragDropEvent_GetText($wParam) ; DragDropEvent_GetFile($wParam) ; Can invoke by $WM_DRAGENTER or $WM_DROP, to get related data. Path of file is splited by "|". ; ; =============================================================================================================================== ; =============================================================================================================================== ; Internal Functions: ; ; IDropTarget_QueryInterface($pSelf, $pRIID, $pObj) ; IDropTarget_AddRef($pSelf) ; IDropTarget_Release($pSelf) ; IDropTarget_DragEnter($pSelf, $DataObj, $KeyState, $X, $Y, $pEffect) ; IDropTarget_DragLeave($pSelf) ; IDropTarget_DragOver($pSelf, $KeyState, $X, $Y, $pEffect) ; IDropTarget_Drop($pSelf, $DataObj, $KeyState, $X, $Y, $pEffect) ; IDropTarget_SetEffect($pEffect, $Value) ; Methods of IDropTarget interface. ; ; IDropTarget_SetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) ; IDropTarget_GetHWnd($pSelf, ByRef $hWnd, ByRef $hWndToReceiveMsg) ; To set and get data store in IDropTarget interface. ; ; DataObject_QueryText($DataObj) ; DataObject_QueryFile($DataObj) ; DataObject_GetText($DataObj) ; DataObject_GetFile($DataObj) ; Functions to handle DataObject. ; ; DragDropEvent_InfoCreate($hWnd, $DataObj, $KeyState, $X, $Y) ; DragDropEvent_Get($wParam, $Name) ; Functions to handle infomation data for DragDropEvent. ; ; __CreateCOMInterface($sFunctionPrefix, $dtagInterface, $fNoUnknown = False, $ExtraSpace = 0) ; To create vtable of a COM interface. Modify from _AutoItObject_ObjectFromDtag. ; ; =============================================================================================================================== ; =============================================================================================================================== ; Global const and variables ; =============================================================================================================================== ; Define 4 kind of DragDropEvent: DragEnter, DragOver, DragLeave, and Drop Global Enum $WM_DRAGENTER = $WM_USER + 0x1001, $WM_DRAGOVER, $WM_DRAGLEAVE, $WM_DROP ; Message handler return one of these flags, which indicates what the result of the drop operation would be. Global Enum $DROPEFFECT_NONE = 0, $DROPEFFECT_COPY = 1, $DROPEFFECT_MOVE = 2, $DROPEFFECT_LINK = 4, $DROPEFFECT_SCROLL = 0x80000000 Global Const $IID_IDataObject = "{0000010e-0000-0000-C000-000000000046}" Global Const $dtagIDropTarget = "DragEnter hresult(ptr;uint;uint64;ptr);DragOver hresult(uint;uint64;ptr);DragLeave hresult();Drop hresult(ptr;uint;uint64;ptr);" Global Const $dtagIDataObject = "GetData hresult(struct*;struct*);GetDataHere hresult(struct*;struct*);QueryGetData hresult(struct*);GetCanonicalFormatEtc hresult(struct*;struct*);SetData hresult(struct*;struct*;int);EnumFormatEtc hresult(uint;ptr);DAdvise hresult(struct*;uint;ptr;ptr);DUnadvise hresult(uint);EnumDAdvise hresult(ptr);" Global Const $tagFORMATETC = "struct;uint Format;ptr ptd;uint Aspect;int lindex;uint tymed;endstruct" Global Const $tagSTGMEDIUM = "struct;uint tymed;ptr hGlobal;ptr UnkForRelease;endstruct" Global Const $tagDragDropEventInfo = "ptr hwnd;ptr DataObj;uint KeyState;uint x;uint y" Global Const $__KERNEL32_DLL = DllOpen("kernel32.dll") Global Const $__OLE32_DLL = DllOpen("ole32.dll") Global $__IDropTargetLen = 0 ; =============================================================================================================================== ; DragDropEvent startup and register functions ; =============================================================================================================================== Func DragDropEvent_Startup() ; If @AutoItVersion < "3.3.8.0" Then Exit MsgBox(16, "DragDropEvent Fail", "Require AutoIt Version 3.3.8.0 at least") DllCall($__OLE32_DLL, "int", "OleInitialize", "ptr", 0) EndFunc Func DragDropEvent_Register($hWnd, $hWndToReceiveMsg = Default) If IsKeyword($hWndToReceiveMsg) Then $hWndToReceiveMsg = $hWnd Local $IDropTarget = __CreateCOMInterface("IDropTarget_", $dtagIDropTarget, True, 2) ; add 2 extra space to store hWnd If $IDropTarget Then $__IDropTargetLen = @Extended IDropTarget_SetHWnd($IDropTarget, $hWnd, $hWndToReceiveMsg) DllCall($__OLE32_DLL, "int", "RegisterDragDrop", "hwnd", $hWnd, "ptr", $IDropTarget) EndIf EndFunc Func DragDropEvent_Revoke($hWnd) DllCall($__OLE32_DLL, "int", "RevokeDragDrop", "hwnd", $hWnd) EndFunc ; =============================================================================================================================== ; Methods of IDropTarget interface ; =============================================================================================================================== Func IDropTarget_QueryInterface($pSelf, $pRIID, $pObj) Return 0x80004002 ; E_NOINTERFACE EndFunc Func IDropTarget_AddRef($pSelf) EndFunc Func IDropTarget_Release($pSelf) DllCall($__OLE32_DLL, "none", "CoTaskMemFree", "ptr", $pSelf) EndFunc Func IDropTarget_DragEnter($pSelf, $DataObj, $KeyState, $Point, $pEffect) Local $hWnd, $hWndToReceiveMsg IDropTarget_GetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) Local $X = BitAND($Point, 0xFFFFFFFF), $Y = Dec(StringTrimRight(Hex($Point), 8)) Local $Info = DragDropEvent_InfoCreate($hWnd, $DataObj, $KeyState, $X, $Y) Local $Ret = _SendMessage($hWndToReceiveMsg, $WM_DRAGENTER, DllStructGetPtr($Info), 0) DllStructSetData(DllStructCreate("dword", $pEffect), 1, $Ret) EndFunc Func IDropTarget_DragLeave($pSelf) Local $hWnd, $hWndToReceiveMsg IDropTarget_GetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) Local $Info = DragDropEvent_InfoCreate($hWnd, 0, 0, 0, 0) _SendMessage($hWndToReceiveMsg, $WM_DRAGLEAVE, DllStructGetPtr($Info), 0) EndFunc Func IDropTarget_DragOver($pSelf, $KeyState, $Point, $pEffect) Local $hWnd, $hWndToReceiveMsg IDropTarget_GetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) Local $X = BitAND($Point, 0xFFFFFFFF), $Y = Dec(StringTrimRight(Hex($Point), 8)) Local $Info = DragDropEvent_InfoCreate($hWnd, 0, $KeyState, $X, $Y) Local $Ret = _SendMessage($hWndToReceiveMsg, $WM_DRAGOVER, DllStructGetPtr($Info), 0) DllStructSetData(DllStructCreate("dword", $pEffect), 1, $Ret) EndFunc Func IDropTarget_Drop($pSelf, $DataObj, $KeyState, $Point, $pEffect) Local $hWnd, $hWndToReceiveMsg IDropTarget_GetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) Local $X = BitAND($Point, 0xFFFFFFFF), $Y = Dec(StringTrimRight(Hex($Point), 8)) Local $Info = DragDropEvent_InfoCreate($hWnd, $DataObj, $KeyState, $X, $Y) Local $Ret = _SendMessage($hWndToReceiveMsg, $WM_DROP, DllStructGetPtr($Info), 0) DllStructSetData(DllStructCreate("dword", $pEffect), 1, $Ret) EndFunc Func IDropTarget_SetHWnd($pSelf, $hWnd, $hWndToReceiveMsg) Local $Buffer = DllStructCreate("ptr[" & ($__IDropTargetLen + 2) & "]", $pSelf) DllStructSetData($Buffer, 1, $hWnd, $__IDropTargetLen + 1) DllStructSetData($Buffer, 1, $hWndToReceiveMsg, $__IDropTargetLen + 2) EndFunc Func IDropTarget_GetHWnd($pSelf, ByRef $hWnd, ByRef $hWndToReceiveMsg) Local $Buffer = DllStructCreate("ptr[" & ($__IDropTargetLen + 2) & "]", $pSelf) $hWnd = DllStructGetData($Buffer, 1, $__IDropTargetLen + 1) $hWndToReceiveMsg = DllStructGetData($Buffer, 1, $__IDropTargetLen + 2) EndFunc ; =============================================================================================================================== ; Functions to handle DataObject ; =============================================================================================================================== Func DataObject_QueryText($DataObj) Local $IDataObj = ObjCreateInterface($DataObj, $IID_IDataObject, $dtagIDataObject) If Not IsObj($IDataObj) Then Return -1 $IDataObj.AddRef() Local $FORMATETC = DllStructCreate($tagFORMATETC) DllStructSetData($FORMATETC, "Format", 13) ; 13 = CF_UNICODETEXT DllStructSetData($FORMATETC, "Aspect", 1) DllStructSetData($FORMATETC, "lindex", -1) DllStructSetData($FORMATETC, "tymed", 1) ; 1 = TYMED_HGLOBAL Local $Ret = $IDataObj.QueryGetData($FORMATETC) If $Ret <> 0 Then DllStructSetData($FORMATETC, "Format", 1) ; 1 = CF_TEXT $Ret = $IDataObj.QueryGetData($FORMATETC) EndIf Return $Ret EndFunc Func DataObject_QueryFile($DataObj) Local $IDataObj = ObjCreateInterface($DataObj, $IID_IDataObject, $dtagIDataObject) If Not IsObj($IDataObj) Then Return -1 $IDataObj.AddRef() Local $FORMATETC = DllStructCreate($tagFORMATETC) DllStructSetData($FORMATETC, "Format", 15) ; 15 = CF_HDROP DllStructSetData($FORMATETC, "Aspect", 1) DllStructSetData($FORMATETC, "lindex", -1) DllStructSetData($FORMATETC, "tymed", 1) ; 1 = TYMED_HGLOBAL Return $IDataObj.QueryGetData($FORMATETC) EndFunc Func DataObject_GetText($DataObj) Local $IDataObj = ObjCreateInterface($DataObj, $IID_IDataObject, $dtagIDataObject) If Not IsObj($IDataObj) Then Return -1 $IDataObj.AddRef() Local $FORMATETC = DllStructCreate($tagFORMATETC) Local $STGMEDIUM = DllStructCreate($tagSTGMEDIUM) DllStructSetData($FORMATETC, "Format", 13) ; 13 = CF_UNICODETEXT DllStructSetData($FORMATETC, "Aspect", 1) DllStructSetData($FORMATETC, "lindex", -1) DllStructSetData($FORMATETC, "tymed", 1) ; 1 = TYMED_HGLOBAL Local $IsUnicode = True Local $Ret = $IDataObj.QueryGetData($FORMATETC) If $Ret <> 0 Then $IsUnicode = False DllStructSetData($FORMATETC, "Format", 1) ; 1 = CF_TEXT $Ret = $IDataObj.QueryGetData($FORMATETC) EndIf If $Ret <> 0 Then Return SetError(1, 0, "") Local $Error = 1, $Text = "" If $IDataObj.GetData($FORMATETC, $STGMEDIUM) = 0 Then If DllStructGetData($STGMEDIUM, "tymed") = 1 Then Local $Ptr = _MemGlobalLock(DllStructGetData($STGMEDIUM, "hGlobal")) Local $Tag If $IsUnicode Then $Tag = "wchar[" & (_MemGlobalSize($Ptr) / 2) & "]" Else $Tag = "char[" & _MemGlobalSize($Ptr) & "]" EndIf $Text = DllStructGetData(DllStructCreate($Tag, $Ptr), 1) _MemGlobalUnlock($Ptr) If DllStructGetData($STGMEDIUM, "UnkForRelease") = 0 Then _MemGlobalFree($Ptr) $Error = 0 EndIf EndIf Return SetError($Error, 0, $Text) EndFunc Func DataObject_GetFile($DataObj) Local $IDataObj = ObjCreateInterface($DataObj, $IID_IDataObject, $dtagIDataObject) If Not IsObj($IDataObj) Then Return -1 $IDataObj.AddRef() Local $FORMATETC = DllStructCreate($tagFORMATETC) Local $STGMEDIUM = DllStructCreate($tagSTGMEDIUM) DllStructSetData($FORMATETC, "Format", 15) ; 15 = CF_HDROP DllStructSetData($FORMATETC, "Aspect", 1) DllStructSetData($FORMATETC, "lindex", -1) DllStructSetData($FORMATETC, "tymed", 1) ; 1 = TYMED_HGLOBAL Local $Error = 1, $FileList = "" If $IDataObj.GetData($FORMATETC, $STGMEDIUM) = 0 Then If DllStructGetData($STGMEDIUM, "tymed") = 1 Then Local $Ptr = _MemGlobalLock(DllStructGetData($STGMEDIUM, "hGlobal")) Local $StrPtr = $Ptr + DllStructGetData(DllStructCreate("dword", $Ptr), 1) Do Local $Ret = DllCall($__KERNEL32_DLL, "uint", "lstrlenW", "ptr", $StrPtr) Local $StrLen = $Ret[0] If $StrLen Then Local $Str = DllStructGetData(DllStructCreate("wchar[" & $StrLen & "]", $StrPtr), 1) $FileList &= $Str & "|" $StrPtr += $StrLen * 2 + 2 EndIf Until $StrLen = 0 If StringRight($FileList, 1) = "|" Then $FileList = StringTrimRight($FileList, 1) _MemGlobalUnlock($Ptr) If DllStructGetData($STGMEDIUM, "UnkForRelease") = 0 Then _MemGlobalFree($Ptr) $Error = 0 EndIf EndIf Return SetError($Error, 0, $FileList) EndFunc ; =============================================================================================================================== ; Functions to handle infomation data for DragDropEvent ; =============================================================================================================================== Func DragDropEvent_InfoCreate($hWnd, $DataObj, $KeyState, $X, $Y) Local $Info = DllStructCreate($tagDragDropEventInfo) DllStructSetData($Info, "hwnd", $hWnd) DllStructSetData($Info, "DataObj", $DataObj) DllStructSetData($Info, "KeyState", $KeyState) DllStructSetData($Info, "x", $X) DllStructSetData($Info, "y", $Y) Return $Info EndFunc Func DragDropEvent_Get($wParam, $Name) If Not $wParam Then Return SetError(1, 0, 0) Local $Info = DllStructCreate($tagDragDropEventInfo, $wParam) Return DllStructGetData($Info, $Name) EndFunc Func DragDropEvent_GetHWnd($wParam) Local $Ret = DragDropEvent_Get($wParam, "hwnd") Return SetError(@Error, 0, $Ret) EndFunc Func DragDropEvent_GetX($wParam) Local $Ret = DragDropEvent_Get($wParam, "x") Return SetError(@Error, 0, $Ret) EndFunc Func DragDropEvent_GetY($wParam) Local $Ret = DragDropEvent_Get($wParam, "y") Return SetError(@Error, 0, $Ret) EndFunc Func DragDropEvent_GetKeyState($wParam) Local $Ret = DragDropEvent_Get($wParam, "KeyState") Return SetError(@Error, 0, $Ret) EndFunc Func DragDropEvent_IsText($wParam) Local $DataObj = DragDropEvent_Get($wParam, "DataObj") Return DataObject_QueryText($DataObj) = 0 EndFunc Func DragDropEvent_IsFile($wParam) Local $DataObj = DragDropEvent_Get($wParam, "DataObj") Return DataObject_QueryFile($DataObj) = 0 EndFunc Func DragDropEvent_GetText($wParam) Local $DataObj = DragDropEvent_Get($wParam, "DataObj") Return DataObject_GetText($DataObj) EndFunc Func DragDropEvent_GetFile($wParam) Local $DataObj = DragDropEvent_Get($wParam, "DataObj") Return DataObject_GetFile($DataObj) EndFunc ; =============================================================================================================================== ; Functions to create COM interface ; =============================================================================================================================== Func __CreateCOMInterface($sFunctionPrefix, $dtagInterface, $fNoUnknown = False, $ExtraSpace = 0) ; Original is _AutoItObject_ObjectFromDtag in AutoItObject.au3 by AutoItObject-Team ; Modify by Ward Local Const $__PtrSize = DllStructGetSize(DllStructCreate('ptr', 1)) Local Const $dtagIUnknown = "QueryInterface hresult(ptr;ptr*);AddRef dword();Release dword();" If $fNoUnknown Then $dtagInterface = $dtagIUnknown & $dtagInterface Local $sMethods = StringReplace(StringRegExpReplace($dtagInterface, "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF) If $sMethods = $dtagInterface Then $sMethods = StringReplace(StringRegExpReplace($dtagInterface, "\h*(\w+)\h*(;|;*\z)", "$1\|" & @LF), ";" & @LF, @LF) $sMethods = StringTrimRight($sMethods, 1) $sMethods = StringReplace(StringReplace(StringReplace(StringReplace($sMethods, "object", "idispatch"), "variant*", "ptr"), "hresult", "long"), "bstr", "ptr") Local $aMethods = StringSplit($sMethods, @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback Local $AllocSize = $__PtrSize * ($iUbound + 1 + $ExtraSpace) Local $Ret = DllCall($__OLE32_DLL, "ptr", "CoTaskMemAlloc", "uint_ptr", $AllocSize) If @error Then Return SetError(1, 0, 0) Local $AllocPtr = $Ret[0] Local $tInterface = DllStructCreate("ptr[" & $iUbound + 1 & "]", $AllocPtr) If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sFunctionPrefix & $sNamePart $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams ; To avoid repeat allocate the same callback, a memory leakage $hCallback = Eval(":Callback:" & $sMethod) If Not $hCallback Then $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) Assign(":Callback:" & $sMethod, $hCallback, 2) EndIf DllStructSetData($tInterface, 1, DllCallbackGetPtr($hCallback), $i + 2) Next DllStructSetData($tInterface, 1, $AllocPtr + $__PtrSize) ; Interface method pointers are actually pointer size away Return SetExtended($iUbound + 1, $AllocPtr) ; Return interface size as @Extended for access extra space EndFunc DragDropEvent_Example_1.au3 ; =============================================================================================================================== ; File : DragDropEvent_Example_1.au3 (2012/3/9) ; Purpose : Demonstrate the usage of DragDropEvent UDF ; Author : Ward ; =============================================================================================================================== #Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> #Include "DragDropEvent.au3" Opt("MustDeclareVars", 1) DragDropEvent_Startup() Main() Exit Func Main() Local $MainWin = GUICreate("DragDropEvent Example", 380, 130, -1, -1, -1, $WS_EX_TOPMOST) GUISetFont(12, 900) GUICtrlCreateLabel("(Drop text or files on me)", 40, 40) DragDropEvent_Register($MainWin) GUIRegisterMsg($WM_DRAGENTER, "OnDragDrop") GUIRegisterMsg($WM_DRAGOVER, "OnDragDrop") GUIRegisterMsg($WM_DRAGLEAVE, "OnDragDrop") GUIRegisterMsg($WM_DROP, "OnDragDrop") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() EndFunc Func OnDragDrop($hWnd, $Msg, $wParam, $lParam) Static $DropAccept Switch $Msg Case $WM_DRAGENTER, $WM_DROP ToolTip("") Select Case DragDropEvent_IsFile($wParam) If $Msg = $WM_DROP Then Local $FileList = DragDropEvent_GetFile($wParam) MsgBox(262144, "DragDropEvent", StringReplace($FileList, "|", @LF)) EndIf $DropAccept = $DROPEFFECT_COPY Case DragDropEvent_IsText($wParam) If $Msg = $WM_DROP Then MsgBox(262144, "DragDropEvent", DragDropEvent_GetText($wParam)) EndIf $DropAccept = $DROPEFFECT_COPY Case Else $DropAccept = $DROPEFFECT_NONE EndSelect Return $DropAccept Case $WM_DRAGOVER Local $X = DragDropEvent_GetX($wParam) Local $Y = DragDropEvent_GetY($wParam) ToolTip("(" & $X & "," & $Y & ")") Return $DropAccept Case $WM_DRAGLEAVE ToolTip("") EndSwitch EndFunc DragDropEvent_Example_2.au3 ; =============================================================================================================================== ; File : DragDropEvent_Example_2.au3 (2012/3/9) ; Purpose : Demonstrate the usage of DragDropEvent UDF ; Author : Ward ; =============================================================================================================================== #Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> #Include "DragDropEvent.au3" Opt("MustDeclareVars", 1) Global $Button1, $Button2, $Button3, $Button4 DragDropEvent_Startup() Main() Exit Func Main() Local $MainWin = GUICreate("DragDropEvent Example", 460, 400, -1, -1, -1, $WS_EX_TOPMOST) GUISetFont(12, 900) $Button1 = GUICtrlCreateButton("Drop Text", 20, 20, 200, 150) $Button2 = GUICtrlCreateButton("Drop Files", 240, 20, 200, 150) $Button3 = GUICtrlCreateButton("Drop Anything", 20, 190, 200, 150) $Button4 = GUICtrlCreateButton("Don't Drop", 240, 190, 200, 150) GUICtrlCreateLabel("(Click button to revoke the target)", 40, 350) DragDropEvent_Register(GUICtrlGetHandle($Button1), $MainWin) DragDropEvent_Register(GUICtrlGetHandle($Button2), $MainWin) DragDropEvent_Register(GUICtrlGetHandle($Button3), $MainWin) DragDropEvent_Register(GUICtrlGetHandle($Button4), $MainWin) GUIRegisterMsg($WM_DRAGENTER, "OnDragDrop") GUIRegisterMsg($WM_DRAGOVER, "OnDragDrop") GUIRegisterMsg($WM_DRAGLEAVE, "OnDragDrop") GUIRegisterMsg($WM_DROP, "OnDragDrop") GUISetState(@SW_SHOW) While 1 Local $Msg = GUIGetMsg() Switch $Msg Case $Button1, $Button2, $Button3, $Button4 DragDropEvent_Revoke(GUICtrlGetHandle($Msg)) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc Func OnDragDrop($hWnd, $Msg, $wParam, $lParam) Static $DropAccept Switch $Msg Case $WM_DRAGENTER, $WM_DROP ToolTip("") Local $Target = DragDropEvent_GetHWnd($wParam) Select Case DragDropEvent_IsFile($wParam) If $Target = GUICtrlGetHandle($Button1) Or $Target = GUICtrlGetHandle($Button4) Then $DropAccept = $DROPEFFECT_NONE Else If $Msg = $WM_DROP Then Local $FileList = DragDropEvent_GetFile($wParam) MsgBox(262144, "DragDropEvent", StringReplace($FileList, "|", @LF)) EndIf $DropAccept = $DROPEFFECT_COPY EndIf Case DragDropEvent_IsText($wParam) If $Target = GUICtrlGetHandle($Button2) Or $Target = GUICtrlGetHandle($Button4) Then $DropAccept = $DROPEFFECT_NONE Else If $Msg = $WM_DROP Then MsgBox(262144, "DragDropEvent", DragDropEvent_GetText($wParam)) EndIf $DropAccept = $DROPEFFECT_COPY EndIf Case Else $DropAccept = $DROPEFFECT_NONE EndSelect Return $DropAccept Case $WM_DRAGOVER Local $X = DragDropEvent_GetX($wParam) Local $Y = DragDropEvent_GetY($wParam) Local $KeyState = DragDropEvent_GetKeyState($wParam) ToolTip("(" & $X & "," & $Y & "," & $KeyState & ")") Return $DropAccept Case $WM_DRAGLEAVE ToolTip("") EndSwitch EndFunc1 point
-
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