Hello! I want to know how AHK's hotkey works.
#IfWinActive ahk_class Chrome_WidgetWin_1
^t::send !a
#IfWinActive
the hotkey above works only when there's active chrome window, otherwise it is ignored.
Question is, what exactly happens when I press ctrl + t combination somewhere else, not on chrome?
does it still try to check if I am on chrome and if yes perform the send command, or does it simply do nothing on AHK end?, I mean, nothing, not even a checkup?
probably it can be between this two:
1. When hotkey is pressed, the AHK program detects it is pressed on whatever windows that is active, and then it check if that window is the that of predefined program, and then if so, it sends what it is asked to send, for the above, Alt + a
2. Or, the AHK program execute the script only when Chrome window is open and active, so if active window is not Chrome's(e.g. notepad), then AHK script is not called up and ^t does what it is supposed to do in that program.
I ask this because there's list of hotkeys that are plain single characters like A or 5 and used as hotkey only in specific programs, in this case if the answer is 1, it will possibly and unnecessarily uses the CPU no matter how heavy it will be. imagine how many times a or 5 will be used in writing some novels or anything.
thank you.
Question about how autohotkey works
Re: Question about how autohotkey works
Could always do some reading about this. https://www.autohotkey.com/docs/commands/_IfWinActive.htm#gen
I would challenge you to prove that the added CPU usage is anything greater than approximately zero.For performance reasons, #IfWin does not continuously monitor the activation or existence of the specified windows. Instead, it checks for a matching window only when you type a hotkey or hotstring. If a matching window is not present, your keystroke or mouse click is allowed to pass through to the active window unaltered.
Re: Question about how autohotkey works
Hallo,
try this audible script flow:
try this audible script flow:
Code: Select all
q::SoundBeep, 1000, 20
w::SoundBeep, 2000, 20
#If WinActive("ahk_class Chrome_WidgetWin_1"), SoundBeep()
w::SoundBeep, 2000, 20
e::SoundBeep, 3000, 20
#If !WinActive(), SoundBeep()
e::SoundBeep, 3000, 20
SoundBeep()
{
SoundBeep, 4000, 20
}
Re: Question about how autohotkey works
You're free to close the script when you don't need it, but computers are meant to save you time, not vice versa. If it takes you a few seconds to start or stop the script, that's probably about a million times as long as the program takes to check the active window when you press a hotkey. If it takes you a fraction of a second to press and release a key, the CPU is probably still being used less than 1% of that time to process it.
Using the CPU is necessary to make the computer do anything useful. Every time you press a key, the operating system is using the CPU to process your input. There is a lot of work going on behind the scenes that you never notice, because it doesn't happen on a human timescale.
Heavy? I have no idea what you mean.... it will possibly and unnecessarily uses the CPU no matter how heavy it will be.
Using the CPU is necessary to make the computer do anything useful. Every time you press a key, the operating system is using the CPU to process your input. There is a lot of work going on behind the scenes that you never notice, because it doesn't happen on a human timescale.