Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a macro end on address bar change
#1
For work I have to always be clicking a fetch order button and I have it running on a macro to do it for me since sometimes I'm clicking for a long time. I was wondering if it is possible to have the macro end when the address bar changes? I'm on chrome if that matters. My plan is have it stop and play a sound when it ends. I got the sound part figured out, but can't figure out how to have it stop when the address changes.
#2
Yes it's possible to have the macro end when address bar changes
There are several ways
this is using an Accessible Object trigger
insert this line of code in main macro
Code:
Copy      Help
dis- "ChromeAddressBarChange"


Function ChromeAddressBarChange
Trigger $a 142 -4 "" "Chrome_WidgetWin_1" "" "" "" "" 42 0x100000 "Address and search bar"     Help - how to add the trigger to the macro
Code:
Copy      Help
;\
function hwnd idObject idChild
Acc a.FromEvent(hwnd idObject idChild)
out a.Value
bee
shutdown -6 0 "Macro name goes here"
dis+ "ChromeAddressBarChange"

this is using a function that repeatedly checks for the change in the  address bar
this should run in its own thread 
insert this line in main macro
Code:
Copy      Help
mac "WaitForAddressBarChange"
 

Function WaitForAddressBarChange
Code:
Copy      Help
int w=win("- Google Chrome" "Chrome_WidgetWin_1")
Acc a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
str originalValue=a.Value
spe -2
rep
,a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
,str newValue=a.Value
,if newValue!=originalValue
,,break
,0.3
bee
shutdown -6 0 "Macro name goes here"

there are other ways depends on code in main macro.
#3
ty for the response! been playing around with the codes you gave me and no luck
the macro I'm using is one I found on the forum which is:
rep
,lef X X 
,rep 10*1
,,0.1
,,
,,ifk A
,,,bee
,,,mes "my message here"
,,,end

i have it so that when I press the alt key it gives me a message reminding me to do a certain task
i want it so that if address bar changes it plays system sound and gives me the message. ty for the hel
#4
I just tested your code with both versions and they work for me on win10 in chrome and edge

try this
I have provided a way to give different messages depending on whether alt key pressed or address bar change
Code:
Copy      Help
int w=win("" "Chrome_WidgetWin_1")
Acc a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
str originalValue=a.Value
int action
rep
,a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
,str newValue=a.Value
,if newValue!=originalValue
,,action=1
,,break    
,lef X X
,rep 10*1
,,0.1
,,ifk A
,,,action=0
,,,break
bee
if action=1
,mes "my message here";;address bar changed message
else
,,mes "my message here";;alt key pressed message
#5
that worked great, but it only worked once, afterwards it wouldn't stop clicking. not even if I pressed alt
#6
hmm not having that problem please post your code

In QM, to copy all or selected text, use menu Edit -> Other Formats -> Copy for QM Forum. It copies correct and colored code to the clipboard. Then simply paste in the forum. Don't use the Code button.
#7
This is the code i copied
 Macro clicky
Trigger !n"Queue Review"     Help - how to add the trigger to the macro
Code:
Copy      Help
int w=win("" "Chrome_WidgetWin_1")
Acc a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
str originalValue=a.Value
int action
rep
,a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
,str newValue=a.Value
,if newValue!=originalValue
,,action-1
,,break
,lef 981 -632
,rep 10*1
,,0.1
,,ifk A
,,,action=0
,,,break
bee
if action=1
,mes "AUX INTO AVAILABLE"
else
,,mes "AUX INTO AVAILABLE"
#8
try this
Code:
Copy      Help
int w=win("" "Chrome_WidgetWin_1")
Acc a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
str originalValue=a.Value
int action
rep
,if action!=0
,,break
,lef 981 -632
,a.Find(w "TEXT" "Address and search bar" "class=Chrome_WidgetWin_1" 0x35)
,str newValue=a.Value
,if newValue!=originalValue
,,action=1
,,break    
,rep 10*1
,,0.1
,,ifk A
,,,action=2
,,,break
bee
if action=1
,mes "AUX INTO AVAILABLE";;address bar changed message
if action=2
,,mes "AUX INTO AVAILABLE";;alt key pressed message
#9
Thank you! I'll keep playing with it, but that new code doesn't stop it if the address bar changes.
#10
i tested it on many web pages and it worked every time for me..

with qm main window up press ALT+F12(or click tools/ then options)


Makes sure there is a check in Enable Chrome acc when it starts. If its not, put a check and click apply.
also make sure code is exactly the same i notice your copied code you showed had a mistake in it

code had action-1
should have been action=1
#11
Ok so it was an error on my part probably. When I pasted it I had to click fix paste error and now it works perfectly. Thank you so much you're a godsend.

Is there a specific place to learn this kind of stuff? its super cool
#12
best way to copy code from forum is to click copy then paste into qm editor. 
Happy to help. Glad its working now.

qm has a built in help file with tons of information. I still use it to this day
Also almost every qm command you can place the cursor on it and hit F1 to bring up help
Can also use the online help button at the top of the forum page it has the enitre qm help file.


Forum Jump:


Users browsing this thread: 1 Guest(s)