Goal's to refresh and focus onto an existing Mozilla Firefox page (away from any current focus); achieved former, but not latter:
^!s::ControlSend,,{F5},ahk_class MozillaWindowClass
WinActivate, ahk_class MozillaWindowClass
return
Any clues?
To have more than one command executed by a hotkey, put the first line beneath the hotkey definition and make the last line a return:
^!s::
ControlSend,,{F5},ahk_class MozillaWindowClass
WinActivate, ahk_class MozillaWindowClass
return
https://autohotkey.com/docs/Hotkeys.htm#Intro
Related
I just want W to correspond to the Up Arrow key and S to correspond to the Down Arrow key, and work just like they do, and for A/D to move the focus to the last/next tab.
When i hold S, the page skips down erratically and then Firefox opens the "Save as" window multiple times.
When i hold W, the page skips up erratically and then multiple tabs are closed.
D does what it's supposed to, and A straight up doesn't work.
#IfWinActive ahk_exe firefox.exe
w::
Send {Up} ; Move page up.
s::
send {down} ; Move page down.
a::
send, ^{pgup} ; Go to tab on the left.
d::
send, ^{pgdn} ; Go to tab on the right.
#IfWinActive
Return
What exactly is happening? It should work normally but it isn't.
#IfWinActive ahk_exe firefox.exe
w:: Send {Up} ; Move page up.
s:: send {down} ; Move page down.
#IfWinActive ; turn off context sensitivity
The above examples are known as single-line hotkeys because each consists of only one command.
To have more than one command executed by a hotkey, put the first line beneath the hotkey definition and make the last line a return. For example:
#n::
Run http://www.google.com
Run Notepad.exe
return
https://autohotkey.com/docs/Hotkeys.htm#Intro
I work with a local application which when ESCAPE is pressed, the current window is closed. I wanted to avoid that so I made a script with AutoHotKey that detects the name of the window within the app and, if I press ESCAPE, the window doesn't close (Unless I press the X).
#IfWinActive ahk_class name_of_app_class_here
Escape::return
Now I would like to apply a code for when that window is closed (by pressing the X) but I cuoldn't find any solution for that in the forum or in the help.
Example:
#IfWinActive ahk_class name_of_app_class_here
OnWindowClose
`Do_something`
Hope it is well explained.
Thanks!
The code below should do what you want to achieve:
;tested on Notepad (Windows 7)
;note: may not work correctly if aero mode is on
;note: if you click a Notepad window that is *not* the active window, it will be closed
;note: some programs don't return the standard NCHITTEST value for a close button,
;a workaround is to compare the cursor position against the window coordinates
#IfWinActive, ahk_class Notepad
LButton::
WinGet, hWnd, ID, A
WinGetClass, vWinClass, ahk_id %hWnd%
if vWinClass not in Notepad
Return
CoordMode, Mouse, Screen
MouseGetPos, vPosX, vPosY, hWnd2
if (hWnd = hWnd2)
{
SendMessage, 0x84, 0, vPosX|(vPosY<<16), , ahk_id %hWnd% ;WM_NCHITTEST
vNCHITTEST := ErrorLevel ;(8 min, 9 max, 20 close)
if (vNCHITTEST = 20)
{
MsgBox can't close me! ;put your code here
Return
}
}
SendInput {LButton Down}
KeyWait, LButton
SendInput {LButton Up}
Return
#IfWinActive
Note:
The code posted in the link below, achieves something related, catching close buttons for all windows, not just for one program, whether they are active or inactive.
Is it possible to catch the close button and minimize the window instead? AutoHotKey
The below script works but minimizes a screen inactive, but I would like to keep the inactive window visible. what should I do?
F9::
IfWinExist ahk_class Forge10MDIClass
WinMove ahk_class Forge10MDIClass
WinActivate ahk_class Forge10MDIClass
Send {space} ;; pauses audio file (toggles)
Send !{Esc} ;; Alt + Esc in Windows 8; but it is minimizing and I dont want that
return
You could do this in 2 different ways:
First: Store the active window and switch back after toggling the audio file
F9::
WinGet, active_id, ID, A
IfWinExist ahk_class Forge10MDIClass
{
WinActivate ahk_class Forge10MDIClass
Send {space} ;; pauses audio file (toggles)
WinActivate, ahk_id %active_id%
}
Return
Second: Use ControlSend to send Space directly to the window without having to activate it.
F9::ControlSend, ahk_parent, {Space}, ahk_class Forge10MDIClass
Note: I do not have this software, so I cannot confirm that ControlSend works properly with it.
Hope this helps.
I've made simple remapping of CapsLock to Control with autohotkey:
Capslock::Control ; make Caps Lock the control button
This works OK, but in Emacs if I need to do a key sequence like Ctrl-x Ctrl-f while holding the CapsLock key continuously the whole time what gets registered is Ctrl-x f. In order to get the correct sequence I now have to release CapsLock between the keystrokes like Ctrl-x <release> Ctrl-f which is very inconvenient.
Is there a way to do the rebinding so that holding CapsLock down will work exactly as holding down the Control button?
I've also tried the following snippet without success:
#IfWinActive ahk_class Emacs
{
CapsLock::
Sendinput {Ctrl Down}
KeyWait, CapsLock
Sendinput {Ctrl Up}
return
}
Using Send or Sendplay in the above instead of Sendinput also doesn't solve my problem.
My system:
Windows 7 32bit
AHK v1.1.13.01
Emacs 24.3
Thank you!
I'm not sure why it's not working correctly for you. I added your remapping into my existing script and it seems to work fine. Can you post more of what you have? I have the following commands at the top of mine but I wouldn't think they should affect your problem.
#Persistent
#SingleInstance, Force
The commands GetKeystate
and SetKeyDelay might be helpful.
This is what I use and it works:
*Capslock::LCtrl
The asterisk is documented in the help under Keyboard Control > Hotkeys and Hotstrings:
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:
*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey.
*ScrollLock::Run Notepad ; Pressing Scrolllock will trigger this hotkey even when modifer key(s) are down.
This symbol is ignored on Windows 95/98/ME.
I actually have this one too, +Caps Lock, if I really want caps lock:
<#Capslock::Capslock
Try this;
SetCapsLockState, AlwaysOff
CapsLock:: SendInput, {LCtrl Down}
Capslock Up:: SendInput, {LCtrl Up}
What is wrong with my script?
Context: Inbox folder of Outlook. I want to click (focus) just only one email (the one with the gray color), but my script ALSO "colors" all emails the are above it. I'm not sure what is the matter.
#IfWinActive ahk_class rctrl_renwnd32
+F7::
PixelSearch, Px, Py, 14,98,754,962, 0xE1E1E1, 3, Fast
if ErrorLevel
MsgBox, That color was not found in the specified region.
else
Click, %Px%, %Py%
return
#IfWinActive
It seems that you are oh, say, scrolling or moving the cursor around in the preview panel, and now you want to jump the cursor to that same email's entry in the mailbox listing.
If this be the case, then here is a possible solution for you:
Okay, so we know that by default, whatever message you are viewing in the preview pane should be the highlighted entry in the mailbox list. That means all we have to do is to set focus to the mailbox list pane - when that pane receives focus, then the highlighted entry should be able to receive your immediate keyboard commands since it is already selected.
Therefore, all you need to do with your ahk script is create a hotkey that sets focus to the mailbox pane. Use your window spy to spy the class of the mailbox pane and just set focus to it. You shouldn't have to worry about colours at all.
Maybe something like this for Office 2010:
+F7::
ControlFocus, SUPERGRID2, ahk_class rctrl_renwnd32
return
or, for Office 2013:
+f7::
ControlFocus, OutlookGrid1, ahk_class rctrl_renwnd32
if ErrorLevel
MsgBox, You don't seem to be in context.
return
Or, instead of hacking the window, you could just push ctrl+1 - Outlook has a built-in keyboard command to set focus to the mailbox list.