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.

Capturing window drug and resize

If you have a question or need help, this is the place to be.
Post Reply
TMSxEventGhost
Posts: 6
Joined: Thu Sep 29, 2016 11:17 am

Capturing window drug and resize

Post by TMSxEventGhost »

I need to capture when windows got resized or drugged (I want to lay them together in a particular way), however, to do this we need to use winApi like SetWinEventHook.

Fortunately those api are ported to python by PyHook and already used by mouse event plugin viewtopic.php?f=9&t=3720.

We need for example to listen to Windows messages to get resizing event, as explained here http://stackoverflow.com/questions/2880 ... in-c-sharp.

I tired to incorporate this in my own plugin but because my knowledge in python is shallow I get like ton of errors related to threading:

Code: Select all

..\EventGhost\eg\Classes\ThreadWorker.py:319: Runtime Warning: tp_compare didn't return -1 or -2 for exception
  if resultCode == WAIT_OBJECT_0:
Traceback (most recent call last) (1722):
  File "..\EventGhost\eg\Classes\ThreadWorker.py", line 319, in __DoOneEvent
    if resultCode == WAIT_OBJECT_0:
TypeError: an integer is required
Exception in thread ActionThread:
Traceback (most recent call last):
  File "threading.pyc", line 532, in __bootstrap_inner
  File "threading.pyc", line 484, in run
This is a brief of what I did in the plugin:

Code: Select all

import pyHook
import cpyHook
import HookManager

class Test(eg.ActionBase):
    def __call__(self):
        print "dose nothing"

    def Hok(self):
        hc=HookManager.HookConstants()
        cpyHook.cSetHook(hc.WH_MOUSE_LL, self.Res)

    def Res(self, msg, x, y, data, flags, time, hwnd, window_name):
        print "working"

Where latter on i will listen to 'WH_CALLWNDPROC' message for resizing events as mentioned in the url above.

Any help is appreciated how to incorporate this stuff, since my knowledge here is limited.

P.S
I just put all PyHook files in the same folder of the plugin, otherwise it will not "see" cpyHook.
Post Reply