Internet Explorer: move tab to new window

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

Internet Explorer: move tab to new window

26 Dec 2016, 00:13

I wrote this script which moves the active tab to a separate Internet Explorer window.
I just wondered if anybody else had tried something similar, or if there was a more direct, programmatic method to achieve this.
It uses the Acc library.

Code: Select all

#IfWinActive, ahk_class IEFrame ;internet explorer
^m:: ;internet explorer - move active tab to new window

Hotkey, IfWinActive, ahk_class IEFrame
Hotkey, ^m, Off
ToolTip, release Ctrl key
KeyWait, Ctrl
ToolTip
Hotkey, ^m, On

WinGet, hWnd, ID, A
ControlGet, hCtl, Hwnd,, TabBandClass1, % "ahk_id " hWnd
oAcc := Acc_Get("Object", "4.1.4.1", 0, "ahk_id " hCtl)

for _, oChild in Acc_Children(oAcc)
	if (oChild.accChildCount = 1)
	{
		vTabText := oChild.accDescription(0), oTabPos := Acc_Location(oChild)
		break
	}

vPosX := Round(oTabPos.X + oTabPos.W / 2)
vPosY := Round(oTabPos.Y + oTabPos.H / 2)

CoordMode, Mouse, Screen
MouseGetPos, vPosX2, vPosY2
MouseClickDrag, Left, % vPosX, % vPosY, % vPosX, % vPosY-20, 0
MouseMove, % vPosX2, % vPosY2
return
#IfWinActive
Last edited by jeeswg on 04 Oct 2018, 16:33, edited 2 times in total.
User avatar
jeeswg
Posts: 5448
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Internet Explorer: move tab to new window

13 Jun 2017, 16:39

I found these constants but it still hasn't solved the problem, and NavOpenInNewWindow doesn't appear to work (Windows 7 IE 11).

Code: Select all

q:: ;test - open url in new tab/window
WinGet, hWnd, ID, A
oWB := WBGet("ahk_id " hWnd)
vUrl := oWB.LocationURL
oWB.Navigate(vUrl, 0x1) ;NavOpenInNewWindow := 0x1 ;opens in new tab
;oWB.Navigate(vUrl, 0x800) ;NavOpenInNewTab := 0x800 ;works
oWB := ""
return

;[WBGet function]
;Basic Webpage Controls with JavaScript / COM - Tutorial - Tutorials - AutoHotkey Community
;https://autohotkey.com/board/topic/47052-basic-webpage-controls-with-javascript-com-tutorial/
BrowserNavConstants enumeration (Internet Explorer)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx

winapi - GoDoc
https://godoc.org/github.com/antonlahti/go-winapi

Code: Select all

    NavOpenInNewWindow       = 0x1
    NavNoHistory             = 0x2
    NavNoReadFromCache       = 0x4
    NavNoWriteToCache        = 0x8
    NavAllowAutosearch       = 0x10
    NavBrowserBar            = 0x20
    NavHyperlink             = 0x40
    NavEnforceRestricted     = 0x80
    NavNewWindowsManaged     = 0x0100
    NavUntrustedForDownload  = 0x0200
    NavTrustedForActiveX     = 0x0400
    NavOpenInNewTab          = 0x0800
    NavOpenInBackgroundTab   = 0x1000
    NavKeepWordWheelText     = 0x2000
    NavVirtualTab            = 0x4000
    NavBlockRedirectsXDomain = 0x8000
    NavOpenNewForegroundTab  = 0x10000
Btw I don't personally need this, but it would be interesting if it's possible to move tabs programmatically at all, i.e. is it possible to reorder tabs programmatically, without using the mouse. One problem is that these questions are often asked on forums by people who want *any* solution, not a *programmatic* solution.

Return to “Ask For Help”

Who is online

Users browsing this forum: AmDeG 11, Bing [Bot], Google [Bot], lareous, newbieforever, PuzzledGreatly, swagfag, vvhitevvizard and 36 guests