How to change retina display system preferences in OSX? - macos

I am wondering if there is a way to programmatically change the current display mode that is set in System Preferences? Specifically, I want to be able to detect and switch between the 5 Retina display modes on the new Retina MacBook Pro.
I looked through the NSUserDefaults NSGlobalDomain to try to find how to change the current display mode in System Preferences, and couldn't find anything relating to the display at all.
Thanks.

Check out http://www.reddit.com/r/apple/comments/vi9yf/set_your_retina_macbook_pros_resolution_to/ -- uses the private API CGSGetDisplayModeDescriptionOfLength and CGSConfigureDisplayMode to set. Code's included in the kindly distributed .app bundle.
I just wrote up a lengthy post about my endeavours in trying to answer the same question - see
http://garethjenkins.com/2012/07/01/investigating-a-high-resolution-retina-utility-for-macbook-pro-1x-and-2x-modes/

Related

Automator takes screenshot of background instead of window

System specs: mac OS Monterrey V12.5, Apple M1 chip 2020
I am making an application which will take a screenshot of a video, and take the timestamp of the current point in this video, after which both the timestamp and screenshot will be send to a numbers file (mac OS excel like program).
I could not find an application to do this and I tried to get it working using python as shown here but was unable to. Now because I am on Mac I have decided to use Automator instead. I am currently on the screenshot part and Automator has a build in screenshot functionality.
Unfortunately, this screenshot does not detect browser or application windows, it will only take a screenshot of my background.
I have no idea why this is but I suspect it might have to do with permissions related to the M1 chip.
I tried different monitors and simplyfying the automation to just taking a screenshot, but so far nothing has helped, I could not find others online who had a similar problem.
If there is any information missing from this post I will be happy to provide it.
Edit: It seems to be some kind of permission issue, automator CAN take screenshots within Safari, now I just need to find a way to do so in firefox.
I have solved the issue, it turns out that the M1 chip has a special permission for screen recording, adding my Automator application to this permission list will allow it to take screenshots of all windows.

Use AppleScript to change System Preferences > App Badges

I'm trying to use AppleScript to control System Preferences in the background. Specifically, I am trying to Enable / Disable "Badge app icons" for each app. There is no global way to enable / disable badge app icons in system preferences. This must be done per app.
Any idea how this might be done?
Your question is broad, but here are some pointers:
While System Preferences.app can be controlled from an AppleScript, support is limited to revealing (opening) the application to a specific pane and anchor (tab).
Your best bet is to modify the underlying SQLite 3 database in which the per-application notification preferences are maintained - this answer will hopefully get you started.
macOS comes with the sqlite3 CLI.
From what I understand, while AppleScript has - limited - support for accessing SQLite databases via the Database Events app, using do shell script to call the sqlite3 utility may be the better option.
(In fact, in a brief test I wasn't even able to open a database in AppleScript on my macOS 10.12.4 machine)

Recording X windows events

I am a novice when it comes to X windows but have some knowledge of Unix as such.
My project requires me to track user input and output on X window system. For instance, if the GUI is used to configure a route, I would like to know what application is used and what route has been configured. So far, I have explored the following options with partial success.
1)Tried to hook functions like XDrawString and XDrawText using LD_PRELOAD.
2)Used xwininfo to obtain window id and tools like xev.
3)Looked through similar discussions in this forum especially on xev and xinput
1)May not work with if X11 is statically linked? Not sure.
2)xev does not record key press events for a file edited with gedit or attempting to rename a file from the GUI
3)I am trying to go through X windows system internals.
I am pretty discouraged so far. Any input/pointer will be appreciated.
I think you want the cnee program from the Xnee project, which uses the X window system Record extension. The examples that I see for cnee are almost always about recording input events, but, according to the Xnee manual at https://xnee.files.wordpress.com/2012/10/xnee1.pdf, section 3.2.1 ("Record"), "Xnee can record the whole X11 protocol, not just mouse and keyboard events."
Regarding font operations, I believe that X font facilities, mostly through the X font server, evolved over time too, so it might be the case that the applications that you care about are doing X font operations which you can trace.

How to bypass “Adobe Flash Player has stopped a potentially unsafe operation.” running on Mac 10.7 with local files

I am tearing my hair out. I have a complicated Flash player application which I want to run on my local Mac, 10.7.4. I set this up a year or so ago on earlier Mac OS, with earlier Flash players, and sometimes I had to fiddle with global settings, etc, but it always worked. But now flash has decided (sensibly) to handle the security settings surrounding this use of Flash from the local System Preferences. Here's the appropriate screen which should let me tell Flash that I am opening files in the folder:
You can see my desperate attempts to get flash to let me open files in /Users/peter/BTDE2/ etc -- all failing.
Why? How do I get around this? or do I just give up on flash as a horrible bad job...
It appears from the documentation at http://help.adobe.com/en_US/FlashPlayer/LSM/WS6aa5ec234ff3f285139dc56112e3786b68c-7ff0.html#WS6aa5ec234ff3f285139dc56112e3786b68c-7feb that there should be a fix. According to this, there should be a 'Developer Tools' control on the 'Advanced' panel, which gives access to 'Trusted Location' settings. Well, here is the Advanced panel in Flash System Preferences and it shows no such choices. Looks like someone screwed up somewhere.
In the Flash Player panel are you not able to scroll down to reveal the Developer Tools?

How to implement "Open With" contextual menu in OS X

Apps in OS X that can open files to launch their respective applications often let the user choose the app that'll open the file. An example is the Finder.
I am still unclear about what's the best solution to implement this. The challenges are performance and showing the app's icon.
First, to get the list of apps, I found only LSCopyApplicationURLsForURL().
The major difficulty for me now is to get the app icons. All I have is the URLs (paths) to the apps. The only way I know of to get the icons would be to create a CFBundle object and then read the app's plist to get the icon data. But that appears to invole lots of disk access, and I could imagine it'll be quite inefficient if the app is located on a remote file server.
I believe that there's also a cached database about the apps, which includes icons and display names (without extension), and such. But where is the API for that?
Note: The app is Carbon based, but I can make use of Cocoa (NS...) functions if necessary. Also, Support for 10.5, even 10.4, would be appreciated.
Alright. I solved it eventually.
I now use the Carbon function GetIconRefFromFileInfo(), which still works in Lion, though it's marked deprecated/obsolete.
I had also tried to use QLThumbnailImageCreate(), but that didn't get me any results, oddly. No idea what I did wrong.
For Cocoa apps, [[NSWorkspace sharedWorkspace] iconForFile:path] can be used (thanks to C. Grunenberg of DevonTechnologies for this tip, where it's used with EasyFind).

Resources