3

I am trying to make a macro that will cycle through and update browser tabs when hitting 'F10'. Currently it only updates the page I'm currently on, it doesn't cycle through them, I tried googling for it but all the answers were for 'AutoHotKey'. So I looked at the documentation for 'AutoKey' and tried to convert a 'AutoHotKey' script to 'AutoKey' (python) but it doesn't work and I have no idea why.

Here's the script

keyboard.send_keys("< f5>")

keyboard.press_key("< ctrl>")

keyboard.send_keys("< tab>")

keyboard.release_key("< ctrl>")

replacing lines 2 -> 4 with just a "keyboard.press_key("< ctrl>" + "< tab>") doesn't work (I'm not quite sure if it's ("< ctrl> + < tab>") instead, but none works, sadly)

(Please bare in mind that the spaces in front of the "keycodes" are so that Stackoverflow will show them)

Thank you all in advance!!!

v_johan
  • 462
  • 3
  • 16

2 Answers2

4

I asked in the Google group of AutoKey and they came up with this:

keyboard.send_keys("<f5><ctrl>+<tab>")

And that's all you need, it works flawlessly. I would later change the 'f5' to 'enter' instead and it never skips any browser tab, it's awesome!

Thank you all for your time!

v_johan
  • 462
  • 3
  • 16
1

It strangely worked only the other way around for me, but I think that might still suite your task:

keyboard.press_key("<ctrl>")
keyboard.press_key("<tab>")
time.sleep(0.3)
keyboard.release_key("<ctrl>")
keyboard.release_key("<tab>")
keyboard.send_key("<f5>")

I hope this helps.