Screencast keys status tool

I didn’t see anywhere in the youtube if it showed mouse shortcuts (i.e. alt MMB drag for orbit).
It’d be pretty airtight if it did that… :slight_smile:

Mouse keys are filtered out. You can change it easiely in the source.

Carsten

This is such a useful tool, as a screencaster this is what i was looking for.

It appears broken again in r31210 though, i’m getting:

AttributeError: bpy.types.register(…): already registered as a subclass.

location:<unknown location>:-1

location:<unknown location>:-1
I dont know any python so if I can provide further details I will.

Perhaps I’m doing something wrong although if not will you be updating it to work again? I’m sure it would be very much appreciated.

Thanks

O

Does not work in these latest releases!! :frowning:
Could update the script?

sry for the late reply.

for blender 2.54


import bpy
import bgl
import blf
import time


# information for the add-ons window
bl_addon_info = {
    'name': '3D View:Screencast Key Status Tool',
    'author': 'Paulo Gomes',
    'version': (0,4),
    'blender': (2, 5, 4),
    'location': 'View3D &gt; Spacebar &gt; Search for "Screencast Key Status Tool"',
    'description': 'Display keys pressed in the 3d-view, useful for screencasts.',
    'warning': '',
    'wiki_url': '',
    'tracker_url': '',
    'category': '3D View'}

def draw_callback_px(self, context):
    # draw text in the 3d-view
    blf.size(0, 20, 72)
    final = 0

    # only display key-presses of last 2 seconds
    for i in range(len(self.key)):
        if time.time()-self.time[i] &lt; 2:
            blf.position(0, 15, 50+20*i, 0)
            blf.draw(0, self.key[i])
            final = i
        else:
            break

    # get rid of statuses that aren't displayed anymore
    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()

        # keys that shouldn't show up in the 3d-view
        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':
            # add key-press to display-list
            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'):
            # stop script
            context.region.callback_remove(self._handle)
            return {'CANCELLED'}

        return {'PASS_THROUGH'}

    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            # start script
            context.window_manager.add_modal_handler(self)

            self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL')
            self.key = []
            self.time = []
      
            return {'RUNNING_MODAL'}

        else:
            # operator not invoked from within the 3d-view
            self.report({'WARNING'}, 'View3D not found, cannot run operator')
            return {'CANCELLED'}

def register():
    pass

def unregister():
    pass

if __name__ == '__main__':
    register()

Yeah, works in SVN of today, nice tool :slight_smile:

This is a great tool, thanks!

paulo,
This is great!!! thanks for making this.

Screencast in action in a tutorial to make a flattering flag :eyebrowlift:
http://www.blenderguru.com/create-an-animated-flag/
Very nice …

it sure works in alpa2 but am not sure of the other builds

I’ve been using this and it works well. The only problem I’m having is that it consistently crashes Blender whenever I press Ctrl-N to start a new scene.

Using:
r32176
WinXP

I have the add-on disabled by default. It only crashes if I’ve actually started it via the Search menu.

Message in the console window:
RNA_struct_free ‘VIEW3D_OT_screencast_keys’ freed while holding a python reference

yes, crashes after Ctrl-N (W32 SVN 32160)

don’t really know how to work around that :frowning:
you have to disable the script before ctrl n (use f7 to disable).

i’ll try to find out how to do this.

Hey, thanks for the F7 tip! That works good enough for my needs. It’s better than having to restart Blender.

BTW, when I try to manually disable it via the Add-Ons prefs page (unchecking it), Blender freezes when I try to tab into edit mode. The console continuously displays line-after-line (as if caught in a loop) the following:

bpy_class_call(): unable to get python class for rna struct ‘system_blend_info’
Thanks

It’s a problem that all scripts using a ‘callback’ have. The problem is that the callback isn’t properly removed when you do things like opening new files, or disabling the add-on. This probably needs to be solved in the design of the callbacks. As far as I can see this can’t be fixed at the level of the individual scripts.

Thanks for the Update!

hi what you’ve done was great!
Can you make the same thing for blender 2.49 plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.:o

Hi and thanks for implementing such useful tools !
I am having trouble though, making this script work…
No error message when running the script, but the keyboard does not respond anymore after the Screencast Key Status Tool command has been clicked on…I can still pan, move and rotate 3D view with the mouse, click on buttons, but zero keystroke response.
I am using Ubuntu 10.04, and I tried the script with both official 2.54 Beta release and newer builds, as 31901 and 32154. Any idea ?

Ouch !
it worked on my suse 11.2 64bit machine and stopped working with 2.55
this is the error message output

File “Screencast.py”, line 91, in <module>
register()
File “Screencast.py”, line 83, in register
bpy.types.register(ScreencastKeysStatus)
AttributeError: bpy.types.register(…): already registered as a subclass.

hope you can fix it, i really like it.

Sorry, didn’t see last update before posting.
it works very fine on 255 and suse11.2 64 bit.
Thanks for your work