I am very much a novice with scripting with AHK so apologies if I ask silly questions. I have searched the forums and tried a few things but nothing seems to be getting WinActivate working for me properly and consistently. My script is below and is very simple. All it is is a toggle to connect or disconnect to a VPN using a elevated shortcut (toggle pia) and then should return to the active window (kodi). The problem is that it does not consistently make kodi active again, and sometimes when it does it appears to press a button (not sure what button...). It appears to always make kodi seem to be on top, but it is not active (i.e. pressing buttons does nothing on the kodi screen).
Code: Select all
#SingleInstance force
^!g::
{
Run, toggle pia, C:\Program Files\pia_manager\noUAC\
}
Sleep, 500
{
WinActivate, kodi
}
Code: Select all
CoordMode, Mouse, Screen
MouseMove, (A_ScreenWidth // 1.05), (A_ScreenHeight // 1.05)
Sleep, 2500
Click
Cheers.