macos-carbon

How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?

梦想与她 提交于 2019-12-17 02:27:17
问题 The Gestalt() function located in CarbonCore/OSUtils.h has been deprecated as of OS X 10.8 Mountain Lion. I often use this function to test the version of the OS X operating system at runtime (see the toy example below). What other API could be used to check the OS X operating system version at runtime in a Cocoa application? int main() { SInt32 versMaj, versMin, versBugFix; Gestalt(gestaltSystemVersionMajor, &versMaj); Gestalt(gestaltSystemVersionMinor, &versMin); Gestalt

What API can be used to hide OSX Dock when you drag a window towards it

喜夏-厌秋 提交于 2019-12-14 04:18:53
问题 Idea is simple(stolen from Ubuntu): autohide Dock when you drag window toward it and begin to overlap it. Turn autohiding off and show Dock when window is moved out of area when Dock is located. What API can be used to achieve that ? update: managing autohide possible from command line this way but it's horrible defaults write com.apple.dock autohide -bool true killall Dock 回答1: Well, when the Dock is configured to (always) stay visible, the Window Manager will simply refuse to position the

How to store (and use) the current mouse position?

时光毁灭记忆、已成空白 提交于 2019-12-13 16:15:51
问题 What is the best way to store the current mouse position (system-wide) and then (later) put the mouse at that stored point? [NSEvent mouseLocation] gets me the position, and I can move the mouse with a CGEventMouseMoved, but they each use a different co-ordinates system (I believe y=0 is the top for NSEvent and the bottom for a CGEvent). I'm worried about the robustness of capturing the screen height and using it to convert between the two - or is this the best approach? 回答1: Yes, using the

How to refresh browser view in finder window(mac os 10.5)?

大兔子大兔子 提交于 2019-12-13 08:35:36
问题 I want to refresh all NSTableView in NSBrowserView of finder on mac os 10.5. For refreshing icon view , list view and flow list view, i am using apple script. @"tell application \"Finder\" to update every item in front window" In browser view this script is only refreshing last column. For example , this script is refreshing only third column(icns-copy.m.....). Can anyone please help me out? 回答1: It's only refreshing the last column because every Finder window has exactly one target folder at

Generate a Bookmark file from a classic Mac Alias record

强颜欢笑 提交于 2019-12-13 02:31:50
问题 For an app that has been around for many years, and which has stored the classic Alias records in files, I like to recreate Alias files pointing to the same file now, without having to resolve the Alias first (because the destination may be unavailable at that moment). Supposedly this should accomplish this: CFDataRef aliasRecord = ... ; // contains the Alias Record data, see below for an example CFURLRef url = ... ; // initialized with a file URL CFDataRef bmData =

RegisterEventHotKey from thread

懵懂的女人 提交于 2019-12-13 00:56:08
问题 I followed this awesome tutorial to set up a hotkey - http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily/ However I am doing this from a thread. So I suspect I need to run some kind of event loop. I have tried: WaitNextEvent - with the everyEvent argument set to 0 - I guessed on that one because I can't figure out where they define it here - https://developer.apple.com/legacy/library/documentation/AppleScript/Conceptual/AppleEvents/dispatch_aes_aepg/dispatch_aes_aepg

Monitor start and close of process?

孤街浪徒 提交于 2019-12-12 22:33:40
问题 Is there a way to monitor processes in the Mac OS X before they Start & End? I have a dynamic which I would like to inject in few selected processes before the start, so that hooking can be performed. And would like to do the reverse when application quits, i.e. when application quits I want to unload that library from those process & thus perform unhooking. What can be the best solution for my situation? 回答1: In Carbon, you can register for the kEventClassApplication/kEventAppLaunched event.

Why does Apple define UInt32 as long or int depending on platform?

隐身守侯 提交于 2019-12-12 14:50:27
问题 I noticed that UInt32 is defined differently based on the platform in MacTypes.h #if __LP64__ typedef unsigned int UInt32; typedef signed int SInt32; #else typedef unsigned long UInt32; typedef signed long SInt32; #endif If unsigned int is always 32 bits on 32 and 64bit machines, why do they bother conditionally checking the platform? 回答1: My guess is it is some old code which was initially: typedef unsigned long UInt32; typedef signed long SInt32; and a developper later added the LP64 and he

(MACOSX) - Knowing whether a mounted device was mounted from a DMG

拥有回忆 提交于 2019-12-12 10:19:31
问题 Couldn't find that info using DiskArbitration or FSGetVolumeInfo/GetVolumeParms... I know that hdiutil uses a private framework called DiskImages framework, but I wouldn't want to run an external utility each time I want this info... wheres the API for this ? 回答1: July 2015 Update This update was prompted by Stan James' new question. You can obtain this information using the DiskArbitration framework. To use the example below, you must link against and #import it. #import <DiskArbitration

CGContextClip() using an inverted path

旧巷老猫 提交于 2019-12-12 08:49:40
问题 I want to have clipped drawing on my CGContext but I need it just the other way round, i.e. I want to add several rectangles to my clipping path using CGContextAddRect() and the clipping should be done in the way that all the rectangles that I have added to my clipping path stay unaffected by any drawing operations. Normally, it's just the other way round, i.e. drawing functions draw to the rectangles that have been added to the clipping path and leave the areas that haven't been added to the