gpt4 book ai didi

objective-c - Objective-C中如何获取当前应用程序的前台窗口名称

转载 作者:行者123 更新时间:2023-12-03 16:40:46 25 4
gpt4 key购买 nike

我想获取当前Objective-C应用程序的前台窗口名称。

虽然我找到了几种获取当前应用程序名称的方法,但我找不到获取前台窗口的方法。

例如,如果有一个应用程序,

 Text Editor
[*] foo.txt
[ ] bar.txt

其中*表示当前窗口,然后我想创建一个函数 getCurrentWindow() 来返回“foo.txt”。

最佳答案

查看 CGWindowListCopyWindowInfo 函数。

Return Value: An array of CFDictionaryRef types, each of which contains information about one of the windows in the current user session.

这些字典中的键 kCGWindowName 就是您要查找的内容。

关于objective-c - Objective-C中如何获取当前应用程序的前台窗口名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28977855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com