Need a minor explanation on different types of HWND Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
troufas
Posts: 80
Joined: 16 Jan 2021, 13:58

Need a minor explanation on different types of HWND

Post by troufas » 12 Aug 2022, 07:38

Hello,

I have a gui get its HWND stored through:

Code: Select all

gui, main:+hwndmainguihwnd
Then there is an OnMessage that checks when the gui is moved, and when the gui moves, it calls a function that does the following

Code: Select all

guimovement(wParam, lParam, msg, hwnd)
	{
		global mainguihwnd
			MsgBox % hwnd  ","  mainguihwnd
	}
I would expect the message box to display the same number twice but it doesn't. It always gives me one regular looking number (eg. 1312388) and one hex (eg. 0x140684)

Can some one please explain why is that and what each number represents?
Thanks!

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: Need a minor explanation on different types of HWND

Post by boiler » 12 Aug 2022, 07:52

Are those examples an actual pair that were shown, or did you make at least one of them up? It could be that they are both the same integer, represented once in decimal and once in hex (though your examples are not equal).

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Need a minor explanation on different types of HWND

Post by swagfag » 12 Aug 2022, 07:56

ure probably using SetFormat Hex somewhere(theres rarely a reason to)

troufas
Posts: 80
Joined: 16 Jan 2021, 13:58

Re: Need a minor explanation on different types of HWND

Post by troufas » 12 Aug 2022, 08:02

swagfag wrote:
12 Aug 2022, 07:56
ure probably using SetFormat Hex somewhere(theres rarely a reason to)
There is no such command in my code.
boiler wrote:
12 Aug 2022, 07:52
Are those examples an actual pair that were shown, or did you make at least one of them up? It could be that they are both the same integer, represented once in decimal and once in hex (though your examples are not equal).
I think they were, but to be sure, i'll re-do it. The numbers that it showed now are 1181392 and 0x1206d0

EDIT: So seeing as they are indeed the same number just in different format, the question becomes: is there a way to have them appear in the same format without needing to put one of them through a function to transform it, so that i can ultimately compare them easily?

User avatar
boiler
Posts: 16772
Joined: 21 Dec 2014, 02:44

Re: Need a minor explanation on different types of HWND  Topic is solved

Post by boiler » 12 Aug 2022, 17:00

You can compare them easily without converting them. Conversion is just for visualizing, and the actual value of an hwnd is virtually meaningless, so displaying the values really adds no value. You can find out if they're the same like this:

Code: Select all

MsgBox % (hwnd = mainguihwnd ? "same" : "different")
If you really want to convert them so they look the same, you can use Format().

Post Reply

Return to “Ask for Help (v1)”