I need to get snapshot for the whole window my app in Mac OS 11, even if the APP is half-outside the screen. I do not know which API I can use. Use C++ or OC first.
CGDirectDisplayID displayID = CGMainDisplayID(); return CGDisplayCreateImage(displayID);
above code is get screen and can not get image outside the screen.
UIView is a new OS13 API.
Related
I'd like to be able to have my XCUITest application post an image to a server. I've installed the image using the xcrun simctl addmedia command, but I can't figure out to how to access it from the XCUITest class.
I accomplished this by using UITest to access the default photos installed in the simulator Photos library, and then using the SUT to post to the server in question.
The recorder doesn't work inside UIRemoteViews like the photos library. What you can do is setup a ui test and get it to the point where the photos library is open then set a breakpoint and view/print the view hierarchy. That is how I figured out how to select one of the default photos in the iPhone simulator.
let app = XCUIApplication()
let tablesQuery = app.tables
//Get to the camera or library prompt
app.sheets.buttons["Choose From Library"].tap()
app.cells["Camera Roll"].tap()
app.cells["Photo, Landscape, March 12, 2011, 7:17 PM"].tap()
I'm developing an OS X today widget similar to the builtin Weather widget. It runs fine in Xcode's widget simulator. However, after I export it as an Mac app, the today widget in notification center always show the last snapshot that was created while running in widget simulator previously. The correct behavior should be that, whenever the notification center slides out, the today widget fetches the user's current location and display the local time and weather.
Here is what I have in the widgetPerformUpdateWithCompletionHandler:
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
locationManager.startUpdatingLocation()
completionHandler(.NewData)
}
The documentation I've found is terribly unclear on this - what I'd like to do is use the provided Xcode image library (catalog?) on a Mac OS X application.
iOS apps get the benefit of being able to use UIKit's UIImage object to quickly reference image files that are loaded into the catalog.
(To wit: UIImage(imageNamed: "Something"))
Since I'm writing a Mac OS app and not an iOS app, I don't get UIKit.
I'd assume that since XCode provides me with the same image library file by default on an OS X app, that I'm somehow intended to make use of it.
How do I reference images inside the library? Ideally I'd be able to do something with NSImage
In this situation, you can use NSImage just like UIImage:
NSImage(named: "Something")
In my Cocoa app, I need to refer to another window. After searching about it a bit, it looks like that I need to use Apple scripts to do that. My question is that can I return the window of another app as a NSWindow from the Apple script to my Mac app. I've seen some Apple script samples, but not sure how to pass a value from the Apple script to the Cocoa app.
(We have a Mac touchscreen bought recently and there, in order for the touches to get detected in my unity app (through the SDK given for the Touch screen), I need to get that Unity Window and pass it to the touchscreen methods. I'm totally new to Mac development, so I can't figure out how I can pass another Window as a NSWindow to the touchscreen SDK)
Is there (now) a officially supported way to change the OSX Notification Center's Icon for NSUserNotifications while my App is running?
I searched the web, but the answers weren't really "recent", so I just wanted to double check.
I'd like to show the currently playing spotify track's Artwork next to it's title / name
What I tried until now is really ugly:
temporarily replacing the CFBundleIconFile of my app with a IconFamily generated .icns file (I know i shouldn't modify anthing inside the bundle, but I'm not aiming to get the app to the App Store)
restart Notification Center to "forget" it's eventually cached icons
NSRunningApplication* notificationCenter = [NSRunningApplication runningApplicationsWithBundleIdentifier:#"com.apple.notificationcenterui"];
[notificationCenter terminate];
(i know I REALLY SHOULDN'T do this)
If you are NOT going to submit your app to App Store, there's a private API in 10.9 that does what iTunes did:
NSUserNotification *notification = [NSUserNotification new];
[notification setValue:anImage forKey:#"_identityImage"];