1

I'm seeking clarity on a problem I am encountering while building a semi-automated screencasting & video encoding pipeline. A solid technique for addressing it would be lovely as well :-)

The problem

The setup: a Quartz-based + Applescript library enacts a screencast script that triggers screenrecording in an application like Quicktime, interacts with a website, then afterwards exports the screenrecording to a target location.

This pipeline works. With one exception: the mouse cursor disappears in the resulting screen recording after using either the Quartz-based library or Applescript to type into a text field. Note that when I watch the screencast acted out live, I see the mouse cursor the whole time.

Restoring the cursor

I have found some techniques that restore the mouse cursor while the screencast is being enacted:

  • Manually type something after the input text box loses focus (doesn't work programmatically)
  • Switching to a different application via cmd-tab (works manually and programmatically via Applescript)
  • Launching a new application with Applescript, but only if it comes to the foreground (the mechanism for why this works is probably the same as switching to a different application)
  • Doing a right-click to trigger a context menu to appear. Can be done programmatically, and can be within the same application.

My temporary workaround is to simply issue two quick cmd-tab commands via Applescript after every time that the script types text. This works alright, though it does leave some minor artifacts in the resulting screencast.

Details of setup & experiments

A few more details about the technology I'm using here.

  • The machine is a 2013 MBP running Yosemite
  • I have used two independent Quartz-based libraries for simulating user actions: osxautomation and cliclick, both of which exhibit the same issue.
  • I have used three different techniques for doing the screenrecoding: Quicktime, Camtasia, and ffmpeg (ffmpeg -f avfoundation -i "1:0" out.avi). These all probably use AV Foundation under the hood, though I'm not sure about that.
  • I have used Safari, Firefox, and Chrome as the target browser for the interactions

Any insights into what might be causing the problem and/or ideas for a better workaround would be appreciated!!

p.s. I'm not familiar with most of the technologies involved, like Quartz and AV Foundation, so my apologies in advance if my description is fundamentally flawed, or if I've tagged a technology that doesn't bear at all upon the problem.

1
  • It's been a long time, but did you ever find a solution to this? I'm running into the exact same problem and it's very frustrating!
    – Tim Perry
    Commented Aug 7 at 14:17

2 Answers 2

1

I use this in one of my cocoa applications to hide the cursor.

[NSCursor setHiddenUntilMouseMoves:YES];

You might give it a try to see if it unhides the cursor by setting it to "NO" or maybe toggling first "YES" and then "NO". Maybe look into other NSCursor commands as well.

Hope it helps. Good luck.

1
  • Thanks for the idea! I gave it and a few variations a shot, but it didn't work out. Your answer also led me to try Quartz's CGDisplayShowCursor method, which unfortunately also didn't work. Commented Apr 3, 2015 at 5:26
1

I ran into this too, and similarly made no progress with various alternative approaches (fairly sure that this is an AVFoundation bug, and all screen recording tools are just using AVFoundation under the hood).

So far the best solution I've found to restore the cursor when it disappears is to switch to Finder (with no overlapping windows, or no windows open at all) and instantly cmd+tab back. It's a bit annoying, but it's incredibly fast and doesn't result in any flickering or anything in my setup, so there's no real consequences.

In my case, I'm automating on top of a selection of applescripts that I orchestrate from 'real' code (Node.js), and I've just added this to the end of my 'slowly type a string' script so it happens at the end of any typing. The actual applescript to do the switch is this:

tell application "Finder" to activate
key code 48 using {command down}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.