HotKeys mit wx
Verfasst: Mittwoch 11. März 2009, 20:06
Sehr geehrtes Python Forum,
ich habe mal - mit hilfe von Gerold (danke nochmal) - ein kleines Script geschrieben mit dem man Hotkey's machen kann.
Ein beispiel ist dabei, also müsstet ihr's verstehen, wenn ihr Fragen habt dann fragt.
Wenn ihr verbesserungsvorschläge habt dann postet sie.
Vielen Dank
INFACT
PS: kennt jemand eine Möglichkeit, mit der man globale HotKeys abfragen kann, ohne dass die Taste abgefangen wird
ich habe mal - mit hilfe von Gerold (danke nochmal) - ein kleines Script geschrieben mit dem man Hotkey's machen kann.
Code: Alles auswählen
import wx
import thread
wx.SetDefaultPyEncoding("iso-8859-1")
class _IsPressed(wx.Frame):
def __init__(self, key ,event, parent = None, id = -1, title = "Globale Hotkeys"):
wx.Frame.__init__(
self, parent, id, title, style = wx.DEFAULT_FRAME_STYLE | wx.WANTS_CHARS
)
self.key=key
self.event=event
hotkey_id = wx.NewId()
print "Register Hotkey:", self.RegisterHotKey(hotkey_id, wx.MOD_NONE, self.key)
self.Bind(wx.EVT_HOTKEY, self.event, id = hotkey_id)
#self.Bind(wx.EVT_KEY_UP, self.on_frame_key_up)
def on_frame_key_up(self, event):
print "KeyCode:", event.GetKeyCode()
"""example: -
def main():
app = wx.PySimpleApp()
class Press(_IsPressed):
def __init__(self):
self.key=65
_IsPressed.__init__(self, self.key, self.i)
def i(self, event):
from BetaSendKeys import SendKeys as SK
print "gedrückt"
f=Press()
#f.Show(False)
app.MainLoop()
if __name__ == "__main__":
import time
thread.start_new_thread(main,())
while 1:
print "look, it's a thread"
time.sleep(3) - """
Wenn ihr verbesserungsvorschläge habt dann postet sie.
Vielen Dank
INFACT
PS: kennt jemand eine Möglichkeit, mit der man globale HotKeys abfragen kann, ohne dass die Taste abgefangen wird