Bonjour, j'utilise pyhook pour reprendre le focus de mon application quand celle ci ne l'a plus. J'utilise Raise pour mettre mon appli sur le dessus des autres fenetres et SetFocus pour rendre la fenetre active.

Mes problèmes:
1-Lower met ma fenetre en dessous mais Raise ne met pas la fenetre au premier plan, seul l'icone de la barre de taches clignote en orange.
1-Si ma fenetre est au 1er plan mais non active, même en utilisant SetFocus, je n'arrive pas à mettre le focus sur mon appli.

Où est mon erreur? Y a t il une autre fonction pour mettre au 1er plan et activer la fenetre (et le focus)?

Note
: la touche "x" est sensé faire un Lower et "y" un Raise
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import pythoncom, pyHook
try:
    import wx
except ImportError:
    raise ImportError,"The wxPython module is required to run this program"
 
class simpleapp_wx(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,id,title)
        self.parent = parent
        self.initialize()
        self.Bind(wx.EVT_CLOSE, self.OnClose)
 
    def initialize(self):
        self.Show(True)
 
    def OnClose(self, event):
        self.Destroy()
 
if __name__ == "__main__":
    #app = wx.App()
    app = wx.App(redirect=True, filename="err.log")
    frame = simpleapp_wx(None,-1,'my application')
    def OnKeyboardEvent(event):
        print 'MessageName:',event.MessageName
        print 'Message:',event.Message
        print 'Time:',event.Time
        print 'Window:',event.Window
        print 'WindowName:',event.WindowName
        print 'Ascii:', event.Ascii, chr(event.Ascii)
        k = event.Key
        print 'Key:', event.Key
        print 'KeyID:', event.KeyID
        print 'ScanCode:', event.ScanCode
        print 'Extended:', event.Extended
        print 'Injected:', event.Injected
        print 'Alt', event.Alt
        print 'Transition', event.Transition
        print '---'
        frame.SetFocus()
        if k == "X":
            print "xx"
            frame.Lower()
        if k == "Y":
            print "yy"
            frame.Raise()
        frame.SetFocus()
 
    # return True to pass the event to other handlers
        return True
 
 
    # create a hook manager
    hm = pyHook.HookManager()
    # watch for all mouse events
    hm.KeyUp = OnKeyboardEvent
    # set the hook
    hm.HookKeyboard()
 
    app.MainLoop()
Merci d'avance