hi all, this is a wip. I’m trying to learn python scripting and this is my first project. What the script does, is show the keys you press in the lower left corner of the 3Dview. The idea is to have a visual aid of the shortcuts when doing screencasts with blender. I also want to thanks Crouch for his pacience with me.
Load the script in blender’s text editor, then run it. Go to 3dview press space and search for ‘Screencast Key Status Tool’ and execute it. Now the keys you press should appear in the lower left corner. To disable the script press F7.
here’s a short video showing the script in action:
and here’s the script:
you can now copy it to your addon directory and enable it in the user preferences addon menu, thanks Meta-Androcto
# Blender Add-Ons menu registration (in User Prefs)
"Screencast (View3D > Tools > Draw Screencast)"
import bpy
import bgl
import blf
import time
def draw_callback_px(self, context):
# draw some text
blf.size(20, 72)
final = 0
for i in range(len(self.key)):
if time.time()-self.time[i] < 2:
blf.position(15, 50+20*i, 0)
blf.draw(self.key[i])
final = i
else:
break
self.key = self.key[:final+1]
self.time = self.time[:final+1]
class ScreencastKeysStatus(bpy.types.Operator):
'''Draw keys pressed in 3DView'''
bl_idname = "view3d.screencast_keys"
bl_label = "Screencast Key Status Tool"
def modal(self, context, event):
context.area.tag_redraw()
ignore_keys = ['LEFT_SHIFT', 'RIGHT_SHIFT', 'LEFT_ALT', 'RIGHT_ALT', 'LEFT_CTRL',
'RIGHT_CTRL', 'TIMER', 'MOUSEMOVE', 'MIDDLEMOUSE', 'LEFTMOUSE',
'RIGHTMOUSE', 'WHEELDOWNMOUSE', 'WHEELUPMOUSE']
if event.value == 'PRESS':
sc_keys = []
if event.shift:
sc_keys.append('Shift ')
if event.alt:
sc_keys.append('Alt ')
if event.ctrl:
sc_keys.append('Ctrl ')
if event.type not in ignore_keys:
sc_keys.append(event.type)
self.key.insert(0, "+ ".join(map(str, sc_keys)))
self.time.insert(0, time.time())
if event.type == ('F7'):
context.region.callback_remove(self._handle)
return {'CANCELLED'}
return {'PASS_THROUGH'}
def invoke(self, context, event):
if context.area.type == 'VIEW_3D':
context.manager.add_modal_handler(self)
# Add the region OpenGL drawing callback
# draw in view space with 'POST_VIEW' and 'PRE_VIEW'
self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL')
self.key = []
self.time = []
return {'RUNNING_MODAL'}
else:
self.report({'WARNING'}, "View3D not found, cannot run operator")
return {'CANCELLED'}
def register():
bpy.types.register(ScreencastKeysStatus)
def unregister():
bpy.types.unregister(ScreencastKeysStatus)
if __name__ == "__main__":
register()