DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Post New Requests Here => Topic started by: wasker on December 14, 2005, 06:45 AM

Title: Forward button on Mouse Explorer to Open Link in a New Window
Post by: wasker on December 14, 2005, 06:45 AM
I've got an MS MouseExplorer and came with the following code to make it open links in a new window when I browsing with IE:

XButton2::
If WinActive("ahk_class IEFrame")
{
    Send, {SHIFT down}{LButton}{SHIFT up}
    return
}
else
{
    Send, {XButton2}
    return
}

Now I would like to make it work with all apps that use IE for browsing purposes (Html Help for instance). I need to detect the class of window that is currently under mouse cursor. How to do this?
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: mouser on December 14, 2005, 08:44 AM
great question.

there are programs that will tell you the windows classes of other windows; often they have "spy" in their names, like windows "spy" or something.  i can't remember any off hand but if you can't find a good free one with google and no one else posts the link for one i'll look again.
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: wasker on December 14, 2005, 08:56 AM
Actually I know window class name I need. And in fact AutoHotkey has the Spy in its distro for this purpose. What I don't know is which function of AutoHotkey determines the class of window under cursor. I mean not the window like IE window itself, but rather control's window (InternetExplorer_Server for instance).

In other word: I want Autohotkey to run the aforementioned macro if the mouse is over WebBrowser control (InternetExplorer_Server class) in any application (IE, HtmlHelp, Visual Studio, etc.). Is this possible? If yes, then which function I should use?
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: mouser on December 14, 2005, 09:03 AM
ahh... i understand now what you are saying..
but it's beyond my knowledge - skrommel or someone else will know hopefully - definitely should be possible.
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: skrommel on December 14, 2005, 11:49 AM
 :) Here's a script from AHK's help file:

; This example allows you to move the mouse around to see
; the title of the window currently under the cursor:
#Persistent
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%
return

Skrommel
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: wasker on December 14, 2005, 12:42 PM
Ah, I see. Thanks!  :Thmbsup:

Here's what I've got. It works as expected so far.

XButton2::
SetTimer, LookForInternetExplorer, 50
return

LookForInternetExplorer:
SetTimer, LookForInternetExplorer, Off
MouseGetPos,,, id, control
IfInString, control, Internet Explorer_Server
{
    Send, {SHIFT down}{LButton}{SHIFT up}
    return
}
else
{
    Send, {XButton2}
    return
}
return
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: skywalka on December 15, 2005, 01:18 AM
I use the Maxthon browser (the best browser ever) which has an option 2 open links in a new tab via the middle mouse button.

Is it possible 2 open links with the middle mouse button from outside Maxthon itself.  ie Outlook Express & the Favorites bar etc?
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: skrommel on December 15, 2005, 01:49 AM
 :-\ You could send a RightClick and choose Copy Shortcut or something from the menu, depending on the window beneath the cursor, and then Run or paste it.

Skrommel
Title: Re: Forward button on Mouse Explorer to Open Link in a New Window
Post by: skywalka on December 15, 2005, 01:55 AM
OK.  Thanx.