FireFox Posted August 3, 2013 Share Posted August 3, 2013 (edited) Hi, I noticed that the GUI handle is converted to Int32 after an object function call, the object in question is the ITaskBarList3 and the function is SetProgressState. Edit: In fact it occurs with any ITaskBarList3 object function. Here is a small reproducer : expandcollapse popup#include <GUIConstantsEx.au3> #include "AutoItObject.au3" ;http://www.autoitscript.com/forum/topic/110379-autoitobject-udf/ #include <WinAPI.au3> _AutoItObject_StartUp() OnAutoItExitRegister("OnAutoItExit") Global Const $TBPF_NOPROGRESS = 0, $TBPF_INDETERMINATE = 0x1, $TBPF_NORMAL = 0x2, $TBPF_ERROR = 0x4, $TBPF_PAUSED = 0x8 Global $_oTB3, $_blITaskBar3Ready = False Global $_hGUI = GUICreate("MyGUI") _ITaskBarList3_Init($_oTB3) GUISetState() _ITaskBarList3_SetProgress() While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIDelete() Func OnAutoItExit() $_oTB3 = 0 _AutoItObject_Shutdown(True) EndFunc ;original code by wraithdu Func _ITaskBarList3_Init(ByRef $_oTB3) ; works only on Win7+ If @OSBuild < 6701 Then Return 0 ; get interfaces Local $CLSID_TaskBarlist = _AutoItObject_CLSIDFromString("{56FDF344-FD6D-11D0-958A-006097C9A090}") ; ITaskbarList3: http://msdn.microsoft.com/en-us/library/dd391692(VS.85).aspx Local $IID_ITaskBarList3 = _AutoItObject_CLSIDFromString("{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}") ; create the ITaskbarList3 interface instance Local $pTB3 = 0 _AutoItObject_CoCreateInstance(DllStructGetPtr($CLSID_TaskBarlist), 0, 1, DllStructGetPtr($IID_ITaskBarList3), $pTB3) If Not $pTB3 Then Return 0 ; setup AIO wrapper for the interface Local $tagInterface = _ "QueryInterface long(ptr;ptr;ptr);" & _ "AddRef ulong();" & _ "Release ulong();" & _ "HrInit long();" & _ "AddTab long(hwnd);" & _ "DeleteTab long(hwnd);" & _ "ActivateTab long(hwnd);" & _ "SetActiveAlt long(hwnd);" & _ "MarkFullscreenWindow long(hwnd;int);" & _ "SetProgressValue long(hwnd;uint64;uint64);" & _ "SetProgressState long(hwnd;int);" & _ "RegisterTab long(hwnd;hwnd);" & _ "UnregisterTab long(hwnd);" & _ "SetTabOrder long(hwnd;hwnd);" & _ "SetTabActive long(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons long(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons long(hwnd;uint;ptr);" & _ "ThumbBarSetImageList long(hwnd;ptr);" & _ "SetOverlayIcon long(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip long(hwnd;wstr);" & _ "SetThumbnailClip long(hwnd;ptr);" ; create the AIO object using the wrapper $_oTB3 = _AutoItObject_WrapperCreate($pTB3, $tagInterface) If IsObj($_oTB3) = 0 Then Return 0 ; call the HrInit method to initialize the ITaskbarList3 interface $_oTB3.HrInit() ; register to receive the message that our button is ready GUIRegisterMsg(_WinAPI_RegisterWindowMessage("TaskbarButtonCreated"), "_TaskbarReady") Return 1 EndFunc ;==>_ITaskBarList3_Init Func _ITaskBarList3_SetProgress($iTaskBarState = $TBPF_INDETERMINATE, $iTaskBarValue = -1) If Not $_blITaskBar3Ready Then Return 0 ConsoleWrite("Before: " & VarGetType($_hGUI) & ": " & $_hGUI & @CrLf) $_oTB3.SetProgressState($_hGUI, $iTaskBarState) ConsoleWrite("After: " & VarGetType($_hGUI) & ": " & $_hGUI & @CrLf) If $iTaskBarValue <> -1 _ And $iTaskBarState <> $TBPF_INDETERMINATE _ And $iTaskBarState <> $TBPF_NOPROGRESS Then $_oTB3.SetProgressValue($_hGUI, $iTaskBarValue, 100) EndIf EndFunc ;==>_ITaskBarList3_SetProgress Func _TaskbarReady($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Switch $hWnd Case $_hGUI ; the taskbar button is ready $_blITaskBar3Ready = True EndSwitch EndFunc ;==>_TaskbarReady Can someone explain to me this behaviour? Br, FireFox. Edited August 3, 2013 by FireFox Link to comment Share on other sites More sharing options...
jaberwacky Posted August 3, 2013 Share Posted August 3, 2013 Only thing I can figure is that SetProgressState uses the gui handle as an Int32 which changes it to that because it's a variant? Set the gui handle to const and it doesn't happen. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
FireFox Posted August 3, 2013 Author Share Posted August 3, 2013 Set the gui handle to const and it doesn't happen.It's a workaround that does not fit me... Link to comment Share on other sites More sharing options...
jaberwacky Posted August 3, 2013 Share Posted August 3, 2013 Use Ptr()? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
FireFox Posted August 3, 2013 Author Share Posted August 3, 2013 I mean it does not fix the original problem. Link to comment Share on other sites More sharing options...
Solution trancexx Posted August 3, 2013 Solution Share Posted August 3, 2013 First of all don't use AutoItObject for this when you have built-in functions. Built-in function would be ObjCreateInterface() and I believe Beege posted few examples. Then ask questions. This way you actually get anwers about the wrong things. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
FireFox Posted August 3, 2013 Author Share Posted August 3, 2013 I believe Beege posted few examples.That's right! I was not aware of it and it works like a charm I abandon this code.Br, FireFox. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now