WinActivate not activating by PID

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
illuzioner
Posts: 27
Joined: 07 Jun 2017, 13:50

WinActivate not activating by PID

24 Jun 2017, 12:42

I wrote a simple script that's supposed to let me mark the active window and jump back to it regardless of what other window is currently active.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
;#NoTrayIcon
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode 2

^Space::
;WinGet, myWnd, ID, A
WinGet, myWndPID, PID, A
MsgBox myWndPID = %myWndPID%
return

^!Space::
Sleep, 333
;MsgBox myWnd = %myWnd%`nID = %ID%
MsgBox myWndPID = %myWndPID%
WinActivate, ahk_pid myWndPID
return
However, while the Message boxes come up with the expected numbers, the WinActivate doesn't work.

What am I doing wrong?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: WinActivate not activating by PID

24 Jun 2017, 12:48

Try:

Code: Select all

WinActivate, ahk_pid %myWndPID%
illuzioner
Posts: 27
Joined: 07 Jun 2017, 13:50

Re: WinActivate not activating by PID

24 Jun 2017, 12:52

Freak. I forgot the % signs. D'oh!

Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Ineedhelplz, mikeyww and 195 guests