Sorry.altainta wrote:Sorry but still not working
The Main macroThe cancel Sleep Mode MacroCode: Select all
import eg xyz = "SleepNow" def SleepMode(myArgument): eg.TriggerEvent(xyz, repr(myArgument)) task = eg.scheduler.AddTask(10, SleepMode, xyz)
errorCode: Select all
<?xml version="1.0" encoding="UTF-8" ?> <EventGhost Version="1522"> <Macro Name="Show OSD: Cancel Sleep Mode"> <Action> EventGhost.ShowOSD(u'Cancel Sleep Mode', u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (255, 255, 255), (0, 0, 0), 6, (0, 0), 0, 3.0, False) </Action> <Action> EventGhost.PythonCommand(u'eg.scheduler.CancelTask(task)') </Action> <Action> EventGhost.FlushEvents() </Action> </Macro> </EventGhost>
altaintaCode: Select all
Traceback (most recent call last): Python script "12", line 2, in <module> eg.scheduler.CancelTask(task) NameError: name 'task' is not defined
I wanted to delete only a shadow copy.
The solution is simple. You must use:
eg.globals.myTask = eg.scheduler.AddTask(...)
and
eg.scheduler.CancelTask(eg.globals.myTask)
Pako