//
//
// Created by BCZ on 2023/1/6.
//
@main
class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system.statusItem(withLength: -1)
@IBOutlet weak var statusMenu: NSMenu!
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
let icon = NSImage(named: “icon_VIP”)
statusItem.button?.image = icon
print(NSScreen.main!.frame.size)
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { t in
let options = CGWindowListOption(arrayLiteral: .excludeDesktopElements, .optionOnScreenOnly)
let windowsListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0))
let infoList = windowsListInfo as! [[String:Any]]
let visibleWindows = infoList.filter{ $0[“kCGWindowLayer“] as! Int == 0 && $0[“kCGWindowOwnerName”] as? String == “微信” }
iflet wx = visibleWindows.first,
let frontApp = NSWorkspace.shared.frontmostApplication {
if frontApp.bundleIdentifier == “com.tencent.xinWeChat” {
}
}
}
}
funcapplicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
}
}
原文地址:https://blog.csdn.net/qq_31249697/article/details/128587784
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_25318.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!