Skip to content

Get the currently used icon in window. #300

@EliosMax

Description

@EliosMax

Hello, I need to get the currently used icon(bitmap) in windows. Before, I used Pyhon and this function works:

Get cursor icon as bitmap, with ability to save it or get pixels from it

def get_icon_mouse(self):
	info = win32gui.GetCursorInfo()
	if info[1] != 0:
		gdc = win32gui.GetDC(0)
		hdc = win32ui.CreateDCFromHandle(gdc)
		hbmp = win32ui.CreateBitmap()
		hbmp.CreateCompatibleBitmap(hdc, self.ico_height, self.ico_width)
		hdc = hdc.CreateCompatibleDC()
		hdc.SelectObject(hbmp)
		hdc.DrawIcon((0, 0), info[1])
		signedIntsArray = hbmp.GetBitmapBits(True)
		img = np.fromstring(signedIntsArray, dtype='uint8')
		img.shape = (self.ico_height, self.ico_width, 4)

		# hbmp.SaveBitmapFile(ico, 'icon.bmp')
		# win32gui.DestroyIcon(info[1])

		win32gui.DeleteObject(hbmp.GetHandle())
		win32gui.ReleaseDC(0, gdc)
		hdc.DeleteDC()
		self.error_get_icon = 0
		return img
	else:
		return self.error_image

icon

Could someone help me write this code in Golang?
Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions