Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help for simple macro
#1
I am a beginner of QM and would like to receive help for a simple macro. I have a child window that contain differents big dots with different colors. I need a macro that checks the color of a dot and when it changes (example from green to red), after 2 seconds press automaticly the reset button in the same child window. I am aware that this is a simple macro, but I can not manage it. Thanks in advance for your reply.
#2
Hi.... some help for me?....i try several option but not able to find a solution. Maybe need OCR software or there is a solution for capture the screen change colour?.... appreciated any reply!
#3
Macro Macro31
Code:
Copy      Help
;1. Download the 'test_qm_bmp' file and open it in ms paint. A link in this post should be visible from which you can download the bmp file
;2. run this code, the QM icon in your systray should become purple/pink indicating it is running
;3. change the middle RED SQUARE to a GREEN square. This means fill it with the correct green color. (choose the green color from the ms pain pallet from top row, next to yellow)
;4. the moment you fill it with the CORRECT green color a messagebox will appear notifying you the correct green color has been detected
;5. AFTER you ran/tested this code, read the green comments below that explains what I have done to generate the code.
;;;;to have button-click as a last action, read STEP 5
;;-------------------------------------------------------


;; STEP 1
;; Make sure the example bmp is open in ms paint AND make sure it is active.
;; We check for the TITLE "test_qm_bmp - Paint" and WINDOW CLASS "MSPaintApp" to be open.
;; Note, a part of the title is used which will work so in
;; stead of "test_qm_bmp - Paint" , the following is used "test_qm_bmp"
;; To get the below code,
;; 1. open the 'test_qm_bmp.bmp' in paint
;; 2. above in the top right QM you see a toolbar with hand icon, keyboard icon, mouse icon....
;;    click the dotted circle icon (directly at the right of the mouse icon, if you hover over it you see a tootlip 'Wait')
;; 3. in the dialog window that appears in the left listbox you see 'Wait' , 'Wait for window active' , 'Wait for window created'....
;;;;;;click on 'Wait for window visble'
;; 4. You see a square purple/white 'Drag' icon, left click and hold then drag it ontop of the open ms paint window
;; 5. Press 'Ok'
;; 6. The code is generated, and can now be adjusted. I adjusted it as you see below:
;;;;;;- Modified '0' to '3' , which waits 3 seconds
;;;;;;- If the 3 second wait is over and the window is still not detected then
;;;;;;;;the error code below under 'err' is executed, which 'end' and the show the error text "The example bmp...."

int w=wait(3 WV win("test_qm_bmp" "MSPaintApp"))
err
,end "The example bmp file must be open in 'MS paint'"

;; STEP 2
;; At this point we know 'test_qm_bmp' is open in ms paint, we just activate the window
;; To generate this code,
;; 1. above in the toolbar next to the circled dots (which I explained earlier) you see blue/white window icon.
;;;;;;If you hover over it a tooltip appears 'Windows,controls', click that blue white window icon
;; 2. Select the second option, 'Window/control actions'
;; 3. In the leftside 'Activate or set focus' should be already selected (if not, then select it)
;; 4. You see a square purple/white 'Drag' icon, left click and hold then drag it ontop of the open ms paint window
;; 5. Press 'Ok'
;; I only changed the title (like I did earlier)

int w1=win("test_qm_bmp" "MSPaintApp")
act w1


;; STEP 3
;; To be sure we work from the exact same start point, we move and resize the window
;; to same position as what I was working from. The code below in STEP 4 uses coordinates if you worked
;; from an different start point (different ms paint window size and position the code would not work).
;; 1. To get the below code, in the same window as STEP 2 (click the blue/white window icon: 'Windows, controls')
;; 2. Delect the second option, 'Window/control actions'
;; 3. In the leftside selecte 'Move, resize'
;; 4. In the rightside somwhere in the middle you see 'Move' , 'Resize' and 'Move and resize', select: 'Move and resize'
;; 5. Go back to the ms paint window and place it anywhere you want and resize it to the size so that the WHOLE image is shown.
;; 6. Go back to the dialog where you clicked 'Move and resize' and left click and drag the purple/white drag icon over ms paint
;; 7. press 'Ok'


int w2=win("test_qm_bmp" "MSPaintApp")
mov+ 30 35 850 310 w2


;; STEP 4
;; Let's assume we are waiting for the middle (RED) square to become green.
;; The green color comes from the color pallet in ms paint, it is green color in TOP ROW (next to yellow).
;; This is very important because in order to get the below code (wait for green color) we first change the MIDDLE square
;; to a green color, just click the click the green color in windows paint (top row, next to yellow) and fill it with green
;; then do the following:
;; 1. above in the top right QM you see a toolbar , click the dotted circle button ('Wait' button, just like in STEP 1)
;; 2. In the leftside click 'Wait for color' (Make sure the window in which you want to do the wait for color action has the desired color)
;; 3. Click the 'Capture' button, your whole desktop changes a bit and the mouse becomes a cross-hair AND in the top-right you see magnified
;;;;;;area which shows you on where you are currently. Click on the middle square which should be green somewhere in the center of it (as long as you are hitting a green part)
;;;;;;and then left-click and select 'Ok' in the small pop-up menu that appears.
;; 4. Click ok
;; Below in the code it waits 150 seconds
;; change it to 0 to wait forever OR to another value to wait for that amount of seconds.
;; so for example if you cange 150 to 7 it will wait for 7 seconds.


int w3=win("test_qm_bmp" "MSPaintApp")
wait 150 C 0x4CB122 188 169 w3 1
err
,end "Could not detect green color in middle square"
,
,
;; STEP 5
;; 1. Above in the top right in the QM toolbar where you see hand/pen icon, keyboard icon,...
;;;;;;click the mouse icon
;; 2. On the leftside 'Left click' should be selected if not, then select it
;; 3. You can now do one of the followin

;;;;;;method 1
;;;;;;3a: click the round radio button 'Window'
;;;;;;3b: left click and drag the 'Drag' icon over the button/part you want to click on
;;;;;;3c: press 'ok'

;;;;;;method 2
;;;;;;3a: click the round radio button 'Control'
;;;;;;3b: left click and drag the 'Drag' icon over the button/part you want to click on
;;;;;;;;;;but now you a black square around the objects QM can detect and do actions on!
;;;;;;;;;;if you are lucky it can detect buttons and such and this method is preferred.
,,;;press 'ok'
;;;;;

;; Once you pressed 'ok' the code is generated below and it is the final action...


;; A messagebox to notfify you that the green color is detected
mes(F"Green color detected" F"SUCCESS" "i")

I hope this get's you started.


Attached Files Image(s)
   
#4
I can not find the best words to say.... thank you !
Now the operation begins to be clear to me.
You have a pint of beer paid in Italy!
Ciaooo !!!!
#5
Good to hear!
You might also want to take a look at:
https://www.youtube.com/watch?v=g8XSSa-GiVo
Go to the 8:30 time mark OR click below in the youtube video description on the blue link next to: 4. Capture color


Forum Jump:


Users browsing this thread: 1 Guest(s)