如何使用applescript更改空间

发布于 2024-11-28 00:01:54 字数 293 浏览 0 评论 0原文

我有以下 applescript 来跳过 Spotify 中的歌曲。如果我在全屏应用程序位于最前面时调用脚本,则在脚本完成后该应用程序将不可见。它将在不同的空间。有没有办法可以使用 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

I have the following applescript to skip songs in spotify. If I call the script when a fullscreen application is the frontmost, the application will not be visible after the script has finished. It will be in a different space. Is there a way that I can make the frontmost application visible again with 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁我热情 2024-12-05 00:01:54

这可能不会让您到达任何地方,但您可以使用此脚本循环遍历所有空间,直到看到您要定位的应用程序...

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

This probably won't get you anywhere, but you could use this script to loop through all your spaces until you see the application you're targeting...

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
尤怨 2024-12-05 00:01:54
set front_app to current application

tell application "Spotify"
   next track
end tell

tell front_app to activate
set front_app to current application

tell application "Spotify"
   next track
end tell

tell front_app to activate
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文