【C #】Click button


Hello everyone
I want to use C# to click Button component.I cannot execute MyMouseDown and MyMouseUp methods at the same time.This will keep the Button in the “MouseUp” state。
like this

I want the result

This is my code:
ClickButton.gh (5.9 KB)

Thanks for any suggestions.

(David Rutten) #2

You are not allowed to expire objects during a solution. That is the first problem you must solve.


Hi David
This can solve expire objects during a solution,Can you give me updated advice?
This is my code:
ClickButton.gh (7.6 KB)

(David Rutten) #4

Just so I understand what you’re trying to do, you have one button and when that button is pressed you want to trigger both a press and a release on some other button? Because I have my doubts that’s even reliably possible.


Yes,I want to use C# to dynamically click this Button.I can now press the button, but I cannot release this button.


If you use a Boolean Toogle instead of a Button on the Kangaroo solver, you could do something like this (in GHPython, but should be more or less the same in C#):

180317_FlipBooleanToggles_00.gh (4.4 KB)

Which flips the value of the two named boolean toggles when single-clicking the FlipToggles button. So double-clicking this button would be equivalent to actually “pushing” a button. That all got a bit meta, apologies.

(David Rutten) #7

Why not just output a boolean from your C# component instead. Then you don’t have to worry about solutions and callbacks and schedules.