Activate macro with screen click

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Activate macro with screen click

Post by Marcus Tettmar » Fri Mar 31, 2006 9:03 am

Some code to detect and act on a mouse click in a specific area of the screen. For more details see this thread:

http://www.mjtnet.com/forum/viewtopic.php?p=11421#11421

// Set Bounds Here
Let>X1=440
Let>X2=630
Let>Y1=40
Let>Y2=200

// Only detect clicks on Desktop, or Anywhere?
Let>OnlyDesktop=1

OnEvent>KEY_DOWN,VK1,0,MouseClick

Label>MainLoop
Wait>0.2
Goto>MainLoop

SRT>MouseClick
GetActiveWindow>title,xact,yact

// OnlyDesktop/all window check
Let>OkToContinue=FALSE
If>OnlyDesktop=1
If>title=Program Manager
Let>OkToContinue=TRUE
Endif
Else
Let>OkToContinue=TRUE
Endif

If>OkToContinue=TRUE
// Check Cursor is Within Bounds
GetCursorPos>X,Y
If>{((%X% >= %X1%) AND (%X% = %Y1%) AND (%Y% command or call to a subroutine
MessageModal>Hello
// Macro>your_macro
// Pass LClick on?
// LClick
Endif
Endif
END>MouseClick
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts