Emulating Keyboard/Applescript issue

lookitscook's picture

Working a custom patch to trigger system level keystrokes (for use with Syphon recorder). Attached plugin works, except that certain key combinations cause any billboards/sprites to scale 200%. Circle patch doesn't scale.. and it doesn't seem to happen when I flag the "function" key input.

This also happens when executing the equivalent Applescript directly using dust's ask patch. Source code here: https://github.com/zebradog/QCKeyEventEmulator

Any idea what is causing this scaling/how to prevent it?

PreviewAttachmentSize
KeyEventEmulator.plugin.zip5.53 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

dust's picture
Re: Emulating Keyboard/Applescript issue

yes thats very strange. i can confirm this happens for me with both yours and my plugin.

with this plugin in consumer time mode idle

if([self didValueForInputKeyChange:@"inputScript"] || self.inputRun){
 
      NSAppleScript *scriptObject = [[[NSAppleScript alloc] initWithSource:self.inputScript]autorelease];
 
    [scriptObject executeAndReturnError:nil];
 
    }

running this apple script

tell application "Syphon Recorder"
   activate
end tell
 
tell application "System Events"
   keystroke "r" using {option down, command down}
end tell

will in fact produce this scaling of billboards sprites and even mesh renders. i have tried with both syphon image and gl scene both reproduce the scaling your saying.

interesting enough when sending the command using a different thread every thing works. so i suggest possible making a processor type of plugin or to use two different qc threads. one thread to send images to syphon recorder and the other send commands to the syphon recorder. in other words use two patches one sending commands the other sending images and network the patches together. so when the video has reached the end bonjour a stop recording notification to your command sender sender patch.

thats defiantly a weird one.

lookitscook's picture
Re: Emulating Keyboard/Applescript issue

Using applescript felt hacky anyway... rewrote to throw keyboard events directly. Download here: https://github.com/downloads/zebradog/QCKeyEventEmulator/KeyEventEmulato...

monobrau's picture
Re: Emulating Keyboard/Applescript issue

Nice, this is very useful!

Could you make it 32-bit compatible as well?

lookitscook's picture
Re: Emulating Keyboard/Applescript issue

For sure. (Thanks to Bangnoise for the update). Download should now be 32bit compatible.

gtoledo3's picture
Re: Emulating Keyboard/Applescript issue

What did it wind up being that was making GLScale go crazy?

lookitscook's picture
Re: Emulating Keyboard/Applescript issue

No idea, specifically. Something with triggering actionscript via a plugin with certain input. I re-wrote to throw proper CGEvents instead of using applescript, which avoids the problem.

itsthejayj's picture
Re: Emulating Keyboard/Applescript issue

Great work, been using applescript to do this too, your way is better and stop horrible feedback loops i use to get. Is there anyway to allow an input parameter so we could set the active application like in applescript 'tell application "application" to active" ?

dust's picture
Re: Emulating Keyboard/Applescript issue

i'm unclear on how to control syphon recorder with this plugin. using apple script made sense. " tell syphon recorder active then send a record key event " its very strange still...if i use applescript to tell syphon to be active then send the key event with the emulator the scaling still happens for me. using key event emulator plugin to control qc makes sense to me and works fine. it would be cool if you could send a return event as well. that way you could tell qc to take a snap shot and name it plus save it etc...

lookitscook's picture
Re: Emulating Keyboard/Applescript issue

Dust: You shouldn't need to activate syphon recorder. On my machine using "kCGHIDEventTap" when posting the key event throws a system-wide keystroke that is recognized by syphon recorder, even if QC is still the active app.

I'm basically triggering CMD+OPT+R, then waiting for a stop command or timeout, then trigging CMD+OPT+R again, then doing a directory scan of the syphon recorder movie directory to get the most recent movie and using that filename in a callback.

Jayj: Same advice, although if you needed to only target a specific app/processID you could switch kCGHIDEventTap to kCGSessionEventTap which I believe you can send to a specific PID (by default it goes to the active app), which you could specify as a parameter. If you needed to do it by process name you'd need to do a lookup. I probably won't be implementing this since it's working as-is for me, but I agree it would be a useful (better?) solution.

dust's picture
Re: Emulating Keyboard/Applescript issue

yes it works well without having to tell an active app. i really thought i tried that but i might have forgot to use the option key. thanks