Need help with WinGetTitle

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
alclarkey
Posts: 8
Joined: 25 Apr 2019, 15:53

Need help with WinGetTitle

16 Jan 2023, 19:21

[Mod edit: Topic moved to v2 help.]

I'm trying to get the window title of the active window, but my script returns nothing. What am I doing wrong?

Code: Select all

#UseHook 1
#MaxThreadsPerHotkey 4

global windowtitle := ""

f3::
{
global
windowtitle := WinGetTitle("A")
}

f4:: {
global
MsgBox windowtitle
}
User avatar
boiler
Posts: 17209
Joined: 21 Dec 2014, 02:44

Re: Need help with WinGetTitle

16 Jan 2023, 20:35

What you posted would not work in v1, which is the part of the forum where you posted and what your past posts look like you use. WinGetTitle is not a function in v1. It's a command. Look at the docs -- the proper version of the docs for the version you're using -- and follow the syntax shown.
User avatar
mikeyww
Posts: 27192
Joined: 09 Sep 2014, 18:38

Re: Need help with WinGetTitle

16 Jan 2023, 21:19

But OK in v2 if you're trying that.

Code: Select all

#Requires AutoHotkey v2.0
windowtitle := ""
F4::MsgBox windowtitle
F3:: {
 Global windowtitle := WinGetTitle("A")
 SoundBeep 1500
}
Some windows may not have a window title.
alclarkey
Posts: 8
Joined: 25 Apr 2019, 15:53

Re: Need help with WinGetTitle

17 Jan 2023, 17:32

I'm using V2 and I can't get a title from anything.
alclarkey
Posts: 8
Joined: 25 Apr 2019, 15:53

Re: Need help with WinGetTitle

17 Jan 2023, 17:45

Ok, solved it. Problem was the scope. Initialized the variable I was trying to use as a global inside my hotkey, and it worked.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: gekunfei, RussF, WarlordAkamu67 and 39 guests