scripts/modules.d/bases/GizmoScriptAltTabber.py

00001     #***
00002   #*********************************************************************
00003 #*************************************************************************
00004 #*** 
00005 #*** GizmoDaemon Config Script
00006 #***    GizmoScript AltTabber config
00007 #***
00008 #*****************************************
00009   #*****************************************
00010     #***
00011 
00012 """
00013 
00014   Copyright (c) 2007, Gizmo Daemon Team
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 """
00028 
00029 ############################
00030 # Imports
00031 ##########################
00032 
00033 from GizmoDaemon import *
00034 from GizmoDeviceStrings import *
00035 import subprocess
00036 
00037 ############################
00038 # GizmoScriptAltTabber Class definition
00039 ##########################
00040 
00041 class GizmoScriptAltTabber:
00042         """
00043         Inherit from this class if you want to send Alt-Tab events
00044         """
00045         
00046         ############################
00047         # Public Functions
00048         ##########################
00049         
00050         def doAltTab(self):
00051                 """
00052                 Figure out what combination of keys to press to do the next iteration of the Alt-Tab events
00053                 """
00054                 
00055                 if not Gizmod.Dispatcher.AltTabbing:
00056                         Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTALT, 1)
00057                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_TAB)
00058                         Gizmod.Dispatcher.AltTabbingTimeoutTimer = GizmodTimer(ALT_TAB_TIMEOUT, self.timerCallback, None)
00059                         Gizmod.Dispatcher.AltTabbingTimeoutTimer.start()
00060                         Gizmod.Dispatcher.AltTabbing = True
00061                 else:
00062                         Gizmod.Keyboards[0].createEvent(GizmoEventType.EV_KEY, GizmoKey.KEY_TAB)
00063                         Gizmod.Dispatcher.AltTabbingTimeoutTimer.resetTimer()
00064                         
00065         def isAltTabbing(self):
00066                 """
00067                 Return whether or not alt-tabbing is taking place
00068                 """
00069                 
00070                 return Gizmod.Dispatcher.AltTabbing
00071                         
00072         def timerCallback(self, UserData):
00073                 """
00074                 Callback function for the timer
00075                 """
00076                 
00077                 if not Gizmod.Dispatcher.AltTabbing:
00078                         return
00079                         
00080                 Gizmod.Keyboards[0].createEventRaw(GizmoEventType.EV_KEY, GizmoKey.KEY_LEFTALT, 0)
00081                 Gizmod.Dispatcher.AltTabbing = False
00082                 
00083         ############################
00084         # Private Functions
00085         ##########################
00086 
00087         def __init__(self):
00088                 """ 
00089                 Default Constructor
00090                 """
00091                 
00092                 if "AltTabbing" not in dir(Gizmod.Dispatcher):
00093                         Gizmod.Dispatcher.AltTabbing = False
00094                         Gizmod.Dispatcher.AltTabbingTimeoutTimer = None
00095 
00096 ############################
00097 # GizmoScriptDefault class end
00098 ##########################

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3