Hi every1,
I have a script where I'd like to get the x/y coordinates of the GUI itself (relative to the screen/CoordMode pixel); I researched all the usual stuff (GuiControlGet, whether a GUI could have an output variable, etc.) and can't seem to find a way to get this info. The GUI doesn't have a caption so idk if WinGet would do it... any ideas? Thanks.
SOLVED: Getting info about the GUI itself
SOLVED: Getting info about the GUI itself
Last edited by Miguel7 on 10 Sep 2014, 16:28, edited 1 time in total.
Re: Getting info about the GUI itself
- Gui Option: Gui +HwndOutputVar
- Gui, New:Gui, Name:New
If Title is omitted, the script's file name is used. - Variables and Expressions \ Built-in Variables \ GUI Windows and Menu Bars: A_Gui, A_GuiWidth
我为人人,人人为己?
Re: Getting info about the GUI itself
Great. I've been using global variables for the time being, but then I read something about global variables causing performance issues, so I was just wondering whether there was a better way. Looks like there are some built-in variables to look into. Thanks.
Re: Getting info about the GUI itself
Use WinGetPos like for any other window, but either use Gui +LastFound and omit WinTitle, or use +HwndOutputVar and ahk_id %OutputVar%.
Re: Getting info about the GUI itself
Okay, so I've continued to stumble around this a bit more, and still with no luck. There are some built-in variables for GUIs but none that give coordinates. Currently researching GuiControlGet Pos, though it doesn't look like that'll help. So I'm goin' a little rackin' what's left of my brain trying to cook up new approaches to get what I thought would be simple info... has anyone else ever tried to get this information? Or even the coordinates of a GUI control (relative to the screen)? Thanks again.
Re: Getting info about the GUI itself
lol did you read Lexikos' post?
http://www.autohotkey.com/docs/commands/WinGetPos.htm
WinGetPos will get the position of any window
your only problem is that your Gui has no caption, so you need to use one of the the solutions already given for the WinTitle parameter
http://www.autohotkey.com/docs/commands/WinGetPos.htm
WinGetPos will get the position of any window
your only problem is that your Gui has no caption, so you need to use one of the the solutions already given for the WinTitle parameter
Code: Select all
Gui +HwndMyGuiHWND
Gui, Show, w400 h400
WinGetPos, x, y, w, h, ahk_id %MyGuiHWND%
MsgBox, Gui info`nx=%x%`ny=%y%`nw=%w%`nh=%h%
GuiClose:
ExitApp
return
Re: Getting info about the GUI itself
I think we were writing this at the same time
As always, thanks Lexicos! Thanks to every1 else who contributed to this answer too. This did it!
As always, thanks Lexicos! Thanks to every1 else who contributed to this answer too. This did it!
Re: SOLVED: Getting info about the GUI itself
You're welcome, Miguel8.
Who is online
Users browsing this forum: Google [Bot], MSN [Bot] and 122 guests