Re: Microsoft UI Automation in VisualWorks?

Reinout Heeck <[email protected]> Wed, 19 Nov 2025 17:29:45 +0100
Newsgroups gmane.comp.lang.smalltalk.vwnc
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------472JtnNL6hCX0YBLddQUCOXE
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Hey Mark,

WM_GETOBJECT =3D 0x003D

Have a look at InputState >> send:eventUnknown: and see if you are lucky=20
and can catch a 16r3D there?


Not sure how to return the com interface from there though...

-Reinout


On 19/11/2025 12:23, Mark Plas wrote:
>
> Hi all,
>
> Has anyone ever implemented *Microsoft* UI Automation in VisualWorks?
>
> https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win=
32/winauto/entry-uiauto-win32__;!!DZ3fjg!_tA_rrV1wonak0xM1zJgVwXEQ_qg_YwilH=
KDLrj_O27Z4zdOeNgj4fBKZUFHG9UHjr3KYUXyxWdBzgglo4L0VNaUCap6YDpQ$ =20
> <https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/wi=
n32/winauto/entry-uiauto-win32__;!!DZ3fjg!_aQGOK7EA64lDd39rsL3YgMyNrjpz-h71=
lMBNG-HmSuaCpXFN4HqRsEhPwgCPsx8cr6dxMreJnNEF_VebzM95XCf$>
>
> This is becoming a requirement for us, and I wanted to know if anyone=20
> has ever done this before.
>
> Alternatively, does anyone know how to intercept a windows message and=20
> return a result for it from within VisualWorks?
>
> As a small experiment, I tried to intercept the WM_GETOBJECT message=20
> as described here:
>
> https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win=
32/winauto/wm-getobject__;!!DZ3fjg!_tA_rrV1wonak0xM1zJgVwXEQ_qg_YwilHKDLrj_=
O27Z4zdOeNgj4fBKZUFHG9UHjr3KYUXyxWdBzgglo4L0VNaUCc_zaiyd$ =20
> <https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/wi=
n32/winauto/wm-getobject__;!!DZ3fjg!_aQGOK7EA64lDd39rsL3YgMyNrjpz-h71lMBNG-=
HmSuaCpXFN4HqRsEhPwgCPsx8cr6dxMreJnNEF_Veb6sI9g7W$>
>
> In order to do this from within Smalltalk, I tried to replace the=20
> window procedure of a window, with a callback like this:
>
> | callback old |
>
> old :=3D self getWindowLong: aWindow windowHandle nIndex: -4.
>
> callback :=3D CCallback
>
> do: [:hwnd :uMsg :wParam :lParam | self CallWindowProcWWith: old with:=20
> hwnd with: uMsg with: wParam with: lParam]
>
> ofType: self WNDPROC pointerType.
>
> self setWindowLongPtr: aWindow windowHandle nIndex: -4 dwNewLong:=20
> callback.
>
> self halt
>
> In the callback I just call the old window procedure, so the window=20
> should just behave as if nothing was changed.
>
> However, this doesn=E2=80=99t really work. As long as I only move the mou=
se=20
> over a window it seems to work, but as soon as I click on a window=20
> VisualWorks stops handling messages and the application needs to be=20
> killed.
>
> Does anyone know how to do this?
>
> In summary:
>
>   * Has anyone implemented Microsoft UI Automation in VisualWorks?
>   * Does anyone know how to intercept windows messages and return a
>     result for them from within VisualWorks Smalltalk code?
>
> Thanks in advance,
>
> Mark
>=

--------------472JtnNL6hCX0YBLddQUCOXE
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hey Mark,</p>
    <p>WM_GETOBJECT = 0x003D</p>
    <p>Have a look at InputState &gt;&gt; send:eventUnknown: and see if
      you are lucky and can catch a 16r3D there?</p>
    <p><br>
    </p>
    <p>Not sure how to return the com interface from there though...</p>
    <p>-Reinout</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 19/11/2025 12:23, Mark Plas wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:AM8PR05MB79547AF638FD711EB9EFD547FAD7A@AM8PR05MB7954.eurprd05.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <style>@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
	{font-family:Aptos;}p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:12.0pt;
	font-family:"Aptos",sans-serif;
	mso-ligatures:standardcontextual;}a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#467886;
	text-decoration:underline;}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	font-size:12.0pt;
	font-family:"Aptos",sans-serif;
	mso-ligatures:standardcontextual;}span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Aptos",sans-serif;
	color:windowtext;}.MsoChpDefault
	{mso-style-type:export-only;}div.WordSection1
	{page:WordSection1;}ol
	{margin-bottom:0cm;}ul
	{margin-bottom:0cm;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt">Hi all,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">Has anyone
            ever implemented <b>
              Microsoft</b> UI Automation in VisualWorks?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="text-indent:36.0pt"><span
            style="font-size:11.0pt"><a
href="https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win32/winauto/entry-uiauto-win32__;!!DZ3fjg!_aQGOK7EA64lDd39rsL3YgMyNrjpz-h71lMBNG-HmSuaCpXFN4HqRsEhPwgCPsx8cr6dxMreJnNEF_VebzM95XCf$"
              moz-do-not-send="true">https://learn.microsoft.com/en-us/windows/win32/winauto/entry-uiauto-win32</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">This is
            becoming a requirement for us, and I wanted to know if
            anyone has ever done this before.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">Alternatively,
            does anyone know how to intercept a windows message and
            return a result for it from within VisualWorks?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">As a small
            experiment, I tried to intercept the WM_GETOBJECT message as
            described here:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            <a
href="https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows/win32/winauto/wm-getobject__;!!DZ3fjg!_aQGOK7EA64lDd39rsL3YgMyNrjpz-h71lMBNG-HmSuaCpXFN4HqRsEhPwgCPsx8cr6dxMreJnNEF_Veb6sI9g7W$"
              moz-do-not-send="true">
https://learn.microsoft.com/en-us/windows/win32/winauto/wm-getobject</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">In order to
            do this from within Smalltalk, I tried to replace the window
            procedure of a window, with a callback like this:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            | callback old |<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            old := self getWindowLong: aWindow windowHandle nIndex: -4.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            callback := CCallback<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">                                                               
            do: [:hwnd :uMsg :wParam :lParam | self CallWindowProcWWith:
            old with: hwnd with: uMsg with: wParam with: lParam]<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">                                                               
            ofType: self WNDPROC pointerType.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            self setWindowLongPtr: aWindow windowHandle nIndex: -4
            dwNewLong: callback.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">               
            self halt<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">In the
            callback I just call the old window procedure, so the window
            should just behave as if nothing was changed.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">However,
            this doesn’t really work. As long as I only move the mouse
            over a window it seems to work, but as soon as I click on a
            window VisualWorks stops handling messages and the
            application needs to be killed.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">Does anyone
            know how to do this?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">In summary:<o:p></o:p></span></p>
        <ul style="margin-top:0cm" type="disc">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              style="font-size:11.0pt">Has anyone implemented Microsoft
              UI Automation in VisualWorks?<o:p></o:p></span></li>
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              style="font-size:11.0pt">Does anyone know how to intercept
              windows messages and return a result for them from within
              VisualWorks Smalltalk code?<o:p></o:p></span></li>
        </ul>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">Thanks in
            advance,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">Mark<o:p></o:p></span></p>
      </div>
    </blockquote>
  </body>
</html>

--------------472JtnNL6hCX0YBLddQUCOXE--