Jump to content

Clicking a button in context menu of Firefox


Recommended Posts

Hey. I've made a script that right-clicks on hotkey press, then selects a button in context menu by sending {DOWN} five times, then presses it with {ENTER}. However, I got a very persistent and extremely annoying issue when sometimes Send("{DOWN}") misses the context menu somehow and scrolls the page instead, even though the menu had opened and there's no reason for that to happen. I've tried to increase Sleep timer between actions to the point when it's obviously that the delay there is irrelevant. I've been bashing my head for half a day and I still can't figure out why does it happen. It fails about 3 times out of 10.

I figure my best option here would be making my script recognize the context menu, find the button there and click it, and it appears to be possible to do with AutoIt, but I have completely failed to achive my goal. Firefox is displaying the page header in its window title, so I don't even know how to take control over its window without chaging the script accordingly everytime.

I believe that is actually something extremely easy to do and I'm just too dumb to figure out how. Would somebody be so kind to give me a direction in which I should be working here?

Link to comment
Share on other sites

So basically, that part of my script looks like this:

MouseClick("right")

Sleep(500)

$i = 0

Do

Send("{DOWN}")

Sleep(100)

$i += 1

Until $i = 6

Sleep(250)

Send("{ENTER}")

And I do not understand these two things:

1) How to get control of Firefox window if its title is dynamic?

2) What would be the easiest way of recognizing the context menu and pressing a button in it?

Edited by twinxz
Link to comment
Share on other sites

Get main Firefox window handle:

Maybe give this keyconfig.xpi plugin I use a try. It allows you to bind every standard command to a key, those should be more easily and reliably to be automated (just try to send them to the Firefox main window handle).

Edited by KaFu
Link to comment
Share on other sites

Or you could have a look at the Firefox UDF in the Example Scripts forum. It lets you automate Firefox reliably.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...