Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Carriage Return in Mac Excel 2008

Carriage Return in Mac Excel 2008

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 755 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mark_in_gr
    wrote on last edited by
    #1

    I am attempting to simulate keystrokes on OS X using Qt 5.3, Excel 2008 and the CGEventKeyboardSetUnicodeString function.

    The problem is that if I send an "\r" to the following function, it is creating a newline WITHIN the active cell in Excel. I want it to advance to the adjacent cell, similar to how you manually advance with the ENTER key based on the value of the "After pressing RETURN, move selection" setting in Preferences/Edit.

    Is there a way to get this to work from code exactly the way it is entered in the Excel app manually?

    @NSString * text = [NSString stringWithUTF8String: pTextToPrint.toUtf8().data()];

    const char *buffer = [text cStringUsingEncoding:NSUTF16StringEncoding];
    
    CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
    CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource, 0, true);    
    
    CGEventKeyboardSetUnicodeString(keyEventDown, [text length], (UniChar *)buffer);    
    CGEventPost(kCGHIDEventTap, keyEventDown);
    
    
    CFRelease(keyEventDown);    
    CFRelease(eventSource);@
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved