if (!$[GuiName]Bindings)
{
$remapDivision[$remapCount] = "[GuiName]";
$remapName[$remapCount] = "Activate/Deacticate";
$remapCmd[$remapCount] = "[GuiName]Toggle";
$remapCount++;
$[GuiName]Bindings=true;
}
So you can bind a key to the GUI, which I would suggest, but if you insist on it being 'G' then
GlobalActionMap.bindCmd(keyboard, "G", "", "toggle[GuiName]();");
function toggle[GuiName]()
{
if([GuiName].isAwake())
canvas.popDialog([GuiName]);
else
canvas.pushDialog([GuiName]);
}