Internet Explorer: activate tab Topic is solved

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

Internet Explorer: activate tab

09 Jul 2017, 00:44

Methods to activate a tab in Internet Explorer include:
- use the Acc library to invoke the tab button on the DirectUIHWND control using accDoDefaultAction (won't work if there are too many tabs)
- press Ctrl+Tab repeatedly and check the Edit control text (not ideal)

==================================================

So I'd be interested in any possible alternatives, such as interacting with a control or IE object.

Some code to open many urls, and some failed attempts at nudging an IE tab:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


==================================================

Note: the TabWindowClass controls contain the tab name. If you find TabWindowClassNN, then its associated controls will have the same NN. Although you can also check parent/child controls to find associated controls.

Note: WBGet can be used to latch onto an Internet Explorer_Server control, and then get document.url and document.title.
Basic Webpage Controls with JavaScript / COM - Tutorial - Tutorials - AutoHotkey Community
https://autohotkey.com/board/topic/47052-basic-webpage-controls-with-javascript-com-tutorial/
phaleth
Posts: 28
Joined: 13 Apr 2015, 03:49

Re: Internet Explorer: activate tab

09 Jul 2017, 03:08

Following is prolly not 100% reliable but still way better than using ControlSend

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 2198
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Internet Explorer: activate tab  Topic is solved

19 Aug 2017, 20:59

Tested on Windows 7 64-bit, Internet Explorer 11.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



==================================================

I replaced WinActivate with ControlSend and SetForegroundWindow, because using WinActivate works, but it can flash the title bar a bit.

For the WinActivate command source code see: SetForegroundWindowEx, a custom AHK function in window.cpp (which is not a standard Winapi function, although SetForegroundWindow is).

Various bits of code relating to activating windows:

Code: [Select all] [Download] GeSHi © Codebox Plus

WinActivate, % "ahk_id " hWnd
ControlSend, ahk_parent, {Alt Down}{Alt Up}{Alt Down}{Alt Up}, % "ahk_id " hWnd
DllCall("user32\SetForegroundWindow", Ptr,hWnd)
PostMessage, 0x1C,,,, % "ahk_id " hWnd ;WM_ACTIVATEAPP := 0x1C
DllCall("user32\ShowWindow", Ptr,hWnd, Int,5) ;SW_SHOW := 5
DllCall("user32\ShowWindow", Ptr,hWnd, Int,9) ;SW_RESTORE := 9
DllCall("user32\BringWindowToTop", Ptr,hWnd)


==================================================

As a bonus, here are some handy Internet Explorer window messages:
Internet Explorer Winset command list - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28759&p=134907#p134907
How to open the context menu of the window's title bar - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=35975&p=165570#p165570
User avatar
jeeswg
Posts: 2198
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Internet Explorer: activate tab

02 Oct 2017, 23:07

I have here 8 functions, intended to work similarly to the functions for Firefox and Chrome:
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26947

Unfortunately although a lot of things are doable in Internet Explorer, I have had a lot of problems trying to activate a tab in Internet Explorer. It's possible to loop through the Internet Explorer_Server controls in Internet Explorer, and retrieve the titles/urls, however, even though you might have the control hWnd, I'm not sure of a method to then focus the tab.

Methods to activate a tab work as follows: activate a TabThumbnailWindow window (if you know the title), or, use Acc to invoke the activation of one of the tabs you can see listed on the screen, or, navigate using ctrl+tab to a tab you can't see (when there are too many tabs for Internet Explorer to show all at the same time (if you know the title or url).

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Drake, euras, Unknovvn and 38 guests