Wingetpos Problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Wingetpos Problem

15 Apr 2021, 01:50

Would someone please check this code:

Code: Select all

WingetPos, x,,w,, Zap
fileappend, %x%:%w%`n, xtest.txt
I'm getting a value of 593:733 in my text file but Window Spy gives the correct value of x1920 and w 1920 as the Zap window is maximized across my second monitor. What's wrong? Why the discrepancy? I have some applications like zap that start with dialogues that appear on my first monitor and when they appear I want to hide another window. I want to make that window reappear when the dialogues have gone. Cam anyone think of an approach for how to do this. Thanks.
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Wingetpos Problem

15 Apr 2021, 06:09

Try adding the window class to the WinTitle.

Splash screens usually have a different class from the main interface.

Would also add WinExist first, so that you can determine whether the window exists.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Wingetpos Problem

15 Apr 2021, 07:26

Thanks for the reply. Zap is the Window name of a Gui and just an example. I'm actually using ahk_id to identify the window. There are no spashscreens. If my code is correct then it means Window Spy is giving a different result fro Wingetpos and wingetpos is giving the wrong result.
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Wingetpos Problem

15 Apr 2021, 07:59

Try adding the window class to the WinTitle.

Does it work on your first monitor?

Code: Select all

Gui, Add, Text,, Test
Gui, Show,, Zap
If WinExist(wTitle := "Zap ahk_class AutoHotkeyGUI") {
 WinMaximize
 WinGetPos, x,, width
 MsgBox, 64, Dimensions, X        = %x%`nWidth = %width%
} Else MsgBox, 48, Error, Window not found.
ExitApp
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Wingetpos Problem

15 Apr 2021, 22:09

Thanks for the code, It gives me an x position of -3 and a width of 1926 which agrees with Window Spy. I'm going to investigate the issue more. I was monitoring my first monitor using a timer and saving the wingetpos results to the text file but they were not being updated as I moved windows around. I had the whole thing in a function so it must be something to do with that. Thanks again got your help.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen and 374 guests