c.haslam

Shortcut to type email address in Firefox

3 posts in this topic

The following script types an email address in Firefox. There is a shortcut on the Desktop which causes it to run when Ctrl+Alt+M is pressed.

;Local $wh = WinGetHandle("[ACTIVE]")
;If WinExists("[CLASS:MozillaWindowClass]") Then
;   If WinActive("[CLASS:MozillaWindowClass]") Then
        Opt("SendKeyDelay",50)
        ControlSend("[CLASS:MozillaWindowClass]","","","x@gmail.com",1)
;   EndIf
;EndIf
;WinActivate($wh)

The code that is not commented out works, but it has a side-effect: Firefox loses focus. What changes to the script are required for Firefox to keep focus? Some of the commented-out code is my attempt.

The second problem: if Ctrl+Alt+M is pressed when focus is on another application, e.g. TextPad, that application loses focus. How can it keep focus?

You may ask: why would one want to have AutoIt type an address? For domestic harmony!

...chris


...chris

Share this post


Link to post
Share on other sites



The window does not need to be active when using ControlSend nor does ControlSend activate it.

If you want to activate Firefox use WinActivate

WinActivate ( "title" [, "text"] )

For the second problem you could use WinGetHandle to get active window handle, execute your code then restore previous window focus with WInActivate.

;Get active window handle
Local $hWnd = WinGetHandle("")

;Your code here

;Restore focus to active window
WinActivate($hWnd)

 

Share this post


Link to post
Share on other sites

Thanks, Rog.


...chris

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now