title: VMware fusion and applescript with global hotkeys
body: <p>I need a terminal to a Linux vm inside my osx installation. Its a dropdown terminal and in the vm I can use F12 as a global hotkey to toggle show/hide.</p>
  
  <p>The name of the dropdown terminal is yakuake, I know there is a dropdown terminal that works with osx to, but for various reasons, I need both a Linux terminal and easy access to it.</p>
  
  <p>There is several things that makes this difficult.</p>
  
  <ul>
  <li>VMware fusion doesnt have any good applescript support</li>
  <li>I need to be able to run several vm's on the same time.</li>
  <li>Speed</li>
  <li>Hiding the application.</li>
  </ul>
  
  <p>I am using iKey to get a global hotkey on my mac binded to a little oneliner:</p>
  
  <ul>
  <li>/Library/Application\ Support/VMware\ Fusion/vmrun -T fusion -gu username -gp password runScriptInGuest "/Users/username/Documents/Virtual Machines.localized/Ubuntu.vmwarevm/Ubuntu.vmx" -interactive "/bin/bash" "/home/username/bin/toggle_yakuake"</li>
  </ul>
  
  <p>The /home/username/bin/toggle_yakuake script is just a:</p>
  
  <ul>
  <li>/usr/bin/xdotool key Control+Shift+Y # Which is what I bound to yakuake</li>
  </ul>
  
  <p>This works, except its taking around 1-2 seconds, and yakuake will show up below every other windows.
  Therefor I will use logic to just do this if yakuake isnt running, and then I can just hide/show it in osx to toggle it instantly.
  However, I am able to show yakuake using a simple "tell application "Yakuake - Ubuntu" to activate. I am not able to hide it without hiding every other application belonging to the same vm.</p>
  
  <p>It seems that every application spawned by vmware is tied together a little to tight.
  Even if I find the pid of yakuake on my osx installastion, and uses it like:</p>
  
  <pre><code>tell application "System Events"
      set yakuakeproc to every process whose unix id is 58518
      repeat with proc in yakuakeproc
          set the frontmost of proc to true
      end repeat
  end tell
  </code></pre>
  
  <p>It will hide every application belonging to that vm.</p>
  
  <p>I have tried to figure out a solution for this for days now. Is there anyone that have any tips or anything? How can I get applescript to hide one specific application which is inside my vm?</p>