Mozilla Firefox: Save Image As... using s not v

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Mozilla Firefox: Save Image As... using s not v

02 Nov 2017, 08:30

Internet Explorer has 'Save picture as...', with accelerator key s.
Mozilla Firefox has 'Save Image As...', with accelerator key v.
This equals confusion.

Ordinarily in Mozilla Firefox if you press s, you get Set As Desktop Background..., which is undesirable.

I'm trying to write a script such that when you press s, and a menu is detected, v is sent.

In theory it should work, but at the moment I'm not clear why it isn't working.

Intended code.

Code: Select all

DetectHiddenWindows, Off

#If WinActive("ahk_class MozillaWindowClass") && WinExist("ahk_class MozillaDropShadowWindowClass")
s:: ;mozilla firefox - save image as
SendInput, v
return
#IfWinActive
Same code with a diagnostic ToolTip.

Code: Select all

#If WinActive("ahk_class MozillaWindowClass") && WinExist("ahk_class MozillaDropShadowWindowClass")
s:: ;mozilla firefox - save image as
hWnd := WinExist("ahk_class MozillaDropShadowWindowClass")
WinGet, vWinStyle, Style, % "ahk_id " hWnd
;WS_POPUP := 0x80000000 ;WS_VISIBLE := 0x10000000
;WS_CLIPSIBLINGS := 0x4000000 ;WS_CLIPCHILDREN := 0x2000000
;style is 0x86000000, so WS_VISIBLE is off,
;but WinExist still returns an hWnd,
;after the menu is shown at least once
SendInput, v
ToolTip, % hWnd " " vWinStyle
DetectHiddenWindows, Off
return
#IfWinActive
The WinExist line should only return True if the menu is visible, but when I retrieve the window style it implies that the menu is not visible.

As soon as you show the menu at least once, WinExist always seems to return an hWnd, even when DetectHiddenWindows is set to off.

Thanks for reading.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Mozilla Firefox: Save Image As... using s not v

13 Oct 2019, 02:02

Anyhow, the script above appears to be working, as does the variant below.
I added the SoundBeep, because, if the script was ever to send v when you actually wanted to send s, this could cause problems, including at password prompts (where you wouldn't know the letter was being changed)!

Code: Select all

#If WinActive("ahk_class MozillaWindowClass")
&& WinExistVisible("ahk_class MozillaDropShadowWindowClass")
s:: ;mozilla firefox - context menu (press s, send v) (save image as...)
SendInput, v ;Save Image As...
SoundBeep
return
#If

;==================================================

WinExistVisible(oParams*)
{
	local
	vDHW := A_DetectHiddenWindows
	DetectHiddenWindows, Off
	hWnd := WinExist(oParams*)
	DetectHiddenWindows, % vDHW
	return hWnd
}

;==================================================
Anyone have any ideas to change the shortcut key from within Firefox?
That said, I do generally prefer to use AHK techniques, that leave things completely untouched (apart from when AHK is running).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
malcev
Posts: 793
Joined: 12 Aug 2014, 12:37

Re: Mozilla Firefox: Save Image As... using s not v

13 Oct 2019, 03:43

For me this code works

Code: Select all

#If WinActive("ahk_class MozillaWindowClass") && WinExist("ahk_class MozillaDropShadowWindowClass")
s:: ;mozilla firefox - save image as
SendInput, v
return
#IfWinActive
Win10 firefox 69.0.3

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, kczx3, kunkel321, mikeyww and 31 guests