Focus in a component with Python

Hello everyone, I am trying to make focus in a component in order to do double click with the script. I don´t know if the command focus is the correct I tried to do a restore view but I couldn't. For now I have this:

import ctypes
import Grasshopper as gh
import time


if Run == True:
    SetCursorPos = ctypes.windll.user32.SetCursorPos
    mouse_event = ctypes.windll.user32.mouse_event

    def left_click(x, y, clicks=1):
        SetCursorPos(x, y)
        for i in xrange(clicks):
            mouse_event(2, 0, 0, 0, 0)
            mouse_event(4, 0, 0, 0, 0)

    for i in ghenv.Component.OnPingDocument().Objects:
        if i.NickName== "Galapagos":
            gh.GUI.Canvas.GH_Viewport.Focus(i)

    time.sleep(2)

    x= int(a/2)
    y = int(b/2)
    left_click(x,y,2)

  • up

    Giulio Piacentino

    Hi Miguel

    I am sorry but I do not understand what you are trying to do. Could you clarify?

    Thanks,

    Giulio
    --
    Giulio Piacentino
    for Robert McNeel & Associates
    giulio@mcneel.com

    4
  • up

    Miguel

    Finally I could do what I want.
    It has some issues, but works. I leave the code inside the file.