hu_hao
January 12, 2022, 10:49am
1
I want to make a macro to judge if the mouse cursor in the current active App,
So , if the mouse Position is (x,y) and current active window position is (X,Y,W,H)
if(x>=X && x<= X+W && y<=Y && y<=Y-H) , the mouse cursor is in the current active app window,
I searched some token, but dont know how to compose those to a macro together,
Application: %Application%1%
Window Name: %WindowName%1%
Size (W,H): %WindowSize%1%
Position (→, ↓): %WindowPosition%1%
MouseX:%Calculate%MOUSEX()%
MouseY:%Calculate%MOUSEY()%
,I want to get the ''W' of window, and I try to use Calculate token,
// this not work
Size_W: %Calculate%WindowSize%1.width%
how to make this macro?
gglick
January 12, 2022, 11:51am
2
You're looking for the Window Frame token , which can provide all the values you need for a macro like this when assigned to a variable.
Example Macro.kmmacros (3.2 KB)
2 Likes
Zabobon
January 12, 2022, 11:55am
3
While I was typing my reply, it looks like @gglick jumped ahead and gave you the answer But for completeness here is my reply anyway:
Have a look at this page:
https://wiki.keyboardmaestro.com/token/Window_Tokens
Also, this Token gives you the Width of the Front Window in one step:
%FrontWindowFrame[3]%
NB:
%FrontWindowFrame[1]% is left coordinate of top left of front window
%FrontWindowFrame[2]% is top coordinate of top left of front window
%FrontWindowFrame[3]% is width of front window
%FrontWindowFrame[4]% is height of front window
2 Likes