Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
monitor blank area of window for any change
#1
I need to create a macro that monitors a area (defined as x by y) on a program window that is running.  Area is blank (white) and I want to be notified when any line of text shows up in that area so that I can then click three buttons on that same page.  The recording of the buttons seems straightforward but thee monitoring of the area is what has me stumped.  Any suggestions or help>. Thank you very much for a great piece of software!
#2
To create code for it, use dialog "Find Image". In it select "Wait until something changes". Drag drop the "Drag" image to the window...
#3
I have found the FIND IMAGE ...Wait window and changed the option to Wait until something changes.  I am having a problem with the DRAG button.  I get the crosshair to define a corner but cannot get it to define anything.  If I let go of the mouse the Find Image box comes back and I never defined anything.  Can you maybe go into a little moree details on how to drag this area back into the window?  I am fully blink in one eye and vision in other is not the best so reading a lot of tutorial files online or watching videos is difficult.  Please be patient with me.
#4
In the dialog just capture a window or control and enter a name for a RECT variable. Click OK. It creates code like, this:
Macro Macro201
Code:
Copy      Help
RECT r
int w=win("Untitled - Notepad" "Notepad")
wait 0 -S "" w r 16
It also shows in the output pane how to set the variable. Combined code would be:
Macro Macro201
Code:
Copy      Help
RECT r
SetRect &r 50 50 100 100 ;;coordinates in the client area of the window
int w=win("Untitled - Notepad" "Notepad")
wait 0 -S "" w r 16
To define a rectangle area, edit the values in the SetRect line. They are coordinates of left, top, right and bottom. You can see mouse coordinates in the status bar of the Quick Macros window.
#5
Here is my generated code.  However I am not seeing the mouse coordinates in the QM Status Bar.  Not seeing the QM Status bar at all.  I've looked Tools and I see Status Bar and Mouse position is checked but there is no check mark in front of status bar to turn on/off like I would have expected.


RECT noqso
SetRect &noqso 50 50 100 100
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
wait 0 -S "" w noqso 16

status bar covereee by another window.  Back to get coordinates
#6
try putting a check in floating and see if the window shows then
Tools /status bar /floating
#7
Here is my macro:

RECT r
SetRect &r 1170 260 2160 510
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
wait 0 -S "" w r 16

#region Recorded 1/19/19 4:50:02 PM
int w1=act(win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon"))
lef 1139 26 w1 ;;title bar
lef 1044 992 w1 1 ;;push button 'Erase Alt+E'
lef 1748 990 w1 1 ;;push button 'Halt Tx Alt+H'
#endregion

I am attaching screenshot.  QM Floating toolbar is located just below the coordinate 1170  260.  When run, I expect that when the lines populate in the right window below  1170 260 that QM will run the recorded portion of Erasing the entire Right window followed by Halt button.  As you can see from the attached image there are multiple lines populating even below the QM toolbar which according to the 4 coordinates should be in the area watching for changes.  Can you see what might be the problem?  Thank you veery much!


Attached Files Image(s)
   
#8
To debug it, insert out 1 and out 2 above and below the wait line:

out 1 ;;note: at this time the area must be still blank
wait 0 -S "" w r 16 ;;during this waiting time the area should become non-blank
out 2 ;;now the area is non-blank

If the macro works as expected, it should print 1 and 2 in the output.
If it prints only 1, probably nothing changed in that area while the wait line is waiting.

I tested this macro with the screenshot in Firefox. The area initially is blank. When I run the macro, it prints 1. Then when I scroll the page, the text is scrolled into the area, and the macro prints 2.

Macro Macro247
Code:
Copy      Help
out
RECT r
SetRect &r 1600 260 1700 300
int w=win("monitor blank area of window for any change - Mozilla Firefox" "MozillaWindowClass")
out 1
wait 0 -S "" w r 16
out 2
#9
That macro works.  Problem was I had another macro running and I had to delete that macro first.  Is there a way to run. multiple macros (I had simultaneous running macros set on the first macro that I had to delete.  Or should I create this as a function and call from the macro I had to delete?

Second question:  duet to my eye sight issue I am having trouble finding the Tray where help file says I should see if macro is running.
#10
Gintaras:

This macro will work one time.  However, after the sccxreen is cleared on the right sided and the area I want to monitor is blank again, dit no longer will work.  It continues to let data lin es fill up the monitored area/. Any suggestions

RECT r
SetRect &r 2000 710 2500 900

int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")

wait 0 -S "" w r 16


#region Recorded 1/21/19 10:43:15 AM
int w1=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
lef 2926 1056 w1 1 ;;push button 'Halt Tx Alt+H'
lef 3652 1388 w1 1 ;;radio button
lef 1748 1060 w1 1 ;;push button 'Erase Alt+E'
lef 2456 1062 w1 1 ;;check box 'Enable Tx Alt+n'
#endregion
#11
your code is only setup to run one time then exit. If you want it to keep going need to add a repeat like so

Code:
Copy      Help
RECT r
SetRect &r 2000 710 2500 900
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
rep    
,wait 0 -S "" w r 16
,#region Recorded 1/21/19 10:43:15 AM
,int w1=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
,lef 2926 1056 w1 1 ;;push button 'Halt Tx Alt+H'
,lef 3652 1388 w1 1 ;;radio button
,lef 1748 1060 w1 1 ;;push button 'Erase Alt+E'
,lef 2456 1062 w1 1 ;;check box 'Enable Tx Alt+n'
,#endregion
#12
Somehow I am getting an error running this macro. Oudtpu box gives the following error:
Error in <open ":1: /179">BlankAreaCk:  empty block. Did you forget to tab-indent following lines?.
No lines were mentioned other than this error message
Can you see anything?


RECT r
SetRect &r 2000 326 3500 500

int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
out 1
wait 0 -S "" w r 16
out 2
rep


#region Recorded 1/21/19 10:43:15 AM
int w1=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
lef 2926 1056 w1 1 ;;push button 'Halt Tx Alt+H'
lef 3652 1388 w1 1 ;;radio button
lef 1748 1060 w1 1 ;;push button 'Erase Alt+E'
lef 2456 1062 w1 1 ;;check box 'Enable Tx Alt+n'
#endregion
#13
you didn't copy code correctly

read here on how to copy code to and from qm forum

http://www.quickmacros.com/forum/showthread.php?tid=786

also your code can be greatly improved to not rely on mouse clicks .. The problem with mouse clicks and using x any y coordinates is if you change window size or screen resolution they won't work..


here is an improved version

Code:
Copy      Help
RECT r
SetRect &r 2000 710 2500 900
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
Acc a
rep    
,wait 0 -S "" w r 16
,a.Find(w "PUSHBUTTON" "Halt Tx Alt+H" "" 0x31)
,a.DoDefaultAction
,lef 3652 1388 w 1 ;;radio button    
,a.Find(w "PUSHBUTTON" "Erase Alt+E" "" 0x1)
,a.DoDefaultAction
,a.Find(w "CHECKBUTTON" "Enable Tx Alt+n" "" 0x1001)    
,a.DoDefaultAction


can be improved further

what are you clicking in this line lef 3652 1388 w 1 ;;radio button

if you let me know what it is i can probably find a better way that doesn't use the mouse and coordinates
#14
Code:
Copy      Help
RECT r
SetRect &r 2000 326 3500 500

int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
out 1
wait 0 -S "" w r 16
out 2
rep


#region Recorded 1/21/19 10:43:15 AM
int w1=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
lef 2926 1056 w1 1 ;;push button 'Halt Tx Alt+H'
lef 3652 1388 w1 1 ;;radio button
lef 1748 1060 w1 1 ;;push button 'Erase Alt+E'
lef 2456 1062 w1 1 ;;check box 'Enable Tx Alt+n'
#endregion

Kevin, Hopefully this is the correct way to insert code
#15
to copy code from qm to the forum

click macro name on left side of qm window that has code you want to share
   
 In QM, to copy all or selected text, use menu Edit -> Other Formats -> Copy for QM Forum

   
#16
Code:
Copy      Help
Macro [b]BlankAreaCk[/b] [help1][/help1]
[code]RECT r
SetRect &r 2000 326 3500 500

int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
out 1
wait 0 -S "" w r 16
out 2
rep


#region Recorded 1/21/19 10:43:15 AM
int w1=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
lef 2926 1056 w1 1 ;;push button 'Halt Tx Alt+H'
lef 3652 1388 w1 1 ;;radio button
lef 1748 1060 w1 1 ;;push button 'Erase Alt+E'
lef 2456 1062 w1 1 ;;check box 'Enable Tx Alt+n'
#endregion

Kevin: Thank you for being so patient with me. If this is not what you want then I will need your instructions on uploading to forum[/code]
#17
you changed the code sample i provided

when you use a rep in qm code all lines that you want to repeat must be tabbed 

see picture

   



even if you had the code tabbed after the rep line all it would do would just click the buttons


 code should look like this

if you want it to keep scanning for a change then click buttons
Code:
Copy      Help
RECT r
SetRect &r 2000 710 2500 900
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
rep
,wait 0 -S "" w r 16
,#region Recorded 1/21/19 10:43:15 AM
,lef 2926 1056 w 1 ;;push button 'Halt Tx Alt+H'
,lef 3652 1388 w 1 ;;radio button
,lef 1748 1060 w 1 ;;push button 'Erase Alt+E'
,lef 2456 1062 w 1 ;;check box 'Enable Tx Alt+n'
,#endregion
,1
#18
[img]blob:http://www.quickmacros.com/eceb6552-43df-4f28-a103-a09687eb3b34[/img]

Kevin:  Here is the window that I am trying to monitor for ham radio transmission automation monitoring.  I have a macro built that makes a ham contact and logs it to my logging program and repeats the calling for a new ham contact.  All works well until someone returns my contact but does not supply the full information that is required for a complete verifiable ham contact.  In this case the right side of the screen (all ;lines in yellow) keeps repeating the exact same line over and over and over again without ever cancelling the contact and starting initiation of my macro. I thought that if I defined an area ind the bottom of the right side where the white area is and if anything changes in thaat area....any colored linen matter what is there.... will then run a recording to press the HALT DTX button, Erase button dot clear eevverything on the right side, press the CQ W4EIS EM13 lineOR the radio button in the next columm and finally the ENABLE TX button to start the transmission all over again.  Right now the defined area to monitor for any change is LARGER that the white area showing in this screen shot is not working.
I will inclue a copy of each of three macros.

BlankAreaCk macro 
Code:
Copy      Help
Macro [b]BlankAreaCk[/b] [help1][/help1]
[code]RECT r
SetRect &r 2000 710 2500 900
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
rep
,wait 0 -S "" w r 16
,#region Recorded 1/21/19 10:43:15 AM
,lef 2926 1056 w 1 ;;push button 'Halt Tx Alt+H'
,lef 3652 1388 w 1 ;;radio button
,lef 1748 1060 w 1 ;;push button 'Erase Alt+E'
,lef 2456 1062 w 1 ;;check box 'Enable Tx Alt+n'
,#endregion
,1
[/code]


WSJX Macro - this works logging contacts and restarting until returning station does not reply
Code:
Copy      Help
Macro [b]WSJTX[/b] [help1][/help1]
Trigger [b]$a 130 0 "" "Qt5QWindowIcon" "" "WSJT-X   v2.0.0   by K1JT - Log QSO"[/b] [help2][/help2]
[code];\
;\
function hwnd idObject idChild
;Acc a.FromEvent(hwnd idObject idChild)
;out a.Name

#region Recorded 1/22/19 7:03:07 PM
int w1=win("WSJT-X   v2.0.0   by K1JT - Log QSO" "Qt5QWindowIcon")
lef 238 17 w1 ;;title bar
lef 335 401 w1 1 ;;dialog 'WSJT-X   v2.0.0   by K1JT -...'
int w2=act(win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon"))
lef 1750 1068 w2 1 ;;push button 'Erase Alt+E'
lef 3652 1390 w2 1 ;;radio button
lef 2558 1072 w2 1 ;;check box 'Enable Tx Alt+n'
#endregion
[/code]

START macro that combines the two macros
Code:
Copy      Help
Macro [b]Start[/b] [help1][/help1]
[code]mac BlankAreaCk
mac WSJTX
[/code]
  I am open to any help or better way of accomplishing the desired result

Here is an attachment that may not have shown in prior message


Attached Files
.docx   WSJTX screen.docx (Size: 448.54 KB / Downloads: 252)
#19
ok i installed that program  for testing. i am not a ham nor could i hook it up to a radio.

this macro locates the text area on the right side of the window and then creates a rectangle of that area minus the scrollbars and then monitors it  for any change. 

displays a brief green rectangle at the start  that shows the rectangular area the macro is monitoring.

to copy this code click the select all button .then right click the selected code and click copy
then in qm find BlankAreaCk macro select all the code inside and then paste

Try this 

Macro BlankAreaCk
Code:
Copy      Help
int w=wait(30 WV win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon"))
Acc a.Find(w "TEXT" "" "state=0x100040 0x20000040" 0x4 30)
int x y width height
a.Location(x y width height)
RECT r r1 rd rl;
r1.left=x
r1.top=y+10
r1.right=x+width-20
r1.bottom=y+height-20
r=r1
DpiScreenToClient w +&r 0x100
SetRect &rd r.left r.top r.right r.bottom
sub.DebugShowRectangle rd w 1
rep
,rl=rd
,out 1
,wait 0 -S "" w rl 16
,out 2
,a.Find(w "PUSHBUTTON" "Halt Tx Alt+H" "" 0x31)
,a.DoDefaultAction
,out 3
,0.3
,;lef 3652 1388 w 1 ;;radio button    
,a.Find(w "PUSHBUTTON" "Erase Alt+E" "" 0x1)
,a.DoDefaultAction
,out 4
,5
,a.Find(w "CHECKBUTTON" "Enable Tx Alt+n" "" 0x1001)    
,a.Mouse(1)
,out 5
#sub DebugShowRectangle
function RECT'r hwnd [double'timeS] [flags] ;;flags: 1 not client area

;Shows a rectangle relative to a window or control.
;By default, relative to the client area.

;r - rectangle.
;hwnd - window/control handle.
;timeS - time in seconds. Default 2.


if hwnd
,if(flags&1) RECT k; GetWindowRect hwnd &k; OffsetRect &r k.left k.top
,else MapWindowPoints hwnd 0 +&r 2

__OnScreenRect osr.SetStyle(0x8000 1)
osr.Show(1 r)
wait iif(timeS timeS 2.0)
osr.Show(2 r)
#20
When I ran the macro there were no errors but it worked tooo well. Immediately after posting the first line where I was calling out for a contzct it cleared the screen and started over. The blank area to monitor needs to be in the bottom 20% or so of the bottom of the right side. Do you have a PayPal Acct Kevin?
#21
"The blank area to monitor needs to be in the bottom 20% or so of the bottom of the right side."

easy fix use updated macro below




Macro BlankAreaCk
Code:
Copy      Help
int w=wait(30 WV win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon"))
Acc a.Find(w "TEXT" "" "state=0x100040 0x20000040" 0x4 30)
int x y width height
a.Location(x y width height)
RECT r r1 rd rl;
r1.left=x
r1.top=y+(height*0.70)
r1.right=x+width-20
r1.bottom=y+height-20
r=r1
DpiScreenToClient w +&r 0x100
SetRect &rd r.left r.top r.right r.bottom
sub.DebugShowRectangle rd w 1
rep
,rl=rd
,out 1
,wait 0 -S "" w rl 16
,out 2
,a.Find(w "PUSHBUTTON" "Halt Tx Alt+H" "" 0x31)
,a.DoDefaultAction
,out 3
,0.3
,;lef 3652 1388 w 1 ;;radio button    
,a.Find(w "PUSHBUTTON" "Erase Alt+E" "" 0x1)
,a.DoDefaultAction
,out 4
,5
,a.Find(w "CHECKBUTTON" "Enable Tx Alt+n" "" 0x1001)    
,a.Mouse(1)
,out 5
#sub DebugShowRectangle
function RECT'r hwnd [double'timeS] [flags] ;;flags: 1 not client area

;Shows a rectangle relative to a window or control.
;By default, relative to the client area.

;r - rectangle.
;hwnd - window/control handle.
;timeS - time in seconds. Default 2.


if hwnd
,if(flags&1) RECT k; GetWindowRect hwnd &k; OffsetRect &r k.left k.top
,else MapWindowPoints hwnd 0 +&r 2

__OnScreenRect osr.SetStyle(0x8000 1)
osr.Show(1 r)
wait iif(timeS timeS 2.0)
osr.Show(2 r)
#22
Kevin

New code shows only 2 lines before erasing and resetting.  Are you measuring depth on the right side window by number of lines or by a Percentage of the box from top?  I have lost sight om one eye but if you want to tell me what/wherfre in the code to change I might be able too adjust?
#23
Kevin:

Here is the output log

3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
<fa "4298123 /5569924 0 1222 -1618455466">Click here to correct the pasted code
5
1
Error in <open ":1574: /4">Start:  unknown identifier.
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
<fa "4298123 /5569924 0 1222 -1618455466">Click here to correct the pasted code
2
3
4
5
1
Cannot start macro <open ":1579:">KevinBl;ankAreaCk while a macro is running. You may want to <fa "4467104 /1579">change 'If a macro is running' option or convert to function.
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
Error (RT) in <open ":1: /162">BlankAreaCk:  the point is not in the window.    <help #IDP_ERR>?
#24
a few things to note while using this. You cannot change the window size once it starts. you cannot obscure the window either. When the macro starts it shows green rectangle that shows the area its monitoring. 
 see pic below

   

i tested macro on my end it only stops the transmission once text hits that area. so not sure what is going on
#25
Recopied/[asted and macro appears to be working now.  
There is still one problem with making this fully automatic.  Occasionally two people come back to me at one time and apparently turn off the ENABLE TX button.  
Don't think this is a QM problem but could you write a macro to watch the Enable TX button and if off for 15sec./....turn it back on

Thank you!

Lee Clayton

[img]blob:http://www.quickmacros.com/0817e39b-1202-49ee-9f2d-99aec2af2ea5[/img]

Here is a screenshot showing the entire right side of the screen completely full.  This should not have happened as I was running the new BlankAreaCk macro.
#26
after some thought and a good look again at that program i came up with a much better way than using scan at all

try this also handles problem of enable tx button becoming unchecked for any reason

Macro BlankAreaCk2
Code:
Copy      Help
int w=win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon")
int c xy checked mx my mw mh
Acc a b 
a.Find(w "TEXT" "" "" 0x0)
rep
,b.Find(w "CHECKBUTTON" "Enable Tx Alt+n" "" 0x1001)    
,checked=b.State&STATE_SYSTEM_CHECKED
,if !checked
,,b.Location(mx my mw mh)
,,c=child(b)
,,ScreenToClient c +&mx
,,mx+mw/2; my+mh/2 ;;center
,,xy=(mx&0xffff)|(my<<16)
,,SendMessage(c WM_LBUTTONDOWN 1 xy)
,,SendMessage(c WM_LBUTTONUP 0 xy)    
,str lines=a.Value
,if numlines(lines) >5
,,out lines
,,out "stop"
,,b.Find(w "PUSHBUTTON" "Halt Tx Alt+H" "" 0x31)
,,b.DoDefaultAction
,,0.3
,,b.Find(w "PUSHBUTTON" "Erase Alt+E" "" 0x1)
,,b.DoDefaultAction
,1
 no mouse commands no screen coordinates
#27
incase you have trouble copying it


.qml   BlankAreaCk2New.qml (Size: 3 KB / Downloads: 252)
#28
KEVIN:  Your updated code,  when run BY ITSELF,  will clear the right window when the 9th line of text is displayed.  There are a possible 31 lines on the window so it is "rebooting" after top 29% is populated instead of allowing it to go to the BOTTOM 20-25% before rebooting window.  However, when I add in another macro that actually logs the contact then it stops rebooting the right window all together.  Do the two macros need to be built into one?  Also, when the WSJTX macro runs and a contacc is logged there is a small box that pops up with contact information that does cover part of the right window temporarily.  This is a WSJTX program window.  Now for the two macros for you to inspect for the problem.

WSJTX macro:
Code:
Copy      Help
Macro [b]WSJTX[/b] [help1][/help1]
Trigger [b]$a 130 0 "" "Qt5QWindowIcon" "" "WSJT-X   v2.0.0   by K1JT - Log QSO"[/b] [help2][/help2]
[code];\
;\
function hwnd idObject idChild
;Acc a.FromEvent(hwnd idObject idChild)
;out a.Name

#region Recorded 1/22/19 7:03:07 PM
int w1=win("WSJT-X   v2.0.0   by K1JT - Log QSO" "Qt5QWindowIcon")
lef 238 17 w1 ;;title bar
lef 335 401 w1 1 ;;dialog 'WSJT-X   v2.0.0   by K1JT -...'
int w2=act(win("WSJT-X   v2.0.0   by K1JT" "Qt5QWindowIcon"))
lef 1750 1068 w2 1 ;;push button 'Erase Alt+E'
lef 3652 1390 w2 1 ;;radio button
lef 2558 1072 w2 1 ;;check box 'Enable Tx Alt+n'
#endregion

Now what I call the START macro that does both:
Macro will not insert here but it is only two lines:

mac KevinBlankAreaCk2
mac WSJTX

[/code]
#29
Kevin:

I see the line "if numlines(lines) >8".  and I can increase line number myself.  Will leave it at 8 for now for testing purposes.  If you can help me incorporate the two macros into one I think the solution will be found!@!!!!!
#30
probably the new code fails because when added to you other macro is because the new macro is not setup to run simultaneously. Easy enough to fix.  NOt sure why your initial macro is setup with a trigger.
we can surely combine it as it looks like your main macro just does a couple things then runs the main program..


from what i can tell you starter macro  clicks ok? on the log window
then
erase
then click radion next to Tx6 button?
then clicks 
Enable Tx  button


Forum Jump:


Users browsing this thread: 1 Guest(s)