Jump to content
Macro Express Forums

How to bring a Chrome Tab into Focus


Recommended Posts

I’m new to Macro Express – please be gentle!

 

PROBLEM

How can I bring a particular Chrome Tab into Focus so that I can use it.

 

ANALYSIS

I am using - Windows 10 - Chrome - Macro Express Pro – two screens

 

On my First screen I have an Excel list of Part Numbers

 

On my second screen I have 10 Chrome tabs and I need to bring the second Tab (called ‘Parts’) into Focus so that I can paste a part number and then ‘Enter’.

When the ‘Parts’ tab is - in Focus / Active / the top Tab – the macro works ok

 

BUT when another Tab (say Accounts) is - in Focus / Active / the top Tab – I can’t get the Macro to work. The Parts Tab IS NOT brought in to Focus / Active / the top Tab.

I have tried various combinations of ‘Window Activate’, ‘Window Maximize’, ‘Window Restore’, ‘Window Show’ to no avail.

 

Note: When another Tab (say Accounts) is - in Focus / Active / the top Tab – and I try to use the ‘Window Activate’ command - the Tab that I need (say Parts) IS NOT shown in the ‘Windows Title’ list.  Is this part of my problem?

 

SOLUTION

I’m obviously missing something - I’d be very grateful for some help with this.

Mike

 

 

Link to comment
Share on other sites

Look up keyboard shortcuts for Chrome.  When I Googled "keyboard shortcut to switch to a specific Chrome tab", I found that Ctrl-1 activates the first tab, Ctrl-2 activates the second, and so on.  So if your Parts tab is always the second one, instead of doing "Window Activate", use the Text Type command to "type" Ctrl-2.  Of course Chrome itself will have to be in focus to accept the keystrokes.  I don't know for sure that this will work for you, but it's worth a try. 

Link to comment
Share on other sites

Hello Mike.

 

I'm not a regular Chrome user but I just tried it with the shortcuts @rberq mentioned. Strangely Ctrl+1, Ctrl+3, Ctrl+4, etc all worked OK. But Ctrl+2 consistently did nothing. So in case you'd already been using that, avoid it by using Ctrl+1 followed by Ctrl+Tab. And brief research shows that similar Chrome shortcut problems are not rare.

 

The following macro worked consistently here:

 

// Assumes Chrome is open.
// Any of Chrome's tabs could currently be selected. But the window tiltle of all of them will include the string ' - Google Chrome'.
// Assumes Excel is open and active, with a cell in the Parts column selected.
// This macro will copy the selected part number and paste it into a text field of the page open in Tab#2 of Chrome.
Clipboard Copy
Window Activate: - Google Chrome
Wait for Window Title: - Google Chrome
// Select tab #2 by using Ctrl+1 folowed by Ctrl+Tab (to avoid the issue I described, if it's present for you too).
Text Type (Simulate Keystrokes): <CONTROL>1
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): <CONTROL><TAB>
Delay: 0.1 seconds
// Navigate with tabs or mouse clicks to the text target location.
Mouse Move: 434, 643 Relative to Current Window
Mouse Left Click
// Paste from clipboard.
Clipboard Paste

 

CODE (for pasting to Direct Editor):

 

<COMMENT Value="Assumes Chrome is open."/>
<COMMENT Value="Any of Chrome's tabs could currently be selected. But the window tiltle of all of them will include the string ' - Google Chrome'."/>
<COMMENT Value="Assumes Excel is open and active, with a cell in the Parts column selected."/>
<COMMENT Value="This macro will copy the selected part number and paste it into a text field of the page open in Tab#2 of Chrome."/>
<CLIPBOARD COPY/>
<WINDOW ACTIVATE Title="- Google Chrome" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<WAIT FOR WINDOW TITLE Title="- Google Chrome" Partial="TRUE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<COMMENT Value="Select tab #2 by using Ctrl+1 folowed by Ctrl+Tab (to avoid the issue I described, if it's present for you too)."/>
<TEXT TYPE Action="0" Text="<CONTROL>1"/>
<DELAY Flags="\x01" Time="0.1"/>
<TEXT TYPE Action="0" Text="<CONTROL><TAB>"/>
<DELAY Flags="\x01" Time="0.1"/>
<COMMENT Value="Navigate with tabs or mouse clicks to the text target location."/>
<MOUSE MOVE Option="\x02" X="434" Y="643" _PROMPT="0x000A"/>
<MOUSE LEFT CLICK/>
<COMMENT Value="Paste from clipboard."/>
<CLIPBOARD PASTE/>

 

 

Otherwise, can you post your commands and code (using the code tool <>) which should help us look closer at your issue.

 

Terry

MacroTestScreenshot-1.jpg

Link to comment
Share on other sites

  • 2 weeks later...

One of the first things I do with a new program macro is research all the keyboard shortcuts. 

Also Command line options and import/export options. Often you can enter a lot of data that way without a complex macro but still use MEP to generate an import file or process an export. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...