Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

eg hangs on script second run

If you have a question or need help, this is the place to be.
Post Reply
qvan
Posts: 2
Joined: Sun Nov 03, 2013 11:30 am

eg hangs on script second run

Post by qvan »

hello
could you help me with my problem?
code for first run work fine (save screenshot). on second buttonpress EG do nothing (interface does not locking i can configure and so on) and then in 1 min windows close EG with error
i'm new in phyton but i think that code is ok and problem in threads or some with memory, access or rights

win7 64, EG 0.4.1 r1640
ðæðÁðÀÐïð╝ÐÅð¢ð¢Ðïð╣.png
ðæðÁðÀÐïð╝ÐÅð¢ð¢Ðïð╣.png (3.03 KiB) Viewed 1548 times

Code: Select all

import wx, ctypes, datetime
 
app = wx.PySimpleApp()
 
SM_XVIRTUALSCREEN = 76
SM_YVIRTUALSCREEN = 77
SM_CXVIRTUALSCREEN = 78
SM_CYVIRTUALSCREEN = 79
 
user32 = ctypes.windll.user32
width, height = user32.GetSystemMetrics(SM_CXVIRTUALSCREEN), user32.GetSystemMetrics(SM_CYVIRTUALSCREEN)
x, y = user32.GetSystemMetrics(SM_XVIRTUALSCREEN), user32.GetSystemMetrics(SM_YVIRTUALSCREEN)    
 
screen = wx.ScreenDC()
bmp = wx.EmptyBitmap(width, height)
mem = wx.MemoryDC(bmp)
mem.Blit(0, 0, width, height, screen, x, y)
del mem
date = datetime.datetime.now()
str = date.strftime("%Y%m%d%H%M%S")
str = u'D:\Pictures\screenshot'+str+'.png'
bmp.SaveFile(str, wx.BITMAP_TYPE_PNG)

Code: Select all

15:23:30: 0 MainThread: ----------------------------------------
15:23:30: 0 MainThread:         EventGhost started
15:23:30: 0 MainThread: ----------------------------------------
15:23:30: 0 MainThread: Version: 0.4.1.r1640
15:23:30: 0 MainThread: missing guid in plugin: C:\Program Files (x86)\EventGhost\plugins\GameVoice
15:23:31: 0 MainThread: missing guid in plugin: C:\Program Files (x86)\EventGhost\plugins\Ping
15:23:31: 0 MainThread: PluginManager.ScanAllPlugins :0.10622506466438879
15:23:31: 0 MainThread: SendKeysParser.__init__()
15:23:31: 0 MainMessageReceiver: MainMessageReceiver.__MainLoop()
15:23:31: 0 MainMessageReceiver: MainMessageReceiver.Setup()
15:23:31: 0 MainThread: Document.ShowFrame()
15:23:31: 0 MainThread: Log.GetData()
15:23:31: 0 MainThread: Document.ShowFrame => None
15:23:31: 0 ActionThread: ActionThread.__MainLoop()
15:23:31: 0 EventThread: EventThread.__MainLoop()
15:23:31: 0 EventThread: EventThread.StartSession(filename=u'C:\\Program Files (x86)\\EventGhost\\11.xml')
15:23:31: 0 ActionThread: ActionThread.StartSession(filename=u'C:\\Program Files (x86)\\EventGhost\\11.xml')
15:23:31: 0 SchedulerThread: SessionChangeNotifier.Register()
15:23:31: 0 MouseThread: MouseThread.run()
15:23:31: 0 ActionThread: Document.Load(filePath=u'C:\\Program Files (x86)\\EventGhost\\11.xml')
15:23:31: 1 MainThread: OSDFrame.__init__(parent=None)
15:23:31: 0 ActionThread: StartLoad(cls=<class 'eg.Classes.TreeLink.TreeLink'>)
15:23:31: 0 ActionThread: XML loaded in 0.021464 seconds.
15:23:31: 0 ActionThread: MceRemote.__start__(waitTime=0.14999999999999999, disableHid=True)
15:23:31: 0 MceMessageReceiver: MceMessageReceiver.__MainLoop()
15:23:31: 0 ActionThread: ActionThread.StartSession => None
15:23:39: 0 ActionThread: Exception in __DoOneEvent
Exception in thread ActionThread:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "threading.pyc", line 484, in run
  File "C:\Program Files (x86)\EventGhost\eg\Utils.py", line 127, in LogItWithReturnWrapper
    result = func(*args, **kwargs)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 354, in __MainLoop
    self.__DoOneEvent()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\ThreadWorker.py", line 342, in __DoOneEvent
    eg.PrintTraceback()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\Log.py", line 204, in PrintTraceback
    self.Write(error.rstrip() + "\n", ERROR_ICON, source)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\Log.py", line 151, in Write
    wx.CallAfter(self._WriteLine, line, icon, wRef, when, eg.indent)
  File "wx\_core.pyc", line 14655, in CallAfter
AssertionError: No wx.App created yet

Exception in thread Thread-7:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "threading.pyc", line 736, in run
  File "C:\Program Files (x86)\EventGhost\plugins\MceRemote\__init__.py", line 246, in OnTimeOut
    self.lastEvent.SetShouldEnd()
  File "C:\Program Files (x86)\EventGhost\eg\Classes\EventGhostEvent.py", line 117, in SetShouldEnd
    eg.SetProcessingState(0, self)
  File "C:\Program Files (x86)\EventGhost\eg\Classes\TaskBarIcon.py", line 111, in SetProcessingState
    wx.CallAfter(eg.Notify, "ProcessingChange", state)
  File "wx\_core.pyc", line 14655, in CallAfter
AssertionError: No wx.App created yet

15:24:08: 1 MainThread: MainFrame.OnClose(dummyEvent=<wx.CloseEvent>)
15:24:08: 1 MainThread: App.Exit()
15:24:08: 1 MainThread: Document.CheckFileNeedsSave()
15:24:08: 1 MainThread: Document.CheckFileNeedsSave => 5100
15:24:08: 1 MainThread: Document.Close()
15:24:08: 1 MainThread: MainFrame.Destroy()
15:24:08: 1 MainThread: LogCtrl.Destroy()
15:24:08: 1 MainThread: TreeCtrl.Destroy()
15:24:08: 1 MainThread: StatusBar.Destroy()
15:24:08: 1 MainThread: MainFrame.Destroy => True
15:24:08: 1 MainThread: Document.GetExpandState()
15:24:08: 1 MainThread: Document.Close => None
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: eg hangs on script second run

Post by Pako »

The code is almost bug free.
But the solution is very simple. It will be enough, if you remove the line app = wx.PySimpleApp().
But the whole script can be done much simpler:

Code: Select all

import ImageGrab, datetime
im = ImageGrab.grab()
date = datetime.datetime.now()
str = date.strftime("%Y%m%d%H%M%S")
im.save(r'D:\Pictures\screenshot%s.png' % str)
Pako
qvan
Posts: 2
Joined: Sun Nov 03, 2013 11:30 am

Re: eg hangs on script second run

Post by qvan »

thank you very much
i try with imagegrub early but it does not working (think there was a lot of bugs))

ps tested closed
Post Reply