Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Every (almost) control in Windows is a window itself. It has got its class and instance name. Since the construction of every MailTo window in each mail client remains the same, after gaining knowledge how to find appropriate control a solution can be built.<br> This is where Spy++ from Visual Studio comes in handy (if you do not have it, try to find some similar tool, there is a freeware version at <a href="http://msdn.microsoft.com/pl-pl/magazine/cc163617(en-us).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/pl-pl/magazine/cc163617(en-us).aspx</a> but it lacks cool searching tool).<br> So, After starting Spy++ and mail program, we hit “New mail” and mailing window will appear. Refresh in Spy++, and use “Find window” tool – click on your TO list, and you will se how it is built.<br> I started with Outlook Express. The mail window is of class ATH_Note, then inside address area is a window of class OE_Envelope and inside this window there are several windows, some of them are of class RichEdit20W. The “To” field is the first one.<br> <br></p> <pre><code>procedure UpdateToOE; var Window:Thandle; Text:PChar; begin {Lets find Mail window} Window:=FindWindow('ATHNote',nil); if (Window = 0) then Exit; {Lets find adress area inside} Window:= FindWindowEx(Window,0,'OEEnvelope',nil); if (Window = 0) then Exit; {Lets find TO field - remeber this is the first field of this class} Window:= FindWindowEx(Window,0,'RichEdit20W',nil); if (Window = 0) then Exit; {Prepare text into PChar} Text:='test@test.com'; {Send message WMSETTEXT which will set our text in control} SendMessage(Window,WMSETTEXT,0,Integer(Text)); {Sending one extra space to prevent OE does not notice - answer to grzegorz's question} SendMessage(Window,WM_CHAR,32,1); //done! End; </code></pre> <p><br> Note: FindWindowEx when second param is 0 will always search for FIRST in the row – so, but if you will do sth like this:<br></p> <pre><code>Window:=FindWindow('ATH_Note',nil);&lt;br&gt; if (Window = 0) then Exit;&lt;br&gt; Window:= FindWindowEx(Window,0,'OE_Envelope',nil);&lt;br&gt; if (Window = 0) then Exit;&lt;br&gt; Sibling:= FindWindowEx(Window,0,'RichEdit20W',nil);&lt;br&gt; if (Sibling = 0) then Exit;&lt;br&gt; Window:=FindWindowEx(Window, Sibling, 'RichEdit20W',nil);&lt;br&gt; if (Window = 0) then Exit;&lt;br&gt; Text:='test@test.com';&lt;br&gt; SendMessage(Window,WM_SETTEXT,0,Integer(Text));&lt;br&gt; </code></pre> <p>The text will be put in a SECOND edit field. See msdn for FindWindowEx.<br> <br> So, this is good for OE (XP SP3 IE7). But what with MS Outlook? I checked it with Spy++ at work and “To” Field is a second in a row “RichEdit20WPT” class (note T on the end), parent class is “#32770 (Dialog)”, parent of this is “AfxWndW” and once again parent class is “AfxWndW” (this is some kind MS-style TPanel in TPanel) and – tadam! – mail window is of a class “rctrl_renwnd32”. So the pseudocode for this will be:<br></p> <pre><code>Window:=FindWindow('rctrl_renwnd32',nil);&lt;br&gt; Window:= FindWindowEx(Window,0,’AfxWndW’,nil);&lt;br&gt; Window:= FindWindowEx(Window,0,’AfxWndW’,nil);&lt;br&gt; Window:= FindWindowEx(Window,0,’#32770 (Dialog)’,nil);&lt;br&gt; //Search for FIRST (don’t know what it is)&lt;br&gt; Sibling:= FindWindowEx(Window,0,’RichEdit20WPT’,nil);&lt;br&gt; //Search for TO field&lt;br&gt; Window:= FindWindowEx(Window,Sibling,’RichEdit20WPT’,nil);&lt;br&gt; Text:='test@test.com';&lt;br&gt; SendMessage(Window,WM_SETTEXT,0,Integer(Text));&lt;br&gt; </code></pre> <p><br> <br> Probably you will want to use WM_GETTEXT to extract current text and update new text accordingly, but this is beyond the scope of getting into edit field.<br> BTW: This code strongly depends of outlook version, so try to check your version with Spy++ before).<br></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload