使用非常长的字符串调用此函数:
void postBytes( UniChar *buf, UniCharCount len )
{
CGEventSourceRef evtSrc = CGEventSourceCreate( kCGEventSourceStatePrivate );
CGEventRef keyEvtDown = CGEventCreateKeyboardEvent( evtSrc, 0, true );
CGEventKeyboardSetUnicodeString( keyEventDown, len, buf );
CGEventPost( kCGHIDEventTap, keyEventDown );
CFRelease( keyEvtDown );
CFRelease( evtSrc );
}
无论作为参数提供的字符串如何:当调用CGEventPost()
时,只会向事件流发布最多20个字符。此行为未记录。我错过了什么?