tatane 0 Report post Posted March 22 (edited) Hi, I'm trying to get the handle of the control id return by GUICtrlCreateObj. I know that GUICtrlGetHandle can't retrieve it. Is there another way ? I have to identify the control object I clicked on to change is size and there is several control object (same type) in my window. I already am able to get this handle when I click the control, what I need is get the handle as soon as i'm creating the control object. Thanks. Edited March 22 by tatane Share this post Link to post Share on other sites
Subz 291 Report post Posted March 22 So if you use something like $idObject = GuiCtrlCreateObj(...) why can't you use $idObject to make your changes? Or am I missing something. Share this post Link to post Share on other sites
tatane 0 Report post Posted March 22 Because when I click on the control object (let's say a rectangle in my GUI), I don't know what object it is. So I want to compare the handle/control id of this object to the one I created before. The problem is when I create it via GuiCtrlCreateObj(...) , I get an autoit control identifier and no handle to compare. I should precise that I create more than one gui control object through a loop and the only thing I can keep track is the autoit control identifier. Share this post Link to post Share on other sites
Subz 291 Report post Posted March 22 Can you post your code? Share this post Link to post Share on other sites
tatane 0 Report post Posted March 22 I'm using a dll (vncx.dll) to create COM Object. expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <Misc.au3> #include <WinAPI.au3> ;~ #include <Array.au3> ; Ouvrir la DLL vncx.dll avec OLE/COM Object Viewer (elle doit être enregistrée dans windows au préalable : REGSVR32.EXE VNCX.DLL Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") $Form1 = GUICreate("Test VNCX", 1300, 800) GUISetState(@SW_SHOW) $port = "5900" $password = "xxxxxxx" $VNCViewer1 = ObjCreate("VNCX.VNCViewer") ; "{EFAB8D1F-794A-4C47-B834-53653E05A441}" $VNCViewerctrlobj1 = GUICtrlCreateObj($VNCViewer1, 5, 5, 300, 300) ;~ GUICtrlSetState($VNCViewerctrlobj1, $GUI_DISABLE) ; utile pour du view only ; Gestion des évènements $VNCViewerEventobj1 = ObjEvent($VNCViewer1, "IVNCViewer_") $VNCViewer1.Connect("192.168.0.1", $port, $password, "") $VNCViewer1.Stretch = True ;~ $VNCViewer1.Display = 0 $VNCViewer1.StretchX(1, 3) $VNCViewer1.StretchY(1, 3) ;~ $VNCViewer1.Alignment = 5 Sleep(2000) $VNCViewer1.Start GUICtrlSetPos($VNCViewerctrlobj1, 5, 5, $VNCViewer1.ViewWidth, $VNCViewer1.ViewHeight) $VNCViewer1.Refresh($VNCViewer1.ViewLeft, $VNCViewer1.ViewTop, $VNCViewer1.ViewWidth, $VNCViewer1.ViewHeight) ;~ $VNCViewer2 = ObjCreate("VNCX.VNCViewer") ; "{EFAB8D1F-794A-4C47-B834-53653E05A441}" ;~ $VNCViewerctrlobj2 = GUICtrlCreateObj($VNCViewer2, 400, 5, 100, 100) ;~ ; Gestion des évènements ;~ $VNCViewerEventobj2 = ObjEvent($VNCViewer2, "IVNCViewer_") ;~ $VNCViewer2.Connect("192.168.0.2", $port, $password, "") ;~ $VNCViewer2.Stretch = True ;~ $VNCViewer2.Display = 1 ;~ $VNCViewer2.StretchX(1, 3) ;~ $VNCViewer2.StretchY(1, 3) ;~ $VNCViewer2.Alignment = 5 ;~ Sleep(2000) ;~ $VNCViewer2.Start ;~ GUICtrlSetPos($VNCViewerctrlobj2, 5, 5, $VNCViewer2.ViewWidth, $VNCViewer2.ViewHeight) ;~ $VNCViewer2.Refresh($VNCViewer2.ViewLeft, $VNCViewer2.ViewTop, $VNCViewer2.ViewWidth, $VNCViewer2.ViewHeight) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Deconnection_VNCX() Exit EndSwitch WEnd ; Evènement : La connexion vient d'être établie Func IVNCViewer_Connected($ServerName) ConsoleWrite("Serveur " & $ServerName & " connecté" & @CRLF) EndFunc Func _Deconnection_VNCX() $VNCViewer1.Stop $VNCViewer1.Disconnect ;~ $VNCViewer2.Stop ;~ $VNCViewer2.Disconnect EndFunc Func IVNCViewer_BeforeMouseUp($VNCXButtonsEnum, $VNCXModifiersEnum, $X, $Y, $VNCXActionsEnum) $hCtrlHnd = ControlGetHandle("", "", "") ConsoleWrite("Ctrl Id:" & _WinAPI_GetDlgCtrlID($hCtrlHnd) & @TAB & "Ctrl Handle:" & $hCtrlHnd & @TAB & "Ctrl Class:" & _WinAPI_GetClassName($hCtrlHnd) & @CRLF) EndFunc ; Evènement : Une erreur est survenue Func IVNCViewer_Error($VNCXErrorsNumber, $ErrorMessage, $VARIANT) ConsoleWrite("$VNCXErrorsNumber=" & $VNCXErrorsNumber & " $ErrorMessage =" & $ErrorMessage & " $VARIANT=" & $VARIANT & @CRLF) EndFunc ; Evènement : Un problème est survenue Func IVNCViewer_Warning($VNCXWarningNumber, $WarningMessage, $VARIANT) ConsoleWrite("$VNCXWarningNumber=" & $VNCXWarningNumber & " $WarningMessage =" & $WarningMessage & " $VARIANT=" & $VARIANT & @CRLF) EndFunc ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc The object is hard coded for testing. The comparison should be placed in the IVNCViewer_BeforeMouseUp function (where I detect the click and get the handle). Share this post Link to post Share on other sites