WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: hdsouza on June 15, 2019, 05:42:48 PM

Title: Link under the mouse cursor
Post by: hdsouza on June 15, 2019, 05:42:48 PM
I need to extract the weblink under the mouse cursor.

I looked at getting the name under the mouse cursor with this, although instead of the window name I need the weblink.
Code (winbatch) Select

:Start
buttons = MouseInfo(0)
If buttons != 0
        Display(1, "testing", buttons)
endif   
If IsKeyDown(@ctrl) then goto stop
goto start
:stop
exit


and https://forum.winbatch.com/index.php?topic=1596.msg7743 (https://forum.winbatch.com/index.php?topic=1596.msg7743)

Please help.
Thanks
Title: Re: Link under the mouse cursor
Post by: pguild on June 15, 2019, 10:44:12 PM
There is probably a better way, but here's one way, I don't like it though.
To get link under cursor,
press Shift.  The system then does a right-click for you and
presses the down arrow 5 times, followed by pressing ENTER.

When you hear a beep, the link is on the Windows Clipboard
and you can paste it wherever you like.  You could also use clipget to
get the link into a variable.

I don't know why, but MouseInfo seems to be needed for this to work.  ::)

:Start
windowontop("",1)
WHILE @TRUE
If MouseInfo(0) != 0
    Display(1, "testing", MouseInfo(0))
endif   
If IsKeyDown(@SHIFT)
   clicktype = @RCLICK
   mouseclick(clicktype, 0)
   sendkey("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}~",.1)
   beep
endif
If IsKeyDown(@CTRL) then break
ENDWHILE
RETURN

Title: Re: Link under the mouse cursor
Post by: hdsouza on June 16, 2019, 08:07:19 AM
Thanks pguild for the code.
Works great for the most part, although infrequently it behaves erratically and then click the wrong dropdown

Not sure if  anyone has another solution.
Title: Re: Link under the mouse cursor
Post by: td on June 16, 2019, 08:51:13 AM
Not exactly what you are looking for but this works consistently with Firefox:
Code (winbatch) Select
while 1
   If StrIndex(MouseInfo(0), 'Mozilla Firefox', 1, @Fwdscan)
      If IsKeyDown(@SHIFT)
         mouseclick(@RCLICK, 0)
         SendKeysTo('~Mozilla Firefox','a',.1)
      endif
   endif
   if IsKeyDown(@CTRL) then break
   TimeDelay(.01)
endwhile


It might give you some ideas.
Title: Re: Link under the mouse cursor
Post by: hdsouza on June 16, 2019, 09:18:04 AM
Thanks Td. Yes this is a 100% consistent