activate macro with mouse click on the screen

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
braddog
Newbie
Posts: 3
Joined: Mon Mar 27, 2006 1:26 am

activate macro with mouse click on the screen

Post by braddog » Mon Mar 27, 2006 1:38 am

I am trying to decide about getting MacroScheduler. I ordered the beginner's manual yesterday to review. **** Could someone please tell me if macros can be ** activated by defining an area on the screen, that when clicked with the mouse, will activate a macro ****. I have found this to be a useful feature with Macro Express. Can this be done with MacroScheduler? In other words, the activation event for a given macro is defined as a click within specific coordinates on the screen that define a rectangle. Then a bitmap image can be used to visually indicate where on the screen to click in order to activate a certain macro.

Thank you very much.

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

Post by Marcus Tettmar » Mon Mar 27, 2006 7:39 am

There's no way in Macro Scheduler to do that at present. But it's a great idea and one I will add to the wish list.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

braddog
Newbie
Posts: 3
Joined: Mon Mar 27, 2006 1:26 am

button overlying background bitmap image

Post by braddog » Thu Mar 30, 2006 2:58 pm

Is it possible to place buttons on top of a background bitmap image? You could then activate different macros by clicking different buttons. There would be an image in the background to assist with organizing the buttons graphically. I hope this is possible since we can't click on a specific portion of the screen to activate macros. Maybe we can click on a button placed at a specific part of the screen. The important point is having the background bitmap image for orientation.

Thank you.

User avatar
JRL
Automation Wizard
Posts: 3502
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Mar 30, 2006 3:27 pm

I'm not sure I undestand this discussion. But....

Very definitely, A macro can be written that places a dialogbox on the screen with buttons of any size desired. The dialog can have a bitmap as its background. Those buttons can have bitmaps as their background. The buttons, when selected, can perform any task imaginable including the execution of other macros. The original dialog box could be full screen size and the buttons could be sized such that they completely fill the dialogbox.

Is something like this what you are looking for?

Later,
Dick

User avatar
JRL
Automation Wizard
Posts: 3502
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Mar 30, 2006 3:58 pm

Another thought.

Create a bitmap with the appropriate colors and borders and use it as a Windows wallpaper. this could be turned on and off through the registry using Macro Scheduler. Then use OnEvent>VK1 to capture any mouse click that occurs anywhere on the screen. The subroutine called by the OnEvent> mouseclick will first capture the coordinates of the mouse position, then run the appropriate macro based on the coordinates.

Later,
Dick

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Thu Mar 30, 2006 8:51 pm

How about something like the script below?
You can place the dialog anywhere you like on your desktop and have as many buttons as you want to run your macros.

When you compile the script you can include the following parameters -NOSYSTRAY -HIDE this way you have nothing in the system tray or taskbar.


Dialog>Dialog1
Caption=Your Dialog
Width=193
Height=244
Top=CENTER
Left=CENTER
Button=Macro 1,8,8,75,25,1
Button=Macro 2,8,40,75,25,3
Button=Macro 3,8,72,75,25,4
Button=Macro 4,8,104,75,25,5
Button=Macro 5,8,136,75,25,6
Button=Macro 6,8,168,75,25,7
Button=Exit,48,208,75,25,2
Button=Macro 7,96,8,75,25,8
Button=Macro 8,96,40,75,25,9
Button=Macro 9,96,72,75,25,10
Button=Macro 10,96,104,75,25,11
Button=Macro 11,96,136,75,25,12
Button=Macro 12,96,168,75,25,13
EndDialog>Dialog1

Show>Dialog1
LibFunc>user32,FindWindowA,dhwnd,TForm,Your Dialog
LibFunc>user32,SetWindowLongA,sres,dhwnd,-16,131072
CloseDialog>Dialog1
show>Dialog1
label>start
rda>Dialog1
label>main loop
wait>.05
gda>Dialog1,r
if>r=1,do something1
if>r=2,2
if>r=3,do something2
if>r=4,do something3
if>r=5,do something4
if>r=6,do something5
if>r=7,do something6
if>r=8,do something7
if>r=9,do something8
if>r=10,do something9
if>r=11,do something10
if>r=12,do something11
if>r=13,do something12
goto>main loop
label>do something1
///Execute Macro 1
ExecuteFile>(your directory)\Macro1.exe
goto>start
label>do something2
///Execute Macro 2
ExecuteFile>(your directory)\Macro2.exe
goto>start
label>do something3
///Execute Macro 3
ExecuteFile>(your directory)\Macro3.exe
goto>start
label>do something4
///Execute Macro 4
ExecuteFile>(your directory)\Macro4.exe
goto>start
label>do something5
///Execute Macro 5
ExecuteFile>(your directory)\Macro5.exe
goto>start
label>do something6
///Execute Macro 6
ExecuteFile>(your directory)\Macro6.exe
goto>start
label>do something7
///Execute Macro 7
ExecuteFile>(your directory)\Macro7.exe
goto>start
label>do something8
///Execute Macro 8
ExecuteFile>(your directory)\Macro8.exe
goto>start
label>do something
///Execute Macro 9
ExecuteFile>(your directory)\Macro9.exe
goto>start
label>do something10
///Execute Macro 10
ExecuteFile>(your directory)\Macro10.exe
goto>start
label>do something11
///Execute Macro 11
ExecuteFile>(your directory)\Macro11.exe
goto>start
label>do something12
///Execute Macro 12
ExecuteFile>(your directory)\Macro12.exe
goto>start
label>do something13
///Execute Macro 13
ExecuteFile>(your directory)\Macro13.exe
goto>start
///Label>2 means exit the script
label>2

Last edited by Rain on Fri Mar 31, 2006 1:40 pm, edited 1 time in total.

braddog
Newbie
Posts: 3
Joined: Mon Mar 27, 2006 1:26 am

activate macro with mouse click on the screen

Post by braddog » Fri Mar 31, 2006 1:38 am

Appreciate everyone's help. I will try to look at this this weekend.

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

Post by Marcus Tettmar » Fri Mar 31, 2006 8:35 am

Some great ideas here. Dick was bang on the button with the OnEvent and VK1 suggestion. For once I missed that and I can't believe my initial response was that this wasn't possible - most unlike me. In fact the OnEvent suggestion is really elegant. I've created an example which works really nicely. Here's the code:

// 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

Use this as a controlling script. This would need to run while you want the click on the screen area to be detected. So if that is all the time, have it set to run on startup. Or compile it to an exe and have the executable and have the exe run on startup - hidden if you wish.

You can modify the bounds with the first four variables, and set whether this should only work on the desktop or on any window. Set OnlyDektop to 0 for any window, 1 for desktop only. If you want you can modify it further to work on only one specific window - see the GetActiveWindow check in the subroutine.

Replace the MessageModal line on line 33 with a call to your macro, or run an external app, or call a subroutine or do whatever it is you want to do when the click is detected.

Note that depending what your code does the click on the screen could be "stolen" by the macro (e.g. in this case focus is stolen) and can therefore prevent it being activated on the window. You can easily get round this by issuing an LClick afterwards if you want to pass the click on to the window beneath.

Thanks for the idea Dick!
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