2011-08-04 4 views
1

私はspotifyで曲をスキップするために次のようなapplescriptを持っています。フルスクリーンアプリケーションが最前面にあるときにスクリプトを呼び出すと、スクリプトが終了してもアプリケーションは表示されません。それは別の空間にあります。最前面のアプリケーションを再びAppleScriptで見えるようにする方法はありますか?applescriptでスペースを変更する方法

 
set front_app to (path to frontmost application as Unicode text) 

tell application "Spotify" 
    next track 
end tell 

tell application front_app to activate 
+0

重複のhttp://stackoverflow.com/questions/2305491/applescript-opening-an-app-in-space-number-n – cwd

答えて

1
set front_app to current application 

tell application "Spotify" 
    next track 
end tell 

tell front_app to activate 
+0

コードははるかに良く見えますが、同じように動作します。 front_appがフルスクリーンアプリケーションの場合、スクリプトの実行後も表示されません。 – Kim

+0

@キム:ああ、そうです。私はLionをインストールしていないので、フルスクリーンのアプリでは確認できません。ところで、どうやってスクリプトを起動していますか?例えば。ビルトインスクリプトメニュー、Quicksilver、FastScripts、または何か?私は多分ランチャーとスクリプトではなく、フロントアプリからフォーカスを盗んで、それを返すことはないのだろうかと思っています。それではまた、Lionの全画面アプリで問題になるかもしれません。 – Flambino

+0

私はAlfredからスクリプトを起動します。私は次の曲、前の曲、一時停止などのためのスクリプトを持っています。現在のアプリケーションが全画面アプリケーションでない限り、それは魅力的です。 – Kim

2

これはおそらくどこでもあなたを取得することはありませんが、あなたは、あなたがターゲットとしているアプリケーションが表示されるまで、すべてのあなたの空間を通ってループにこのスクリプトを使用することができます...

可能
set front_application to current application 
tell application "Spotify" to next track 
tell application "Finder" to set collapsed of front_application to false --makes sure the app isn't minimized 
repeat 
    tell application "System Events" to keystroke (ASCII character 29) using {control down} 
    display dialog "Correct space?" buttons{"OK"} default button 1 giving up after 4 --don't click 'OK' if the current space isn't showing the target application 
    if gave up of the result is false then exit repeat 
end repeat 
+0

答えをありがとう、しかし私は目立たない方法を探しているので、ダイアログをポップアップすることは私がやりたいことではありません。 – Kim

+0

'repeat'ループの前に'アプリケーションに "システムイベント"をキーコード53にする "ことができます。 – fireshadow52

関連する問題