<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi <font class="" face="Menlo">Manajit,<br>
      <br>
      Before your fix all key codes wa sent using<br>
    </font><br>
    AXUIElementCreateSystemWide();<br>
    <br>
    and <font class="" face="Menlo">CGEventCreateKeyboardEvent was
      commented or excluded from compilation:<br>
      <br>
      274 #if 0<br>
      †275†††† CGEventRef event = CGEventCreateKeyboardEvent(NULL,
      keyCode, keyPressed);<br>
      †276†††† if (event != NULL) {<br>
      †277†††††††† CGEventPost(kCGSessionEventTap, event);<br>
      †278†††††††† CFRelease(event);<br>
      †279†††† }<br>
      †280 #endif<br>
      <br>
      I just wonder why it was done. Maybe that was some other issue
      fix. The comment above states:<br>
      <br>
      †262††††† * Well, using CGEventCreateKeyboardEvent/CGEventPost
      would have been<br>
      †263††††† * a better solution, however, it gives me all kinds of
      trouble and I have<br>
      †264††††† * no idea how to solve them without inserting delays
      between simulated<br>
      †265††††† * events. So, I've ended up disabling it and opted for
      another approach<br>
      †266††††† * that uses Accessibility API instead.<br>
      <br>
      I don't understand what trouble is mentioned in the comment above.
      But in your fix you've put the CGEventCreateKeyboardEvent back,
      may it return this trouble back?<br>
      <br>
      Also as I understand Numpad number keys did not work as well. Could
      you add the corresponding test case since you provide a fix this
      extra issue?<br>
      <br>
      --Semyon<br>
      <br>
      <br>
    </font>
    <div class="moz-cite-prefix">On 5/13/2016 11:50 PM, Manajit Halder
      wrote:<br>
    </div>
    <blockquote
      cite="mid:75CD4BD9-983C-4315-A5FC-3518C37BECF7@oracle.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <font class="" face="Menlo">Hi Semyon,</font>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class="">
        <div class=""><font class="" face="Menlo">The fix is changed a
            bit†because it was observed that the modifier keys plus
            alphabet keys were not working together. In the modified fix
            only Num keys are posted by AXUIElementPostKeyboardEvent and
            remaining keys are posted by
            CGPostKeyboardEvent/CGEventPost. The fix is explained in the
            comment in file CRobot.m.</font></div>
        <div class=""><font class="" face="Menlo"><br class="">
          </font></div>
        <div class=""><font class="" face="Menlo">Please review the new
            changes:</font></div>
      </div>
      <div class=""><font class="" color="#4787ff" face="Menlo"><u
            class=""><a moz-do-not-send="true"
              href="http://cr.openjdk.java.net/%7Emhalder/8155740/webrev.01/"
              class="">http://cr.openjdk.java.net/~mhalder/8155740/webrev.01/</a></u></font></div>
      <div class=""><font class="" color="#4787ff" face="Menlo"><u
            class=""><br class="">
          </u></font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" face="Menlo">Answers to your
          questions:</font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" color="#5e30eb" face="Menlo">What is
          difference between AXUIElementPostKeyboardEvent and
          CGEventCreateKeyboardEvent?</font></div>
      <div class=""><font class="" face="Menlo">
          <div class=""><font class="" face="Menlo"><br class="">
            </font></div>
          Difference as per the documentation:</font></div>
      <div class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre">       </span>AXUIElementPostKeyboardEvent
          is similar to CGPostKeyboardEvent (which synthesizes a
          low-level keyboard event on the local machine), but it allows
          you to specify the target application as opposed to always
          sending the events to the active application. If the
          system-wide accessibility object is passed in the application
          parameter, the event is sent to the active application.†</font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" face="Menlo">Difference behaviour as
          per the implementation observed while debugging the code:</font></div>
      <div class=""><span class="Apple-tab-span" style="white-space:pre"><font class="" face="Menlo">       </font></span></div>
      <div class=""><font class="" face="Menlo">AXUIElementPostKeyboardEvent:</font></div>
      <div class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre">       </span>AXUIElementPostKeyboardEvent
          posts 0 key code for all the modifier keys with key codes 16,
          17,18, 20, 157 and also for newly added modifier key
          VK_ALT_GRAPH. But it posts correct key code for all the
          remaining keys.</font></div>
      <div class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre">       </span>While
          debugging it was that for modifier keys keyDown and keyUp
          events are not generated, but flagsChanged event
          (flagsChanged: (NSEvent *)event) is generated. But for all
          other keys keyDown followed by keyUp events are generated.</font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" face="Menlo">CGEventCreateKeyboardEvent:</font></div>
      <div class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre">       </span>CGEventCreateKeyboardEvent†posts
          correct key code for all the keys except for numeric keys
          (numbers 0 to 9 on normal
          keyboard).†CGEventCreateKeyboardEvent posts wrong key codes
          for the number keys†0 to 9. Instead of posting number key
          codes it posts Numpad key codes†for the corresponding number
          key. For example Numpad0 key code is posted for†number 0,
          Numpad1 key code is posted for number 1 and simillarly for
          remaining num keys.</font></div>
      <div class=""><span class="Apple-tab-span" style="white-space:pre"><font class="" face="Menlo">       </font></span></div>
      <div class=""><font class="" color="#5e30eb" face="Menlo">Why the
          latter was commented? Does it mean that valid modifier keys
          have not been sent by AWT robot?</font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" face="Menlo">I didnít get your
          question clearly. If you meant why in the current
          implementation the later part (fix using CGPostKeyboardEvent)
          of fix was commented.</font></div>
      <div class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre">       </span>I
          am not very sure about it. As per the comment it is only clear
          that CGPostKeyboardEvent/CGEventPost would have been a better
          solution and I agree with that, perhaps reason could be
          related to the difference in behaviour observed while
          debugging the code as mentioned above.</font></div>
      <div class=""><font class="" face="Menlo"><br class="">
        </font></div>
      <div class=""><font class="" face="Menlo">Thanks,</font></div>
      <div class=""><font class="" face="Menlo">Manajit</font></div>
      <div class=""><br class="">
      </div>
      <div class="">
        <div>
          <blockquote type="cite" class="">
            <div class="">
              <meta content="text/html; charset=windows-1252"
                http-equiv="Content-Type" class="">
              <div bgcolor="#FFFFFF" text="#000000" class=""> Hi
                Manajit,<br class="">
                <br class="">
                Just a few questions to clarify on the fix.<br class="">
                What is difference between AXUIElementPostKeyboardEvent
                and CGEventCreateKeyboardEvent?<br class="">
              </div>
            </div>
          </blockquote>
          <span class="Apple-tab-span" style="white-space:pre">       </span><br
            class="">
          <blockquote type="cite" class="">
            <div class="">
              <div bgcolor="#FFFFFF" text="#000000" class=""> Why the
                latter was commented? Does it mean that valid modifier
                keys have not been sent by AWT robot?<br class="">
                <br class="">
                --Semyon<br class="">
                <br class="">
                <br class="">
                <div class="moz-cite-prefix">On 5/12/2016 10:45 AM,
                  Manajit Halder wrote:<br class="">
                </div>
                <blockquote
                  cite="mid:538F0C0F-2C53-49CD-96B5-F78A794E3177@oracle.com"
                  type="cite" class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=windows-1252" class="">
                  <div style="line-height: 16px;" class=""><font
                      class="" size="2" face="Menlo">Hi All,</font></div>
                  <div style="line-height: 16px;" class="">
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><br class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo">Kindly review the
                        fix for JDK9.</font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><br class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><b class="">Bug</b>:†</font></div>
                    <div class=""><a moz-do-not-send="true"
                        href="https://bugs.openjdk.java.net/browse/JDK-8155740"
                        class=""><font class="" size="2" face="Menlo">https://bugs.openjdk.java.net/browse/JDK-8155740</font></a></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><u class=""><br
                            class="">
                        </u></font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><b class="">Webrev</b>:†</font></div>
                    <div class=""><a moz-do-not-send="true"
                        href="http://cr.openjdk.java.net/%7Emhalder/8155740/webrev.00/"
                        class=""><font class="" size="2" face="Menlo">http://cr.openjdk.java.net/~mhalder/8155740/webrev.00/</font></a></div>
                    <div class=""><font class="" size="2" face="Menlo"><br
                          class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><b class="">Issue:†</b></font></div>
                    <div class=""><font class="" size="2" face="Menlo">[macosx]

                        robot.keyPress and robot.keyRelease do not
                        generate key event for Alt-Graph key
                        VK_ALT_GRAPH.</font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><br class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><b class="">Cause:†</b></font></div>
                    <div class=""><font class="" size="2" face="Menlo">VK_ALT_GRAPH

                        is a new key added to the Mac OS X platform and
                        it is not mapped to any key on the OS X
                        platform.</font></div>
                    <div class=""><font class="" size="2" face="Menlo"><br
                          class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><b class="">Fix:†</b></font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo">VK_ALT_GRAPH is
                        mapped to right option (<span
                          style="line-height: normal; background-color:
                          rgb(238, 238, 238);" class="">OSX_RightOption)
                          key on Mac OS X.</span></font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><br class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo"><span
                          style="line-height: normal; background-color:
                          rgb(238, 238, 238);" class="">Method†</span><span
                          style="line-height: normal;" class="">Java_sun_lwawt_macosx_CRobot_keyEvent

                          is modified for the following reason:</span></font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo">AXUIElementPostKeyboardEvent
                        posts 0 key code for all †the modifier keys with
                        key codes (16, 17,18, 20, 157) and also for
                        newly added modifier key VK_ALT_GRAPH.</font></div>
                    <div class=""><font class="" size="2" face="Menlo">But
                        it posts correct key code for all the other
                        keys. On the other hand
                        CGEventCreateKeyboardEvent posts correct key
                        code for all the modifier keys and†</font></div>
                    <div class=""><font class="" size="2" face="Menlo">hence
                        it is used to post modifier key events and
                        AXUIElementPostKeyboardEvent is used to post all
                        the remaining key events.</font></div>
                    <div class=""><font class="" size="2" face="Menlo"><br
                          class="">
                      </font></div>
                    <div class=""><font class="" size="2"
                        color="#001e57" face="Menlo">Regards,<br
                          class="">
                        Manajit</font></div>
                  </div>
                </blockquote>
                <br class="">
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
    <br>
  </body>
</html>