WinGetTitle Topic is solved
-
- Posts: 14
- Joined: 09 Sep 2023, 11:15
Re: WinGetTitle
Same error with WinGetPos...
Checking for previous posts about this issue... and found my own post quoted! Thanks for putting this in bug reports
Checking for previous posts about this issue... and found my own post quoted! Thanks for putting this in bug reports
Re: WinGetTitle
What makes you think it is a bug? If there is no foreground window (the system function GetForegroundWindow returns 0), or the foreground window cannot be "found" due to DetectHiddenWindows, there will be no target window. Hence the error. WinExist("A") should be 0 in these cases.
@andymbody It does not matter what the title is. There is no such thing as a window with no title, but sometimes the title is not visible, or has a length of 0.
@andymbody It does not matter what the title is. There is no such thing as a window with no title, but sometimes the title is not visible, or has a length of 0.
Re: WinGetTitle
You don't avoid an exception that is thrown. You catch it, or you avoid the condition that causes the exception to be thrown, so that it isn't thrown.
As I said, WinExist("A") should return 0 in those cases.
As I said, WinExist("A") should return 0 in those cases.
-
- Posts: 14
- Joined: 09 Sep 2023, 11:15
Re: WinGetTitle
It seems like a bug because V1 did not behave this way.
I'll use a lib to handle the V2 window title oddities.
I'll use a lib to handle the V2 window title oddities.
Code: Select all
#Requires AutoHotkey >2
#Singleinstance force
wX1:=0,wY1:=0,wXd:=0,wYd:=0
while 1 {
wGetPos(&wX1, &wY1, &wXd, &wYd, "A")
tooltip(wGetTitle("A") '`n' wX1 "," wY1 "`n" wXd "," wYd "`n" a_tickcount)
sleep 100
}
esc::exitapp
;=============================================================================
; wGetTitle
;=============================================================================
wGetTitle(title) { ; ahk2 has issue with getting title for taskbar when switching apps.
try return WinGetTitle(title)
catch
return ""
}
;=============================================================================
; wGetPos
;=============================================================================
wGetPos(&pX1, &pY1, &pXd, &pYd, title) {
try return WinGetPos(&pX1, &pY1, &pXd, &pYd, title)
catch {
pX1:=0,pY1:=0,pXd:=0,pYd:=0
return 0
}
}
Re: WinGetTitle Topic is solved
What do you think is the point of changing the version number? Of course it behaves differently.
WinGetTitle v1 wrote:If there is no matching window, OutputVar is made blank.
This is part of overall changes to error handling. v1 has a tendency to ignore errors, return blank values or set ErrorLevel; it is inconsistent. v2 throws errors more consistently.WinGetTitle v2 wrote:A TargetError is thrown if the window could not be found.
Who is online
Users browsing this forum: No registered users and 16 guests