Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing the new tab with changing header in Chrome
#1
Dear All, 

I'm trying to make a macro which will clicks the link in the red box from https://hk.yahoo.com/
I wish to open that link to a new tab and then close it and repeat the process.

However, every time the link is clicked , the new tab has a different header.

How could I modify the code so that it opens and close that tab regardless of what header it has??

The middle two lines of code is where i hope it would disregard the header and close the tab:


lef 327 2 w1 1 ;;text '日均家務13小時 近8...'
wait 30 WT w1 "日均家務13小時 近8成受訪母親年中無休 - 雅虎香港新聞 - Google Chrome"

Sorry if this is such a noob question...I am a noob Confused



Code:
Copy      Help
#region Recorded 13/5/2018 22:06:11
int w1=act(win("Yahoo雅虎香港 - Google Chrome" "Chrome_WidgetWin_1"))
lef 125 3 w1 1 ;;text 'Yahoo雅虎香港'
rig 441 236 w1 1 ;;Chrome_RenderWidgetHostHWND 'Chrome Legacy Window'
lef 13 9 wait(18 WV win("" "Chrome_WidgetWin_2")) 1 ;;menu item 'Open link in new tab'



lef 327 2 w1 1 ;;text '日均家務13小時 近8...'
wait 30 WT w1 "日均家務13小時 近8成受訪母親年中無休 - 雅虎香港新聞 - Google Chrome"


lef 383 18 w1 1 ;;push button 'Close'
wait 30 WT w1 "Yahoo雅虎香港 - Google Chrome"
lef 74 309 w1 1 ;;document
#endregion
#2
Try this. Waits until window name changed. Not tested.

Macro Macro2947
Code:
Copy      Help
str oldName.getwintext(w1)
wait 30 -WT w1 oldName
#3
Thank you for your reply Gintaras but I am not sure how to use the code u gave me.
Do I just replace it with the two lines? That don't seem to work Sad
#4
replace
wait 30 WT w1 "日均家務13小時 近8成受訪母親年中無休 - 雅虎香港新聞 - Google Chrome"
#5
Hey really big thanks to you, it worked!!!! Smile

Is there a way to let the new tab wait for like 10 seconds before closing it??


Forum Jump:


Users browsing this thread: 1 Guest(s)