/ 杂七杂八  

iPad作为Mac唯一屏幕的实现方法

iPad作为Mac唯一屏幕的实现方法

由于Mac mini太香了,在三月份入手了丐版,但是最后几个月宿舍不准备添置显示器了,所以在宿舍考虑使用iPad作为Mac mini的显示器。经过一段时间的使用觉得是可行的,所以也就有了这篇文章。

前提:

  1. 需要有一个HDMI显卡欺骗器(PDD只要3块钱不到)。
  2. 不使用其他第三方应用程序,只采用“自动操作”。

该方法修改自:「永不吃灰」iPad变Mac的最完美显示器

我尝试的环境为Mac mini M4 + iPad Pro 2020,理论上对于其他的Mac和iPad也都是可以的。

设置“自动操作”完成“随航”操作

首先打开启动台->自动操作,点击新建文稿,选择应用程序,在左上角搜索框搜索“AppleScript”,选择运行AppleScript,拖到右边的框中,将下面的代码替换到编辑区。注意将其中的“Levitate’s iPad”修改为你自己iPad的名称,不要删掉两边的引号。

代码如下(来自b站视频:「永不吃灰」iPad变Mac的最完美显示器。):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
on findLastTargetIndex(targetItem, itemList)
set lastIndex to 0
repeat with i from (count of itemList) to 1 by -1
if item i of itemList is targetItem then
set lastIndex to i
exit repeat
end if
end repeat
return lastIndex
end findLastTargetIndex

do shell script "afplay /System/Library/Sounds/Pop.aiff"

tell application "System Settings"
activate
do shell script "afplay /System/Library/Sounds/Pop.aiff"
delay 1
tell application "System Events"
tell process "System Settings"
-- 获取系统语言
set systemLanguage to do shell script "defaults read -g AppleLocale"

if systemLanguage starts with "zh" then -- 简体中文系统
if systemLanguage is "zh_CN" then
set menuItemName to "显示器"
set menuBarItemName to "显示"
set addButtonName to "添加"
else -- 繁體中文系統
set menuItemName to "顯示器"
set menuBarItemName to "顯示方式"
set addButtonName to "加號"

end if


else if systemLanguage starts with "en" then -- SystemOfEnglishLanguage
set menuItemName to "Displays"
set menuBarItemName to "View"
set addButtonName to "Add"

-- else if systemLanguage starts with "**" then -- change ** to the Abbreviate of the LanguageYouUse
-- set menuItemName to "..." -- change ... to the definition of "Displays" in the MacOS of the LanguageYouUse -- set emenuBarItemName to "??" -- change ?? to the definition of "View" in the MacOS of the LanguageYouUse
-- set addButtonName to "$$" -- change $$ to the definition of "Add" in the MacOS of the LanguageYouUse

end if

click menu item menuItemName of menu menuBarItemName of menu bar item menuBarItemName of menu bar 1
delay 0.3
tell group 1 of group 2 of splitter group 1 of group 1 of window menuItemName
try
delay 1
-- 这里需要延迟,因为系统设置冷启动后不能立刻加载出右侧的界面
click pop up button addButtonName
-- 获取所有菜单的名称
set menuItems to name of menu items of menu addButtonName of pop up button addButtonName
-- 通过名字查找要准确一些,这里去找最后一个名字的索引,因为如果符合通用控制的调节,就会出现两个名字,一个是通用控制,一个是随航
set targetIndex to (my findLastTargetIndex("Levitate’s iPad", menuItems)) -- Need to Change the NameOfTheiPad in the QuotationMarks to Your ipad's
-- 点击目标菜单项
delay 0.3
click menu item targetIndex of menu addButtonName of pop up button addButtonName
do shell script "afplay /System/Library/Sounds/Blow.aiff"
on error
delay 0.5
do shell script "afplay /System/Library/Sounds/Hero.aiff"
end try
end tell
end tell
end tell
end tell
delay 1

tell application "System Settings" to quit

点击左边的“运行代码”▶️,如果可以成功连上你的iPad说明成功啦~cmd+S存储为“开启iPad随航”,注意文件格式是应用程序,位置也是应用程序,点击存储

于是,在启动台可以看到这个“开启iPad随航”应用,如果出现任何的许可请求,都选择允许,注意此时可能仍然无法成功,请打开设置,进入隐私与安全性->辅助功能,将“开启iPad随航”的开关打开,如果没有找到这个应用,请点击下面的➕,从应用程序中选取这个应用打开权限。再尝试一次,此时应该可以完成随航的操作了~

设置快捷键,打开“随航”

下面,我们来设置快捷键。

再次打开启动台->自动操作,点击新建文稿,选择快速操作,在左上角搜索框搜索“应用程序”,选择开启应用程序,在“开启应用程序”的框中选择“开启iPad随航”,如果找不到,请在其他...中找到,cmd+S讲快速操作存储为打开应用“开启iPad随航”

随后,进入设置,打开键盘->键盘快捷键->服务->通用,你应该能在菜单中看到打开应用“开启iPad随航”,双击右边,在里面输入你想设置的快捷键,注意不要和其他应用的快捷键重复,我设置的是ctrl+cmd+P

于是我们可以直接通过快捷键启动iPad作为Mac的显示屏。

盲启动Mac,使iPad作为Mac唯一屏幕

首先,保证插上HDMI欺骗器。打开电脑,盲输入密码,稍等几秒钟,输入上述快捷键,即可实现iPad作为Mac唯一屏幕。

当然也有不用欺骗器的方法,但是都需要利用第三方软件,感觉比较复杂了,不如花三块钱,即插即用😂~但是切记!要用已经链接上的键盘输入。此外这个方法不需要网络,直接把iPad和Mac用双C口线相连即可在无网络环境下使用。

本文标题:iPad作为Mac唯一屏幕的实现方法

文章作者:Levitate_

发布时间:2025年05月13日 - 16:59:07

原始链接:https://levitate-qian.github.io/2025/05/14/iPad-Mac-sidecar/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。