like ctrl+a opens the second tab etc
also is it possible to write a script that opens a tab or web page based on a sequence i.e. ctrl+a then press "g"
huge thank you, not sure if AHK is appropriate for this.
is it possible to write a script that opens specific chrome or firefox tabs Topic is solved
- Brazolek123
- Posts: 187
- Joined: 06 Jun 2016, 16:02
Re: is it possible to write a script that opens specific chrome or firefox tabs
Well, if you know title of the tab you want to open you can just use https://autohotkey.com/docs/commands/WinActivate.htm (each opened tab has a different title in Chrome, not sure if other browsers works the same way). You also can open a website using command https://autohotkey.com/docs/commands/Run.htm, even when there is no web browser turned on.
You can also send key or combination of keys directly to desired window using https://autohotkey.com/docs/commands/ControlSend.htm.
Using 'Active window info' tool to obtain window title or class also might be helpful in your case.
You can also send key or combination of keys directly to desired window using https://autohotkey.com/docs/commands/ControlSend.htm.
Using 'Active window info' tool to obtain window title or class also might be helpful in your case.
Re: is it possible to write a script that opens specific chrome or firefox tabs
turns i don't need a sequence of keys anymore..my main priority is to be able to open many different tabs...with ctrl+a ctrl+g etc...
someone on reddit suggested this:
#SingleInstance, Force
#IfWinActive, ahk_exe chrome.exe
^a::Send, ^2
works great until I try a larger numbered tab, like say 11...takes me to tab 1
i'm looking into winactivate now. thank you
someone on reddit suggested this:
#SingleInstance, Force
#IfWinActive, ahk_exe chrome.exe
^a::Send, ^2
works great until I try a larger numbered tab, like say 11...takes me to tab 1
i'm looking into winactivate now. thank you
Re: is it possible to write a script that opens specific chrome or firefox tabs
I already know the titles to the exact tabs I would like to open
Is there an example somehwere of how to use Winactivate with chrome?
Is there an example somehwere of how to use Winactivate with chrome?
- Brazolek123
- Posts: 187
- Joined: 06 Jun 2016, 16:02
Re: is it possible to write a script that opens specific chrome or firefox tabs
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
title = is it possible to write a script that opens specific chrome or firefox tabs - AutoHotkey Community - Google Chrome
f1::
WinActivate, %title%
return
f12::
ExitApp
-
- Posts: 8
- Joined: 04 Jan 2017, 18:56
Re: is it possible to write a script that opens specific chrome or firefox tabs
hello,
I pasted the above script exactly, without changing an line...leaving this tab open and it did not work
Am I missing something obvious? Using w7, if that makes any difference
I pasted the above script exactly, without changing an line...leaving this tab open and it did not work
Am I missing something obvious? Using w7, if that makes any difference
-
- Posts: 8
- Joined: 04 Jan 2017, 18:56
Re: is it possible to write a script that opens specific chrome or firefox tabs
nevermind, it's not possible to do this in different chrome tabs, just windows?
-
- Posts: 8
- Joined: 04 Jan 2017, 18:56
Re: is it possible to write a script that opens specific chrome or firefox tabs
im looking into using PIDs for tabs now
-
- Posts: 8
- Joined: 04 Jan 2017, 18:56
Re: is it possible to write a script that opens specific chrome or firefox tabs
WinActivate, ahk_id %VarContainingID%
this works but not with chrome tabs, which is weird because in task manager each tab has it's own PID
this works but not with chrome tabs, which is weird because in task manager each tab has it's own PID
Re: is it possible to write a script that opens specific chrome or firefox tabs
Each tab runs in its own (windowless) process, but they are displayed by a single parent process. So you can't activate a tab by activating the process.
Using browser's native hotkeys, Ctrl+1-8 activate tab 1-8 and Ctrl+9 activates the last tab. If you want to activate one beyond those, you're stuck with activating the one closest to it (either 8 or the last) and using Ctrl+Tab multiple times to move one tab forward or Ctrl+Shift+Tab to move back. If you know the number of the tab you just send the correct amount of presses. If you don't, you Loop %MaxTabs% it Until WinActive("tab title").
A more elaborate way would be to use ACC to actually read the tab name without activating them and clicking the right one, but that's more difficult and probably doesn't work well once you have so many the tab bar is scrollable.
Also, please edit your post with updates if your the last and recent poster instead of quadruple posting
Using browser's native hotkeys, Ctrl+1-8 activate tab 1-8 and Ctrl+9 activates the last tab. If you want to activate one beyond those, you're stuck with activating the one closest to it (either 8 or the last) and using Ctrl+Tab multiple times to move one tab forward or Ctrl+Shift+Tab to move back. If you know the number of the tab you just send the correct amount of presses. If you don't, you Loop %MaxTabs% it Until WinActive("tab title").
A more elaborate way would be to use ACC to actually read the tab name without activating them and clicking the right one, but that's more difficult and probably doesn't work well once you have so many the tab bar is scrollable.
Also, please edit your post with updates if your the last and recent poster instead of quadruple posting
-
- Posts: 8
- Joined: 04 Jan 2017, 18:56
Re: is it possible to write a script that opens specific chrome or firefox tabs Topic is solved
thanks, sorry. I'm a bit stressed out. lol.
So I was thinking a "cheat" I could do is have the tabs preloaded in firefox and chrome, that would give me 18 tabs...IE, if I'm desparate
I wrote this which works..need to remember 9 isn't the 9th tab, just the LAST tab.
sorry, a bit braindead right now. I'm not a programmer obviously.
#SingleInstance, Force
#IfWinActive, ahk_exe chrome.exe
^a::Send, ^1
^b::Send, ^2
^c::Send, ^3
^d::Send, ^4
^e::Send, ^5
^f::Send, ^6
^g::Send, ^7
^h::Send, ^8
^i::Send, ^9
#IfWinActive, ahk_exe firefox.exe
^j::Send, ^1
^k::Send, ^2
^l::Send, ^3
^m::Send, ^4
^n::Send, ^5
^o::Send, ^6
^p::Send, ^7
^q::Send, ^8
^r::Send, ^9
UPDATE
^^^^^^^^^^^^^
inspired my solution. im making multiple chrome profiles, ctrl+shift+m to toggle profiles then ctrl+1..ctrl+2 etc. not using ahk unless i feel like switching to ctrl+a etc
So I was thinking a "cheat" I could do is have the tabs preloaded in firefox and chrome, that would give me 18 tabs...IE, if I'm desparate
I wrote this which works..need to remember 9 isn't the 9th tab, just the LAST tab.
sorry, a bit braindead right now. I'm not a programmer obviously.
#SingleInstance, Force
#IfWinActive, ahk_exe chrome.exe
^a::Send, ^1
^b::Send, ^2
^c::Send, ^3
^d::Send, ^4
^e::Send, ^5
^f::Send, ^6
^g::Send, ^7
^h::Send, ^8
^i::Send, ^9
#IfWinActive, ahk_exe firefox.exe
^j::Send, ^1
^k::Send, ^2
^l::Send, ^3
^m::Send, ^4
^n::Send, ^5
^o::Send, ^6
^p::Send, ^7
^q::Send, ^8
^r::Send, ^9
UPDATE
^^^^^^^^^^^^^
inspired my solution. im making multiple chrome profiles, ctrl+shift+m to toggle profiles then ctrl+1..ctrl+2 etc. not using ahk unless i feel like switching to ctrl+a etc
Re: is it possible to write a script that opens specific chrome or firefox tabs
Based on a thread in the old forum:
https://autohotkey.com/board/topic/5025 ... tab/page-3
Here's what I currently have, based not on tab numbers but specific sites/web apps that I want to switch to:
Edit: the code above now recognizes popups (hard-coded to YouTube at the moment) as well as regular tabs. The former don't include " - Google Chrome" in the Window Title (it appears popups just use the page's HTML title tag and website name), even though according to Chrome's task manager, popups are really tab processes. It happens that I like to run Youtube in a popup as I explained in this post:
http://www.oliviertravers.com/how-youtube-window/
I'm sure this could be refactored to cycle through popups then tabs so that it's not necessary to hard-code anything (that way I could put Gmail and Todoist in popups).
Anyway this might be a bit of a digression vs. your original request (by tab number) but I hope this helps.
https://autohotkey.com/board/topic/5025 ... tab/page-3
Here's what I currently have, based not on tab numbers but specific sites/web apps that I want to switch to:
Code: Select all
#g::WinActivate( "- Gmail", "https://mail.google.com/mail/u/0/#inbox" )
#t::WinActivate( "Todoist", "https://todoist.com/app?lang=en" )
#y::
WinActivate( " - YouTube", "https://www.youtube.com/feed/subscriptions" )
Send {Space}
return
WinActivate( TheWindowTitle, TheProgramTitle ) {
if (TheWindowTitle = " - YouTube")
{
chrome := TheWindowTitle
}
else
{
chrome := " - Google Chrome"
}
found := "false"
tabSearch := TheWindowTitle
curWinNum := 0
SetTitleMatchMode, 2
WinGet, numOfChrome, Count, %chrome% ; Get the number of chrome windows
WinActivateBottom, %chrome% ; Activate the least recent window
WinWaitActive %chrome% ; Wait until the window is active
ControlFocus, Chrome_RenderWidgetHostHWND1 ; Set the focus to tab control ???
; Loop until all windows are tried, or until we find it
while (curWinNum < numOfChrome and found = "false") {
WinGetTitle, firstTabTitle, A ; The initial tab title
title := firstTabTitle
Loop
{
if(InStr(title, tabSearch)>0){
found := "true"
break
}
Send {Ctrl down}{Tab}{Ctrl up}
WinGetTitle, title, A ;get active window title
if(title = firstTabTitle){
break
}
}
WinActivateBottom, %chrome%
curWinNum := curWinNum + 1
}
; If we did not find it, start it
if(found = "false"){
WinActivateBottom, %chrome%
curWinNum := curWinNum + 1
Run %TheProgramTitle%
}
return
}
Edit: the code above now recognizes popups (hard-coded to YouTube at the moment) as well as regular tabs. The former don't include " - Google Chrome" in the Window Title (it appears popups just use the page's HTML title tag and website name), even though according to Chrome's task manager, popups are really tab processes. It happens that I like to run Youtube in a popup as I explained in this post:
http://www.oliviertravers.com/how-youtube-window/
I'm sure this could be refactored to cycle through popups then tabs so that it's not necessary to hard-code anything (that way I could put Gmail and Todoist in popups).
Anyway this might be a bit of a digression vs. your original request (by tab number) but I hope this helps.
Re: is it possible to write a script that opens specific chrome or firefox tabs
AccViewer can retrieve the names of Firefox browser tabs,
and so it should be possible to check if a tab
with a certain name exists,
and to click a tab with a specific name via accDoDefaultAction.
However, although I could retrieve information via AccViewer,
I have been having trouble retrieving this information via Acc.ahk.
Any help would be much appreciated, as I keep running into this problem,
with different programs, AccViewer works,
but Acc.ahk functions appear to be inconsistent,
working on some programs but not others.
The same was true of Chrome, I could retrieve information via AccViewer,
but not obtain it via the Acc functions in Acc.ahk.
To open a url in a new tab is quite straightforward:
For Firefox, initial get tab names attempt:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
and so it should be possible to check if a tab
with a certain name exists,
and to click a tab with a specific name via accDoDefaultAction.
However, although I could retrieve information via AccViewer,
I have been having trouble retrieving this information via Acc.ahk.
Any help would be much appreciated, as I keep running into this problem,
with different programs, AccViewer works,
but Acc.ahk functions appear to be inconsistent,
working on some programs but not others.
The same was true of Chrome, I could retrieve information via AccViewer,
but not obtain it via the Acc functions in Acc.ahk.
To open a url in a new tab is quite straightforward:
Code: Select all
vPath := "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
Run, "%vPath%" "%vUrl%"
vPath := "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Run, "%vPath%" "%vUrl%"
Code: Select all
WinGet, hWnd, ID, A
;this works
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
vOutput := ""
Loop, % oAcc.accChildCount
vOutput .= A_Index " " oAcc.accName(A_Index) "`r`n"
Clipboard := vOutput
MsgBox % vOutput
;this doesn't work
oAcc := Acc_Get("Object", "4,22", 0, "ahk_id " hWnd)
vOutput := ""
Loop, % oAcc.accChildCount
vOutput .= A_Index " " oAcc.accName(A_Index) "`r`n"
Clipboard := vOutput
MsgBox % vOutput
Return
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: is it possible to write a script that opens specific chrome or firefox tabs
OK, well I managed to get it sussed.
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947
Working script:
autohotkey - Using AHK to activate specific tabs in chrome or firefox - Stack Overflow
http://stackoverflow.com/questions/4147 ... 1#41672931
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947
Working script:
autohotkey - Using AHK to activate specific tabs in chrome or firefox - Stack Overflow
http://stackoverflow.com/questions/4147 ... 1#41672931
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 1
- Joined: 24 Mar 2021, 07:34
Re: is it possible to write a script that opens specific chrome or firefox tabs
Yes you can, make a .bat file (make a new txt file rename it to.bat) edit the bat file with the following code: (to edit a .bat right click on the .bat file and click edit) :sleepy wrote: ↑04 Jan 2017, 19:13like ctrl+a opens the second tab etc
also is it possible to write a script that opens a tab or web page based on a sequence i.e. ctrl+a then press "g"
huge thank you, not sure if AHK is appropriate for this.
start "C:\Program Files\Google\Chrome\Application\chrome.exe" %1 www.youtube.com
(I just put youtube.com but put whatever website you want)
then just make an ahk script that runs that batch file if you need help with that you can find info here:
https://www.autohotkey.com/docs/commands/Run.htm
But to simplify it the command is run so you would type run and then in quotation marks you would paste the file path of your .bat
it would look something like this (the bat file would be the code with whatever website you want)
^a::
run "C:\Users\ben\Documents\tab.bat"