<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Tastendruck per CGEventPostToPSN an andere Application senden]]></title><description><![CDATA[<p>Schon seit Stunden versuche ich per CGEventPostToPSN Tastaturevents an einem anderen Programm zu senden. Leider schaffe ich es nicht die pid oder die psn per Application Name zu bestimmen. Könnte mir die Library <a href="http://code.ohloh.net/file?fid=c7Hr0hnH5M1Bp66cslebmLqrL70&amp;cid=ufSHNfgNIoo&amp;s=&amp;fp=117904&amp;mp=&amp;projSelected=true#L0" rel="nofollow">http://code.ohloh.net/file?fid=c7Hr0hnH5M1Bp66cslebmLqrL70&amp;cid=ufSHNfgNIoo&amp;s=&amp;fp=117904&amp;mp=&amp;projSelected=true#L0</a> helfen und wie binde ich die in C++ ein? Auch könnte es sein, dass sonst noch was falsch ist, da ich auch mit bestimmten psd beim Compilern den Fehler &quot;symbol(s) not found for architecture x86_64&quot; kriege. Kann mir irgendjemand weiterhelfen?</p>
<pre><code>#include &quot;ApplicationServices/ApplicationServices.h&quot;
#include &quot;Carbon/Carbon.h&quot;

    void postKeyboardEvent()
    {
        //pid_t pid = [(NSRunningApplication*)&lsqb;&lsqb;NSRunningApplication runningApplicationsWithBundleIdentifier:@&quot;com.apple.TextEdit&quot;] objectAtIndex:0] processIdentifier];
        pid_t pid = GetPIDForProcessName(&quot;myprocess&quot;); //Wie Libarry einbinden?
        ProcessSerialNumber psn = { 0, pid };

        CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStatePrivate);
            CGEventRef keyDownEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, true);
            CGEventSetFlags(keyDownEvent, (kCGEventFlagMaskControl | kCGEventFlagMaskCommand));
            CGEventRef keyUpEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, false);
            CGEventSetFlags(keyUpEvent, (kCGEventFlagMaskControl | kCGEventFlagMaskCommand));
            CFRelease(source);

            CGEventPostToPSN(&amp;psn, keyDownEvent);
            CFRelease(keyDownEvent);
            CGEventPostToPSN(&amp;psn, keyUpEvent);
            CFRelease(keyUpEvent);
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/327603/tastendruck-per-cgeventposttopsn-an-andere-application-senden</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 22:44:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327603.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Aug 2014 19:34:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tastendruck per CGEventPostToPSN an andere Application senden on Thu, 21 Aug 2014 19:34:38 GMT]]></title><description><![CDATA[<p>Schon seit Stunden versuche ich per CGEventPostToPSN Tastaturevents an einem anderen Programm zu senden. Leider schaffe ich es nicht die pid oder die psn per Application Name zu bestimmen. Könnte mir die Library <a href="http://code.ohloh.net/file?fid=c7Hr0hnH5M1Bp66cslebmLqrL70&amp;cid=ufSHNfgNIoo&amp;s=&amp;fp=117904&amp;mp=&amp;projSelected=true#L0" rel="nofollow">http://code.ohloh.net/file?fid=c7Hr0hnH5M1Bp66cslebmLqrL70&amp;cid=ufSHNfgNIoo&amp;s=&amp;fp=117904&amp;mp=&amp;projSelected=true#L0</a> helfen und wie binde ich die in C++ ein? Auch könnte es sein, dass sonst noch was falsch ist, da ich auch mit bestimmten psd beim Compilern den Fehler &quot;symbol(s) not found for architecture x86_64&quot; kriege. Kann mir irgendjemand weiterhelfen?</p>
<pre><code>#include &quot;ApplicationServices/ApplicationServices.h&quot;
#include &quot;Carbon/Carbon.h&quot;

    void postKeyboardEvent()
    {
        //pid_t pid = [(NSRunningApplication*)&lsqb;&lsqb;NSRunningApplication runningApplicationsWithBundleIdentifier:@&quot;com.apple.TextEdit&quot;] objectAtIndex:0] processIdentifier];
        pid_t pid = GetPIDForProcessName(&quot;myprocess&quot;); //Wie Libarry einbinden?
        ProcessSerialNumber psn = { 0, pid };

        CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStatePrivate);
            CGEventRef keyDownEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, true);
            CGEventSetFlags(keyDownEvent, (kCGEventFlagMaskControl | kCGEventFlagMaskCommand));
            CGEventRef keyUpEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, false);
            CGEventSetFlags(keyUpEvent, (kCGEventFlagMaskControl | kCGEventFlagMaskCommand));
            CFRelease(source);

            CGEventPostToPSN(&amp;psn, keyDownEvent);
            CFRelease(keyDownEvent);
            CGEventPostToPSN(&amp;psn, keyUpEvent);
            CFRelease(keyUpEvent);
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2414498</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414498</guid><dc:creator><![CDATA[NicoBosshard]]></dc:creator><pubDate>Thu, 21 Aug 2014 19:34:38 GMT</pubDate></item><item><title><![CDATA[Reply to Tastendruck per CGEventPostToPSN an andere Application senden on Thu, 21 Aug 2014 21:41:48 GMT]]></title><description><![CDATA[<p>Du hast kein C++ Problem. Deine Frage wäre in einem OS X Forum besser aufgehoben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2414511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2414511</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 21 Aug 2014 21:41:48 GMT</pubDate></item></channel></rss>