

Set targetAppName to (targetApp's localizedName) as text Set targetApp to (notif's userInfo's valueForKey:"NSWorkspaceApplicationKey") we don't use the idle loop, so tell the system to check in once an hour Tell notifCent to addObserver:me selector:"appHasDeactivated:" |name|:"NSWorkspaceDidDeactivateApplicationNotification" object:(missing value) Tell notifCent to addObserver:me selector:"appHasActivated:" |name|:"NSWorkspaceDidActivateApplicationNotification" object:(missing value) Set notifCent to workSp's notificationCenter() Set workSp to NSWorkspace's sharedWorkspace() Property NSWorkspace : class "NSWorkspace" The app waits in the background to receive notifications that an app has activated or deactivated, then it checks the app name and triggers the keyboard shortcut for the switching the input source when the Window VM app comes or goes. add the app to the Login Items section for your account in Users & Groups (so it starts automatically at login).add the app to the Accessibility section in Security & Privacy➔Privacy (so it can send keyboard shortcuts).Open System Preferences and do the following.click the 'Stay open after run handler' checkbox.select 'Application' from the 'Format' menu at the bottom left.Copy the following script in the Script Editor.You should also check that "Windows VM" is the correct name for the app: find the application in the Finder, select it and type ⌘I to open a Get Info window, and look in the Name & Extension text box. I have mine set to comd-ctrl-space (^⌘ ), but yours is likely different. Assuming that you only have two keyboard layouts, you can use the following script application.įirst, you'll need to open System Preferences and look at Keyboard➔Shortcuts➔Input Sources see what the what the keyboard shortcut for 'selecting previous input source' is, make sure it's clicked on, and copy it into the script at the marked places.
