Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

[MBS] Question about AXUIElementMBS (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] CarbonMonitorEvents equivalent for Windows
Next thread: [MBS] Mouse events on Windows


[MBS] PortAudio   -   Garth Hjelte
  [MBS] Question about AXUIElementMBS   -   Jean-Luc Arnaud
   Re: [MBS] Question about AXUIElementMBS   -   Christian Schmitz
    Re: [MBS] Question about AXUIElementMBS   -   Jean-Luc Arnaud
   Re: [MBS] Question about AXUIElementMBS   -   Marnaud
    Re: [MBS] Question about AXUIElementMBS   -   Jean-Luc Arnaud
   Re: [MBS] Question about AXUIElementMBS   -   Marnaud
    Re: [MBS] Question about AXUIElementMBS   -   Jean-Luc Arnaud

[MBS] Question about AXUIElementMBS
Date: 14.01.15 11:26 (Wed, 14 Jan 2015 11:26:40 +0100)
From: Jean-Luc Arnaud
Hello,

Using AXUIElementMBS, is it possible to send a KeyPress event to the
frontmost application, even if it's not a Xojo one?

I coded that :

dim a as new AXUIElementMBS // get the element
a.PostKeyboardEvent(0, 53, true ) // Esc down
a.PostKeyboardEvent(0, 53, false ) // Esc up

It does not work, with or without enabling access for assistive devices.
Where am I wrong?
Should I use another class instead of AXUIElementMBS

TIA for any help

Re: [MBS] Question about AXUIElementMBS
Date: 14.01.15 18:26 (Wed, 14 Jan 2015 18:26:55 +0100)
From: Christian Schmitz

> Am 14.01.2015 um 11:26 schrieb Jean-Luc Arnaud <<email address removed>>:
>
> Hello,
>
> Using AXUIElementMBS, is it possible to send a KeyPress event to the
> frontmost application, even if it's not a Xojo one?

Of course with RemoteControlMBS module.

> I coded that :
>
> dim a as new AXUIElementMBS // get the element
> a.PostKeyboardEvent(0, 53, true ) // Esc down
> a.PostKeyboardEvent(0, 53, false ) // Esc up

what is a?

>From Apple's AXUIElementPostKeyboardEvent documentation:
You can only pass in the system-wide or application AXUIElementRef.

so first question is what a.handle is before calling it and what lasterror property is after calling it.


Greetings
Christian

Re: [MBS] Question about AXUIElementMBS
Date: 15.01.15 10:46 (Thu, 15 Jan 2015 10:46:48 +0100)
From: Jean-Luc Arnaud
I'm a stupid guy!

Don't know why I tried to use AXUIElementMBS, while I already used
RemoteControlMBS!
Thanks, Christian, what I was trying to do works well with
RemoteControlMBS.Mac(or Win)PressKey.

Jean-Luc Arnaud

Le 14/01/2015 18:26, Christian Schmitz a écrit :
>> Am 14.01.2015 um 11:26 schrieb Jean-Luc Arnaud <<email address removed>>:
>>
>> Hello,
>>
>> Using AXUIElementMBS, is it possible to send a KeyPress event to the
>> frontmost application, even if it's not a Xojo one?
> Of course with RemoteControlMBS module.
>
>> I coded that :
>>
>> dim a as new AXUIElementMBS // get the element
>> a.PostKeyboardEvent(0, 53, true ) // Esc down
>> a.PostKeyboardEvent(0, 53, false ) // Esc up
> what is a?
>
> >From Apple's AXUIElementPostKeyboardEvent documentation:
> You can only pass in the system-wide or application AXUIElementRef.
>
> so first question is what a.handle is before calling it and what lasterror property is after calling it.
>
> Greetings
> Christian
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Question about AXUIElementMBS
Date: 14.01.15 18:01 (Wed, 14 Jan 2015 18:01:50 +0100)
From: Marnaud
Le 14 janv. 2015 à 12:01, Jean-Luc Arnaud <<email address removed>> a écrit:

> I'm probably wrong, but I thought that:
>
> dim a as new AXUIElementMBS
>
> would do the trick, don't it?

According to the documentation:
http://www.monkeybreadsoftware.net/class-axuielementmbs.shtml
“This class represents an element of the User Interface of an application.”
So clearly, your object (with only New) doesn't target anything.
There is an example (at the page mentioned) which shows how to instantiate one; perhaps you can find one that suits you?

> If so, how to send a Keyboard event to the frontmost app?

Doesn't the RemoteControlMBS class work for that?

> Is it possible to send a KeyPress event to the frontmost application, even if it's not a Xojo one?

Well, I'll finally ask my question, which I have since the beginning (it stayed in my mind until now…): how would a Xojo app behave differently than a, say, XCode one about receiving keys press?
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Question about AXUIElementMBS
Date: 15.01.15 10:54 (Thu, 15 Jan 2015 10:54:59 +0100)
From: Jean-Luc Arnaud
Thanks, Arnaud, clearer after reading the doc and the example.

> Well, I'll finally ask my question, which I have since the beginning (it stayed in my mind until now…): how would a Xojo app behave differently than a, say, XCode one about receiving keys press?
I just wanted to say that the frontmost app is not the Xojo one I'm
currently coding (or trying to code! ;-) ).
So, managing Keyboard events by my own is not 'internally' possible.

Jean-Luc Arnaud

Le 14/01/2015 18:01, Marnaud a écrit :
> Le 14 janv. 2015 à 12:01, Jean-Luc Arnaud <<email address removed>> a écrit:
>
>> I'm probably wrong, but I thought that:
>>
>> dim a as new AXUIElementMBS
>>
>> would do the trick, don't it?
> According to the documentation:
> http://www.monkeybreadsoftware.net/class-axuielementmbs.shtml
> “This class represents an element of the User Interface of an application.”
> So clearly, your object (with only New) doesn't target anything.
> There is an example (at the page mentioned) which shows how to instantiate one; perhaps you can find one that suits you?
>
>> If so, how to send a Keyboard event to the frontmost app?
> Doesn't the RemoteControlMBS class work for that?
>
>> Is it possible to send a KeyPress event to the frontmost application, even if it's not a Xojo one?
> Well, I'll finally ask my question, which I have since the beginning (it stayed in my mind until now…): how would a Xojo app behave differently than a, say, XCode one about receiving keys press?
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Question about AXUIElementMBS
Date: 14.01.15 11:57 (Wed, 14 Jan 2015 11:57:27 +0100)
From: Marnaud
Le 14 janv. 2015 à 11:26, Jean-Luc Arnaud <<email address removed>> a écrit:

> Hello,
>
> Using AXUIElementMBS, is it possible to send a KeyPress event to the
> frontmost application, even if it's not a Xojo one?
>
> I coded that :
>
> dim a as new AXUIElementMBS // get the element
> a.PostKeyboardEvent(0, 53, true ) // Esc down
> a.PostKeyboardEvent(0, 53, false ) // Esc up
>
> It does not work, with or without enabling access for assistive devices.
> Where am I wrong?
> Should I use another class instead of AXUIElementMBS

Hello,

Shouldn't an AXUIElement target (i.e. represent) something (a button, a window, etc.)?
In your code above, I don't see how your keyboard event would target an object (even the front process, which would still be an object).
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Question about AXUIElementMBS
Date: 14.01.15 12:01 (Wed, 14 Jan 2015 12:01:49 +0100)
From: Jean-Luc Arnaud
I'm probably wrong, but I thought that:

dim a as new AXUIElementMBS

would do the trick, don't it?

If so, how to send a Keyboard event to the frontmost app?

Thanks

Jean-Luc Arnaud

Le 14/01/2015 11:57, Marnaud a écrit :
> Le 14 janv. 2015 à 11:26, Jean-Luc Arnaud <<email address removed>> a écrit:
>
>> Hello,
>>
>> Using AXUIElementMBS, is it possible to send a KeyPress event to the
>> frontmost application, even if it's not a Xojo one?
>>
>> I coded that :
>>
>> dim a as new AXUIElementMBS // get the element
>> a.PostKeyboardEvent(0, 53, true ) // Esc down
>> a.PostKeyboardEvent(0, 53, false ) // Esc up
>>
>> It does not work, with or without enabling access for assistive devices.
>> Where am I wrong?
>> Should I use another class instead of AXUIElementMBS
> Hello,
>
> Shouldn't an AXUIElement target (i.e. represent) something (a button, a window, etc.)?
> In your code above, I don't see how your keyboard event would target an object (even the front process, which would still be an object).
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info