@Mahdiyar what would need to be done so this script outputs null in normal state and 1 when a key is pressed? I can’t figure it out and Bing-AI wasn’t helpful on this one either.
public class Script_Instance : GH_ScriptInstance
{
int a;
private void RunScript(bool active, out object a)
{
a = null;
Instances.DocumentEditor.KeyDown -= new KeyEventHandler(KeyDownEventHandler);
Instances.DocumentEditor.KeyUp -= new KeyEventHandler(KeyUpEventHandler);
if(active)
{
Instances.DocumentEditor.KeyDown += new KeyEventHandler(KeyDownEventHandler);
Instances.DocumentEditor.KeyUp += new KeyEventHandler(KeyUpEventHandler);
}
}
// <Custom additional code>
void KeyDownEventHandler(object sender, KeyEventArgs e)
{
if(e.KeyCode != Keys.Insert);
a = 1;
}
void KeyUpEventHandler(object sender, KeyEventArgs e)
{
if(e.KeyCode != Keys.Insert) return;
}
}
hotkey_null_1.gh (11.4 KB)