Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[function] A_DefaultGui


  • Please log in to reply
2 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
You don't have the way to get the current default gui in AHK. This functions fills that hole.

A_DefaultGui() {
	if A_Gui !=
		return A_GUI

	Gui, +LastFound
	m := DllCall( "RegisterWindowMessage", Str, "GETDEFGUI")
	OnMessage(m, "A_DefaultGui")
	res := DllCall("SendMessageA", "uint",  WinExist(), "uint", m, "uint", 0, "uint", 0)
	OnMessage(m, "")
	return res
}

Example:

Gui,13: Default
	msgbox % A_DefaultGui()

Posted Image

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

This functions fills that hole.


I had a need for this many times. Very nice. Thanks. :)

Mystiq
  • Members
  • 83 posts
  • Last active: Nov 06 2011 07:07 PM
  • Joined: 08 Jan 2007
Hey!

This was exactly what i was looking for, thanks! I noticed that you can do the this without using Dll calls. I'm no expert but tested and it worked for me.

A_DefaultGui() {
	if (A_Gui)
		return A_GUI
	Gui, +LastFound
	WinGet, hwnd, ID
	Loop, 99 {
		Gui %A_Index%:+LastFoundExist
		if (hwnd = WinExist())
			return A_Index
	}
Return
}

Cheers!

P.S. I hope i didn't offend anyone digging up the archives. :oops: