0

I am using a simple script to run a google/wikipedia/etc search using a hotkey, unfortunately after the search result appears in a new tab, I have to click because the tab is not on focus, although the browser windows is on focus. I tried to add a WinActivate but it's not working. This script used to work as expected before a new OS installation. Why is this script making lose focus on the browser?

Here's the script

^+g:: 
{
Send, ^c
sleep 200
Run, https://www.google.com/search?hl=en&q=%Clipboard% 
sleep 50
WinActivate, ahk_exe waterfox.exe
}
Return
Spyre
  • 2,234
  • 1
  • 4
  • 24
Herman Toothrot
  • 1,463
  • 3
  • 23
  • 53

1 Answers1

1

I don't know why, but it looks like increasing the delay between the Run and the WinActivate seems to fix it.

^+g:: 
{
Send, ^c
sleep 200
Run, https://www.google.com/search?hl=en&q=%Clipboard% 
sleep 500 ;Up from 50, you might be able to fine-tune this number based on your computer's speed
WinActivate, ahk_exe waterfox.exe
}
Spyre
  • 2,234
  • 1
  • 4
  • 24
  • Thanks that solves the problem, however I still find it puzzling that WinActivate was never needed in this kind of script, as you can also see in the autohotkey forum. – Herman Toothrot Oct 27 '20 at 14:02
  • 1
    Yeah, @HermanToothrot, I had to install the Waterfox web browser in order to test this and it looks like it doesn't like to make itself the active window upon launch (which I would think might be good for automating some sort of web-based task in the background) – Spyre Oct 27 '20 at 14:05
  • 1
    Thank you for checking that, so it looks like it's a Waterfox-related behavior. – Herman Toothrot Oct 27 '20 at 17:05