Link under the mouse cursor

Started by hdsouza, June 15, 2019, 05:42:48 PM

Previous topic - Next topic

hdsouza

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

Please help.
Thanks

pguild

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

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

hdsouza

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.

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

hdsouza

Thanks Td. Yes this is a 100% consistent