We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

ძიება მხარდაჭერაში

ნუ გაებმებით თაღლითების მახეში მხარდაჭერის საიტზე. აქ არასდროს მოგთხოვენ სატელეფონო ნომერზე დარეკვას, შეტყობინების გამოგზავნას ან პირადი მონაცემების გაზიარებას. გთხოვთ, გვაცნობოთ რამე საეჭვოს შემჩნევისას „დარღვევაზე მოხსენების“ მეშვეობით.

ვრცლად

Simulate Alt-Key Down

  • 7 პასუხი
  • 1 მომხმარებელი წააწყდა მსგავს სიძნელეს
  • 9 ნახვა
  • ბოლოს გამოეხმაურა Yaron

I'd like to create a toolbar button simulating Alt down (in order to select links' text; - I'm aware of the various extensions addressing the issue).

Also, I'd like to have a toolbar button simulating Alt+Shift pressed (switching between the system languages).

I haven't been able to make it work with "document.createEvent("KeyboardEvent");".

I'd be grateful for your help.

I'd like to create a toolbar button simulating Alt down (in order to select links' text; - I'm aware of the various extensions addressing the issue). Also, I'd like to have a toolbar button simulating Alt+Shift pressed (switching between the system languages). I haven't been able to make it work with "document.createEvent("KeyboardEvent");". I'd be grateful for your help.

ჩასწორების თარიღი: , ავტორი: Yaron

ყველა პასუხი (7)

Can you explain better what it is you want to do please?

Hello FredMcD,

1) A button toggling the state of the Alt key: down - links are rendered as regular text; up- normal rendering of links.

2) A button enabling to switch between the the available system languages (English, French etc.).

Thank you.

ჩასწორების თარიღი: , ავტორი: Yaron

1) Link Toggler {web link} Want to copy a part of text but this text is a link? We'll help you! This addon toggles links on a web page. Simple run "Ctrl+Shift+L" (or Alt or Cmd instead of Ctrl, depends on your system settings) to toggle links on a page.


2) http://www.bing.com/search?q=toggle+language+computer


I hope these help you.

Firefox has limits on what synthetically generated keyboard events it will honor for web pages (including bookmarklets), so what you're proposing to do might not be possible in "unprivileged" code.

Are you using the CustomButtons extension, or creating a new extension, to try to work around those limits?

Thank you FredMcD and jscher2000. I appreciate your help.

Link Toggler is a good extension. Select like a Boss is also very good.

Still, I'd like to try simulating Alt down and up.

---

I've created an extension for my personal use, and I'd like to include the discussed button in it.

Best regards.

I'm not sure how you would like to activate this button. If you click this button then you only have this event in this button and not for a link on a web page. You would have to take over the action code in browser.js to make this work or at least invoke the command with event.altKey set.

Switching the keyboard layout is a OS action and I don't think that you can accomplish this in any way in Firefox. Any way it is usually not a good idea to have a shortcut that cycles through various layouts because you never know if you aren't activating such a switch if you invoke a shortcut in Firefox via a command that uses Alt+Shift. A direct shortcut to select each layout is better to avoid such an accidental switch.

Thank you cor-el. I appreciate your help too. :)

1) That's a good point, and hence my question. I haven't looked at the relevant code in browser.js. I should definitely do that.

2) I've been using the following code to switch between the system languages:

Components.utils.import("resource://gre/modules/ctypes.jsm"); let lib = ctypes.open("user32.dll"); let switchLanguage = lib.declare("ActivateKeyboardLayout", ctypes.winapi_abi, ctypes.voidptr_t, ctypes.voidptr_t, ctypes.uint32_t); switchLanguage(ctypes.voidptr_t(1), 0x00000100); lib.close();

It has a minor glitch: When returning from Sleep Mode (Win 7) the input language is changed but the language displayed in the task bar is frequently wrong. It happens with other apps as well (e.g. Word).

"ctypes" could be used for simulating Alt down and up as well. I don't know how to do that. I'd appreciate any further help.

Best regards.