-
Notifications
You must be signed in to change notification settings - Fork 6
/
mac_test.js
37 lines (33 loc) · 889 Bytes
/
mac_test.js
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
const { load, open, DataType } = require("./index");
// 定义 CGRect 结构体
const CGRect = {
origin: {
x: DataType.Double,
y: DataType.Double,
ffiTypeTag: DataType.StackStruct,
},
size: {
width: DataType.Double,
height: DataType.Double,
ffiTypeTag: DataType.StackStruct,
},
ffiTypeTag: DataType.StackStruct,
};
// 获取主屏幕尺寸的函数
const getMainDisplaySize = async () => {
open({
library: "ApplicationServices",
path: "/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices",
});
const bounds = await load({
library: "ApplicationServices",
funcName: "CGDisplayBounds",
paramsType: [DataType.I32], // 不支持 U32 ,使用 I32 报错
paramsValue: [1],
retType: CGRect,
});
return bounds;
};
if (process.platform === "darwin") {
getMainDisplaySize().then(console.log);
}