macos-carbon

Get Current User from root mode?

♀尐吖头ヾ 提交于 2019-12-04 17:04:47
I am writing a login item and I am trying to find if its possible to get the current user. Lets say, I have logged in with user "Test" and when I execute the exe with root privileges and if I use char *user = getenv("USER"); user is "root". My expected answer is "Test". How can I get it? I don't know if I can put objective c code in login item? Is it possible to NSUserName in login item. NSString *user = NSUserName(); You want the SCDynamicStoreCopyConsoleUser function . QA1133 gives some relevant details and caveats. Login items can be Cocoa applications, so you can use NSUserName() (which is

Programmatically change resolution OS X

五迷三道 提交于 2019-12-04 14:17:03
问题 My question is simple. I am developing a game and, as the title states, I want to be able to programmatically change the display resolution / refresh rate on OS X. I've been searching for this for hours and couldn't find anything. I already know how to create a full screen window. I would also want to get the list of supported resolutions and refresh rates 回答1: From Apple's OpenGL Programming Guide for Mac OS X: Drawing to the Full Screen: Avoid changing the display resolution from that

SGNewChannel error -9405 on Mac 10.9.1

冷暖自知 提交于 2019-12-04 13:41:35
I am getting an error –9405, couldntGetRequiredComponent , with SGNewChannel(m_Grabber, VideoMediaType, &m_Channel) on Mac system 10.9.1. This code works on older systems. Is anyone else having this issue? Edit - Initialization code: // standard SG initialization err = OpenADefaultComponent(SeqGrabComponentType, 0, &m_Grabber); err = SGInitialize(m_Grabber); err = SGSetDataRef(m_Grabber, 0, 0, seqGrabDontMakeMovie); After spending some time reverse engineering what SGNewChannel does on both OS X 10.8 and 10.9 I have found what might be the cause of the new behavior on 10.9. The SGNewChannel

Getting key names for keyboard codes in Swift

僤鯓⒐⒋嵵緔 提交于 2019-12-04 12:26:06
问题 I know others have asked similar questions, but I haven’t seen a definitive answer, and I’m still stuck. I’m trying to write a Swift function that takes a hardware-generated keyboard scan code, such as from an NSEvent, and returns the alpha-caps-locked name of the key, for the particular key arrangement (Dvorak, Qwerty, etc.) currently in effect in the OS (which might be different from the arrangement in effect when the code was generated). It’s my understanding that the only way to do this

Compiling Bochs on Mac os x Snow Leopard

老子叫甜甜 提交于 2019-12-04 09:25:28
问题 Was someone able to compile the Bochs simulator under Snow Leopard. Leopard worked fine for me but under Snow Leopard I get alot of problems related to the Carbon library... Ok, some more information was request. I compile with make on the shell; stanard build process coming with the bochs sources I was successfully able to compile against the 10.5 SDK. Unfortunatley, it was not running under Snow Leopard... always crashed then I installed the latest XCode from the SnowLeopard CD and compiled

What to do about Carbon functions that are deprecated in MacOS/X 10.8.x?

回眸只為那壹抹淺笑 提交于 2019-12-04 07:31:07
I have a C++ codebase that has been around for a while (10+ years) and it compiles and runs fine, but I notice that when I compile it under OS/X 10.8.x (Mountain Lion), the compiler emits deprecation warnings about some of the Carbon functions it calls: ../system/SetupSystem.cpp:575:44: warning: 'UpTime' is deprecated: first deprecated in OS X 10.8 [-Wdeprecated-declarations] ../system/SetupSystem.cpp:575:22: warning: 'AbsoluteToNanoseconds' is deprecated: first deprecated in OS X 10.8 [-Wdeprecated-declarations] ../system/SystemInfo.cpp:249:25: warning: 'MPProcessors' is deprecated: first

CGContextClip() using an inverted path

余生长醉 提交于 2019-12-04 06:56:57
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 clipping path unaffected. So I guess what I need is just a way to reverse the clipping path before

How to convert a Carbon AXUIElementRef to Cocoa NSWindow

老子叫甜甜 提交于 2019-12-04 06:30:01
问题 In my project, i can get the window which mouse is on, and i can use AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue); to make the window to top level temporarily. So i want to convert the element to Cocoa NSWindow and then use makeKeyAndOrderFront to make it always in front. Anyone know how to implement this. + (NSArray *)attributeNamesOfUIElement:(AXUIElementRef)element { NSArray *attrNames = nil; AXUIElementCopyAttributeNames(element, (const void*)&attrNames);

Apple Events to Control Mouse Remotely

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 05:28:21
I'm not even sure where to begin with this question... I want to be able to send mouse-click events to another machine, as if the user had clicked on that machine. I can do it on the same machine via: CGEventSourceRef source = CGEventSourceCreate(NULL); CGEventType eventType = kCGEventLeftMouseDragged; CGPoint mouseCursorPosition; mouseCursorPosition.x = point.x; mouseCursorPosition.y = point.y; CGMouseButton mouseButton = kCGMouseButtonLeft; CGEventRef mouseEvent = CGEventCreateMouseEvent ( source, eventType, mouseCursorPosition, mouseButton ); CGEventSetType(mouseEvent,

Prevent `mouseMovedEvent` callback from processing the movement? Or globally hide cursor momentarily?

戏子无情 提交于 2019-12-04 04:22:30
问题 I have a global app that prevents the mouse from moving into areas of the screen. Must work with all apps, while my app in the background, etc. I have set up a CGEventTap hook that has a callback for mouse movements. The user's mouse movement continues to pass through the hook, no matter how I attempt to modify/kill the movement. That mirrors the experiences of others: https://stackoverflow.com/a/5831573/106761 - (CGEventRef) mouseMovedEvent:(CGEventRef) newUserMouseMovement { //Attempt to