lxn / win

A Windows API wrapper package for the Go Programming Language
Other
1.19k stars 312 forks source link

Get cursor icon as bitmap, with ability to save it. #115

Open EliosMax opened 3 years ago

EliosMax commented 3 years ago

Hello i have code written in python, someone could help me write it in golang? I'm fresh in go, thank you.

import win32gui, win32ui

info = win32gui.GetCursorInfo()
hdc = win32ui.CreateDCFromHandle(win32gui.GetDC(0))
hbmp = win32ui.CreateBitmap()
hbmp.CreateCompatibleBitmap(hdc, 30, 30)
hdc = hdc.CreateCompatibleDC()
hdc.SelectObject(hbmp)
hdc.DrawIcon((0, 0), info[1])
hbmp.SaveBitmapFile(hdc, 'icon.bmp')
win32gui.DeleteObject(hbmp.GetHandle())
hdc.DeleteDC()