Limit script to URL address bar (Firefox)

Get help with using AutoHotkey and its commands and hotkeys
jmgimenez

Limit script to URL address bar (Firefox)

19 Feb 2015, 03:48

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.
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Limit script to URL address bar (Firefox)

19 Feb 2015, 05:41

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.
Attachments
navega.png
Everything is possible!
jmgimenez

Re: Limit script to URL address bar (Firefox)

19 Feb 2015, 05:56

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.
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Limit script to URL address bar (Firefox)

19 Feb 2015, 06:40

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.
Everything is possible!
User avatar
boiler
Posts: 5219
Joined: 21 Dec 2014, 02:44

Re: Limit script to URL address bar (Firefox)

19 Feb 2015, 07:52

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.
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Limit script to URL address bar (Firefox)

19 Feb 2015, 10:49

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.

Return to “Ask For Help”

Who is online

Users browsing this forum: Ben, Bing [Bot], Forgetabyteit, kdservices, tee_rock, vsub and 135 guests