Running different macros based on the size of a window

Is there any way that a macro could run only at a specific size of a window? I have several DOC files, and sometimes I edit them in maximized size, and sometimes as I need to review other files at the same time, I divide my monitor into 3 parts and the DOC file occupies 1/3 of the screen. My macro works on mouse clicks and changing the size of the window would mess up the point that the mouse should click. It is the same concept as if the wireless name is this then run this, otherwise, run the other.

I appreciate it a lot if someone could help me.

Sounds like your mouse clicks are all happening at absolute coordinates. You should try changing them to be relative to the top-left corner of the window. No need then for different macros. Or if you are finding buttons change position with the change in size of window, you could test for the window size and use appropriate coords for your mouse clicks - again relative to the window and not the whole screen.

Alternatively, use found image actions - look in the KM wiki for those!


You could also re-set the DOC window size as the first sub-routine of your macro, although it sounds like "Found Screen Images" might be a good option, as mentioned by @tiffle.


As well as the good advice above -- if you really want it to only run at a specific window size, make the first action of your macro an "If Then Else" that tests the window size and either continues or cancels the macro depending on the results.


Thank you, guys. Awsome comments.
Nige_S > Which condition should I choose for "If Then Else"? or how to put checking the size of the window as a condition?

You mention DOC files so I’ll point out that Microsoft Word has reasonable AppleScript support. Might be worth googling (or letting us know) what your button click macros are doing once they’ve got the right co-ordinates.


Thanks. I use Parallels on Mac. It simply closes the Word file. The thing with a keyboard shortcut is after opening several Word files, it closes the DOC file but then again I should manually close a blank word file underneath of that to see the next word file. The problem with the Quit shortcut is it closes all of the Word files.

Thanks. I did the relative to the top left corner but I did not see a change in the position of the mouse based on the size of the Window. Not sure, where I got it wrong.

You can get window width and height using the %WindowSize% token, then compare those values.


Are you saying you are using PC Word running in Parallels? That could make life a lot more difficult... Are you running your Windows VM in a single Parallels window, or using Coherence mode?

Perhaps you could explain again what you are trying to achieve. The easiest way to do that is to do the process by hand, write down every step, then post that here.


You're welcome.

My reply was a more-or-less scattergun response to your question and now I know it was a waste of time since I assumed you were running Mac apps on your Mac.

Now, thanks to @Nige_S, we can say that if you're not using Coherence then KM will not be able to see the individual windows of your apps. Presumably you are using MS Word on Windows, in which case @vincent_ardern's suggestion about AppleScript is a non-starter sadly.

So rather than let us all try to guess what is actually going on maybe you could do us all a favour to help us help you better by having a look at this:
Tip: How Do I Get The Best Answer in the Shortest Time?


Thank you guys and sorry for the confusion. I will take that into consideration if I wanted to post a new question. My knowledge in this area is very basic. I work on MS word using Parallels and I am not using coherence. Actually, with the help provided especially Nige_S suggestion for using a window size token, I managed to find a solution for my problem and now it beautifully works.