global open new tab in chrome
global open new tab in chrome
I would like to set 'ctrl + t' as a global hotkey for opening a tab in chrome whether or not the browser is the active window.
Re: global open new tab in chrome
Code: Select all
#Requires AutoHotkey v1.1.33.11
app := "chrome.exe"
winTitle := "ahk_exe" app
$^t::
If !WinExist(winTitle) {
Run % app
SoundBeep 2500
WinWait % winTitle,, 6
If ErrorLevel {
MsgBox 48, Error, An error occurred while waiting for the window.
Return
} Else Sleep 2000
}
WinActivate
Send ^t
SoundBeep 1500
Return
Re: global open new tab in chrome
how can I fix this error?
Code: Select all
---------------------------
chrome tab.ahk
---------------------------
Error: Missing "}"
Line#
010: Return
011: if !WinExist(winTitle)
011: {
012: Run,app
013: SoundBeep,2500
014: WinWait,winTitle,,6
015: if ErrorLevel
---> 015: {
016: MsgBox,48,Error,An error occurred while waiting for the window.
017: Exit
018: Exit
018: Exit
The program will exit.
---------------------------
OK
---------------------------
Re: global open new tab in chrome
Copy and use the complete code from the codebox in mikeyww's post, eg by pressing 'Select All' (or expanding/scrolling the codebox and selecting the whole code manually) before copying it.
Re: global open new tab in chrome
Oh, silly mistake .. curious about the choice to add a beep?
Re: global open new tab in chrome
The good thing about such features is you can keep them if you like them and very easily remove them if you don't.
Re: global open new tab in chrome
I agree: delete if you wish!
Some of the rationale for beeps during testing or beyond is below.
Some of the rationale for beeps during testing or beyond is below.
- Confirms that a hotkey was triggered
- Confirms that something else is happening, such as while the user is waiting, or when no other action is visible
Re: global open new tab in chrome
Would I be able to insert this script into a master script as written?
Works fine when run on its own, but when inserted into a collection of scripts,
I get this error message:
Works fine when run on its own, but when inserted into a collection of scripts,
I get this error message:
Re: global open new tab in chrome
You can’t put the lines where it assigns the variables app and WinTitle below hotkeys when you combine scripts because they will never execute.
Re: global open new tab in chrome
Thinking I will put this in a dedicated script as I am not sure how to avoid the conflict ..
Is there a way to put an exception in this script to disable this hotkey when photoshop is the active window?
Is there a way to put an exception in this script to disable this hotkey when photoshop is the active window?
Re: global open new tab in chrome
I just explained how. Don't put the lines where it assigns those two variables below any hotkeys in your script. Put them at the very top of your combined script in the auto-execute section so that those lines will actually execute.
Put this line immediately above the line with the hotkey label:
Code: Select all
#If !WinActive("ahk_exe Photoshop.exe")
If you have any other hotkeys below that one in your script that you don't want affected by the above directive, place the following on a line preceding the first of those, assuming you don't already have other directives meant for them:
Code: Select all
#If
Explained: #If
Re: global open new tab in chrome
Below is just a way to combine these approaches.
Code: Select all
#If !WinActive("ahk_exe Photoshop.exe")
$^t::
If !WinExist(winTitle := "ahk_exe" app := "chrome.exe") {
Run % app
SoundBeep 2500
WinWait % winTitle,, 6
If ErrorLevel {
MsgBox 48, Error, An error occurred while waiting for the window.
Return
} Else Sleep 2000
}
WinActivate
Send ^t
SoundBeep 1500
Return
#If
Who is online
Users browsing this forum: No registered users and 151 guests