Jump to content
Macro Express Forums

Operating on document windows

Recommended Posts

My text editor, TextPad, opens separate windows for each document. In the example below ME Pro recognises only the window 'Basics - TextPad'




So it cannot operate on individual windows in the normal manner (Activate, Move, Position, etc). It's only after maximising a document window that it becomes included on ME Pro's Browse list. For example, maximising the document that has the focus in the above screenshot results in the parent window's title becoming:

Basics - TextPad - [C:\Docs\My Videos\PROJECTS\IOW 2010\Notes-IOW2010.txt]


Does anyone with similar applications have any tips/techniques for working with them please?



Terry, East Grinstead, UK

Link to comment
Share on other sites

Thanks both.


As soon as a window is resized after maximising, it unfortunately becomes invisible to ME Pro.


TextPad can be configured to run multiple instances, but that's not really a path I want to follow.


I'll take a look at Controls, which I hadn't thought of.



Terry, East Grinstead, UK

Link to comment
Share on other sites

If TextPad is an MDI application (and it looks like it may well be), then the windows you're seeing are actually more like controls than real windows. MS Access is an example of an MDI application, and it's very hard to address the windows properly. Take a look in the AutoIt and AutoHotkey forums (fora???) to see some of the difficulties people experience.

Link to comment
Share on other sites

Thanks Paul. The author confirms that it is indeed an MDI type of app.


"I'm not familiar with Macro Express Pro, so can only make general comments

about what you're trying to do. If you close all documents in TextPad,

you're left with a grey area. That's called the MDI (multi-document

interface) window, and all document windows are children of that. Any

program that wants to manipulate the size of document windows would have to

find TextPad's main window, in the usual way, then search its window

hierarchy for the MDI window. Once it's got a handle to that, it can search

its children for one matching a specified document. You may need to ask

tech support at Macro Express if their product will support doing that."




I'm not very comfortable with the use of Controls. The great majority of my past attempts have failed when using Get Control. Using

Capture Control from Specific Coordinates is usually OK, but that is very similar to using familiar Mouse commands.


In this case I tried this exploratory macro on the title of opened document

C:\Documents and Settings\All Users\Application Data\MAGIX\Movie_Edit_Pro_16_Plus\UserData\MovieEdit.log


Get Control: (TEXTPAD.EXE) Using contents -> %MovieEditLog%

Text Box Display:


but the TBD result was the unexpected

C:and SettingsUsersData_Edit_Pro_16_Plus.log


Same result whether I used

Save the control using the z-order of the control


Save the control using the contents of the control


Anyone know how that happened?



Terry, East Grinstead, UK

Link to comment
Share on other sites

That's a kind offer, Paul, thank you. I may well seek your help with AutoIt later, because it's been on my 'Must get into' list for ages. I did actually install it nearly a year ago and played around with it briefly. But of course that wasn't enough. I've certainly no doubts about its potential to reach those parts that MEP doesn't. And when I do enlist your help with my first few scripts, I'll be pleased to make your consideration no less than TWICE what it's been so far! But first I need to do that 'homework' or I won't even know enough to couch sensible questions. I'm off for a trip to USA in a few days. Maybe on my return I'll move AutoIt up the priority list...


Meanwhile I spent some hours last night tackling my TextPad macros the hard way and have made some satisfying progress. If anyone else ends up here with a similar requirement, here are some tips:


1. With a document window open at unknown size and position inside a maximised parent window, a key step is to get the mouse to the document's top left icon. The one sometimes used for Move/Size/etc - I'll call it TL.


2. A relatively fast way to do this is to first get to the top left corner of the document, which (in my case at least) is always at a fixed position relative to TL. So use script like this:


Text Type (Simulate Keystrokes): <CONTROL><HOME> // Gets cursor in a fixed position relative to the top left icon.

Delay: 100 milliseconds

Mouse Move: To the Text Cursor Position

Mouse Move: -10, -16 Relative to Last Position // Moves mouse to top left icon.

Mouse Left Click


3. Then code like this can be used to move the document window to the top left, by first calculating the x and y displacements needed:


<GET MOUSE POSITION Option="\x00" X="%Xmouse%" Y="%Ymouse%" _COMMENT="Get position of top left icon."/>

<VARIABLE MODIFY INTEGER Option="\x01" Destination="%Xdiff%" Value1="19" Value2="%Xmouse%"/>

<VARIABLE MODIFY INTEGER Option="\x01" Destination="%Ydiff%" Value1="84" Value2="%Ymouse%"/>


<MOUSE LEFT CLICK _COMMENT="Click on top left icon."/>

<DELAY Flags="\x02" Time="10"/>


<COMMENT Value="Move."/>

<TEXT TYPE Action="0" Text="m" _COMMENT="Move (places cursor in middle of title)."/>

<DELAY Flags="\x02" Time="50"/>


<MOUSE MOVE Option="\x03" X="%Xdiff%" Y="%Ydiff%" _PROMPT="0x000A"/>



4. Sizing (say to extend the window to maximum height) is achieved in a similar way, but with an added sub-macro to drag it fast:


Text Type (Simulate Keystrokes): s // Size (automatically places 4-point mouse cursor in centre of window).

Delay: 50 milliseconds

Mouse Left Button Down

Macro Run: Drag mouse down - Fast as possible

Mouse Left Button Up


5. Some trial/error is necessary to get the timing right, but the sub-macro looks like this for my (single) 1920 x 1200 screen.


Mouse Left Button Down

Repeat Start (Repeat 1180 times)

Mouse Move: 0, 4 Relative to Last Position

End Repeat

Mouse Left Button Up


I'm sure all of this stuff could be improved, but it seems to cut the mustard reasonably well so far.



Terry, East Grinstead, UK

Link to comment
Share on other sites

Hi Terry,


Obviously, the preferred approach would be to interact programmatically with user interface elements to figure out the name of the window. But this is not always possible, at least not with Macro Express. I have constructed a number of macros for Mozilla Firefox that might be applicable to your situation; I use a workaround because there is no way -- or rather, I know of no way -- to capture the name of a tabbed page.


The purpose of these scripts is to estimate the dimensions and positions of the focused tabbed page. The basic strategy is to move the mouse pointer to the top left corner of the window, and then perform a series of pixel hunts to calculate the width and height of the menubar, address bar, etc. based on changing colours.


When the macro has done all of its work, the mouse pointer is where it needs to be. The method of pixel hunting/keeping track of variables is definitely a brute force method. But it works reliably and quickly.


I would not call this solution elegant, but it works with different window sizes and positions, resolution settings, display settings, and even with different sized monitors. It is not an ideal solution. But until I get a better handle on AutoHotkey, or until the good folks at Insight Software provide us with new functionality, brute force solutions that infer information about the user interface are almost always possible.

Link to comment
Share on other sites

Thanks Alan.


I agree, and as you see I've used rather similar principles in my TextPad macros so far. The step of moving the mouse pointer to the top left corner of the window was crucial for this, as it was for your FF work.


Firefox tab names in my case are accessible like this:




(If I recall correctly, that functionality is from the Tab Mix Plus extension.)


Or if you meant the window titles, then View > Source will get you to that, inside the <Title> tags.



Terry, East Grinstead, UK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...