Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help needed

I have prepared macro for "MS Paint".

I would like to execute this macro (hotkey) only when "Pencil" tool is selected.
If another tool is selected, the hotkey should not run the macro.

Is it possible?
How can i do this?

Anybody help me?
What is your Windows version? On XP and 7 need different code.

What is better?:
1. Run if pencil button is pressed.
2. Run if mouse pointer is pencil.
System - Windows 7 64bit.

Better is no 1 - if pencil button is pressed.
The macro can look for pressed pencil button image, and don't run if not found.

Macro Macro1870
Trigger CSp /MSPAINT     Help - how to add the trigger to the macro
Copy      Help
int w=win
if(!w or !wintest(w "Paint" "MSPaintApp")) ret
if(!scan("macro:mspaint pencil pressed.bmp" child("" "NetUIHWND" w 0x1) 0 16 10)) ret

OnScreenDisplay "macro"

here "mspaint pencil pressed.bmp" is macro where I saved image captured with the 'Find image' dialog:
Copy      Help

However will not run when the button is hidden.
Other way would be to find accessible object, but it is slow, ~150 ms on my PC. Also, i tested, it does not work if you want to use the code in a filter function. Finding image is ~30 ms, and can make faster if need.
sorry, i don't understand... Sad

My Macro is "Draw-15-Macro".

In Properties - Trigger - Keyboard - Hot-key = "Win+G"

How should I set this macro to work only when the "Pencil" button is pressed?

When other tool is selected hot-key "Win+G" shouldn't work.

Step by step please Smile
That code was more like an example. May not work on your PC because of possibly different conditions. Better create your code.

Let your macro, before doing its main work, check whether pencil button is pressed. How? Add code that finds pressed pencil button image on screen, and exits macro if not found. To capture the image and create code, use this dialog: QM floating toolbar -> Windows, controls -> Find image.

In the dialog: Select 'Bitmap macro', click Capture, select button image (drag to select), OK. Uncheck all checkboxes. Then capture the control with the Drag tool. OK.

The code should look like in my example. Here it again:
Copy      Help
int w=win
if(!w or !wintest(w "Paint" "MSPaintApp")) ret
if(!scan("macro:mspaint pencil pressed.bmp" child("" "NetUIHWND" w 0x1) 0 16 10)) ret

Forum Jump:

Users browsing this thread: 1 Guest(s)