SOLVED: Getting info about the GUI itself

Get help with using AutoHotkey and its commands and hotkeys
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

SOLVED: Getting info about the GUI itself

09 Sep 2014, 08:52

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. :)
Last edited by Miguel7 on 10 Sep 2014, 16:28, edited 1 time in total.
User avatar
RobertL
Posts: 540
Joined: 18 Jan 2014, 01:14
Location: China

Re: Getting info about the GUI itself

09 Sep 2014, 09:59

  • 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
Hope it can help.
我为人人,人人为己?
Guest

Re: Getting info about the GUI itself

09 Sep 2014, 15:44

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.
lexikos
Posts: 6855
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Getting info about the GUI itself

09 Sep 2014, 21:37

Use WinGetPos like for any other window, but either use Gui +LastFound and omit WinTitle, or use +HwndOutputVar and ahk_id %OutputVar%.
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Getting info about the GUI itself

10 Sep 2014, 15:46

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 :crazy: 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.
guest3456
Posts: 3108
Joined: 09 Oct 2013, 10:31

Re: Getting info about the GUI itself

10 Sep 2014, 15:56

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

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

Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: Getting info about the GUI itself

10 Sep 2014, 16:27

I think we were writing this at the same time :lol:

As always, thanks Lexicos! Thanks to every1 else who contributed to this answer too. This did it!
Lexicos
Posts: 1
Joined: 11 Sep 2014, 06:14

Re: SOLVED: Getting info about the GUI itself

11 Sep 2014, 06:19

You're welcome, Miguel8. :P

Return to “Ask For Help”

Who is online

Users browsing this forum: Bad husband, Bing [Bot], boiler, malcev, tee_rock and 132 guests