Page 1 of 1

Limit script to URL address bar (Firefox)

Posted: 19 Feb 2015, 03:48
by jmgimenez
Hi,

I am trying to limit a script to when the user is typing in the URL address bar of Firefox. Is it possible?

I found this for IE: http://ahkscript.org/boards/viewtopic.php?f=5&t=6068.

J.

Re: Limit script to URL address bar (Firefox)  Topic is solved

Posted: 19 Feb 2015, 05:41
by empardopo
Check this

Code: Select all

actingexceptonlywhentheuseristypingintheURLaddressbarofInternetExplorer(){
;hWnd := WinActive("ahk_class IEFrame") ; return the IE window handle if the active window IS IE
hWnd := WinActive("ahk_class MozillaWindowClass") ; return the IE window handle if the active window IS IE
if !hWnd ; the IE is not active
    return
ControlGetFocus, Focused, A ; return the focused control in the active window
return, (Focused="") ; return true if the focused control is the URL address
}

; for example a hotkey A
; Rempad A to B
; but just for The URL Adress bar in the internet explorer
#if actingexceptonlywhentheuseristypingintheURLaddressbarofInternetExplorer() ; see #If in the docs, you'd have better understanding later
A::
Send B
return
But there is a difference.

Greetings.

Re: Limit script to URL address bar (Firefox)

Posted: 19 Feb 2015, 05:56
by jmgimenez
Thank you, that was quick!

Unfortunately, this doesn't seem to work. This limits the script to Firefox, but not to the address bar.

Am I doing something wrong?

Regards,

J.

Re: Limit script to URL address bar (Firefox)

Posted: 19 Feb 2015, 06:40
by empardopo
In IE when I put the mouse in the URL address using the Window Spy I get "Edit1" othhowever in Firefox I get nothing!

Sorry.

Re: Limit script to URL address bar (Firefox)

Posted: 19 Feb 2015, 07:52
by boiler
As a last resort, you could use MoseGetPos with CoordMode, Mouse, Window, and limit it to when the returned y value is below some number.

Re: Limit script to URL address bar (Firefox)

Posted: 19 Feb 2015, 10:49
by MJs
FF address bar isn't an Edit control like IE, that's why the script works for IE and not for FF, so you're not the one doing it wrong, it's just not the same type of control.
now, boiler's last resort is close, but you can get a little bit closer and use A_CaretX and A_CaretY
again, it's not that simple since the address bar can be any where, above or bellow the tabs for example....(user can change it)
you may need to look for a way to get the exact location of the address bar in FF (Firefox setttings may be), not easy in AHK I suppose, you may find it in firefox forums, and compare them to that A_CaretX, A_CaretY to verify if the user is typing in the URL address bar of Firefox.