How to Deliberately Set Focus on An Application

Hello, been practicing creating automation which navigates though web pages using shortcuts (based on the practice rules I made).

This is what I want to do (look for for a company’s CEO name from Google):

  1. Open browser for the first time
  2. For each of data row, google the CEO name by:
    • Send Hotkey Ctrl + L to access address bar
    • Scrape data
      repeat, and repeat no 2.

Problem:
When I want to confirm the result (CEO name) I use Message Box. But after the Message Box popped up and I closed it, the shortcuts failed (the Ctrl + L one). It seems like though the application is still visible on the screen, it is in the background and the focus is not on it. Well I could just use Write Line or using another workaround, but since this is practice, is there any way to force focus on a certain app on Windows?

Just notes, yes it its the same practice I made in when I posted in How to Access Google I’m Feeling Lucky From Browser Address Bar.

1 Like

@whyyouandi, possibly you can try Activate Window activity just to bring your running application background to foreground that sets the focus to the application which in turn your hot key operation works better in this case !

Hope it helps !

Regards,
Dominic :slight_smile:

1 Like

Hi,
Try these.

  • make sure your typing lower case l not capital L in Sendhotkey. OR
  • keep some delay after message box pop up. OR
  • To focus on the window you can indicate on the screen in SendHot key activity.
3 Likes

Thank you for your advise.

The Sendhotkey was in lower case but I thought it would be difficult to read in forum but forgot to mention it. But it works well with Indicate on Screen on Hotkey activity. Such a simple but working answer! Thank you.

2 Likes