Jump to content

WinActivate Firefox.exe and Change Tabs


Recommended Posts

Hello! 🤗

First off, I gotta say Im very new to AutoIt and scripting.
Im writing a script for switching tabs in Firefox, but firefox.exe wont work.

ShellExecute("firefox.exe", "google.com")
ShellExecute("firefox.exe", "youtube.com")
Sleep(5000)
WinActivate("firefox.exe")
Sleep(1000)
Send("^{Tab}")

When I run the script the first 2 lines are running fine (but I think its because Firefox is my default Browser)
But WinActivate wont work, so I tried "WinKill" and "Run("firefox.exe")", both didnt really work.
Run is working with the whole path tho, but WinKill and WinActivate wont work.
I would be very happy if someone can correct my code.
Btw my english isnt the best ^^
Thank You!

Link to comment
Share on other sites

Two windows can’t be active at the same time.

If you need to cycle thru multiple windows and hit Tab, you should look ControlSend() which lets you specify the window to interact with. And as @Danp2 pointed out you need to use the title of the window to activate, not the name of the executable.

Code hard, but don’t hard code...

Link to comment
Share on other sites

On 6/2/2021 at 3:53 PM, Danp2 said:

Try removing the ".exe" at the end.

I tried it again with "WinActivate("firefox")" and "WinKill"
It didnt work, any idea why?

Edit:
Instead of WinKill im using

Send("!{F4}")
Send("{Enter}")

at the moment, but I need the WinActiate function, because when I auto open a Website it sometimes wont auto focus the browser (it strangely depends which website)

Edited by Merlini
Link to comment
Share on other sites

On 6/3/2021 at 5:51 AM, JockoDundee said:

If you need to cycle thru multiple windows and hit Tab, you should look ControlSend() which lets you specify the window to interact with.

I used this, and it works fine for my purposes:
But thank you anyways :D

While $i<=5

        Send("{CTRLDOWN}")
        Send("{tab}")
        Send("{tab}")
        Send("{CTRLUP}")
            Sleep(30000)

            $i=$i+1
        WEnd

 

Edited by Merlini
Link to comment
Share on other sites

On 6/2/2021 at 3:53 PM, Danp2 said:

Try removing the ".exe" at the end.

Hello Again,
I kinda did it, when I use the name of the tab, for example WinKill("YouTube") instead of firefox.
But is there anyway to kill all the Windows with WinKill or is there anyway to focus the opened tab
for example (see picture) I want to focus Google when I run the script, but when I selected Wikipedia, then it should focus on Wikipedia when I run it again.
But I dont want to use the site name like "Wikipedia - 1945", it should just auto focus on the tab which was opened last

2021-06-04 08_27_38-Window.png

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...