w32 icon indicating copy to clipboard operation
w32 copied to clipboard

user32.go:1039:10: cannot use flag (type uint32) as type uintptr in argument to procRedrawWindow.Call

Open Kareny opened this issue 7 years ago • 7 comments

issues found when compiling. Any ideas for how to fix this?

Kareny avatar Jun 28 '18 00:06 Kareny

the solution is the same as #80. Use this version: https://github.com/TheTitanrain/w32

tecnologer avatar Jul 11 '18 19:07 tecnologer

I have an actively maintained fork which I use to create both 32 and 64 bit applications, both for work and for private projects. It has diverged quite a bit from this original fork. You could give it a try instead:

https://github.com/gonutz/w32

gonutz avatar Apr 19 '20 11:04 gonutz

@gonutz I have gone through your repo, could you please write a README.md file with the basic step by step implementation with few example how we can use it.

mateors avatar Oct 29 '20 11:10 mateors

@gonutz can you guide me how can i get a window handle from a process id? basically i want to grab the running browser url. currently i get the process list and process id but no idea how to get the job done. i have read Microsofts windows api guideline but its too huge that i cant find any option. i am struggling since last week.

mateors avatar Oct 29 '20 11:10 mateors

@mateors I think that is a great idea, I will think of some examples with common tasks to guide people through some very basic Windows API concepts and then put links to MSDN in the readme as well. Since the Windows API is huge there could be thousands of samples but the real documentation is that of the WinAPI itself, which is at MSDN.

As to your concrete problem, I usually use the EnumWindows for these things and then just scan the window class or window title for what I want. This little piece of code:

package main

import (
	"fmt"
	"github.com/gonutz/w32"
)

func main() {
	w32.EnumWindows(func(w w32.HWND) bool {
		fmt.Println(w32.GetWindowText(w))
		return true
	})
}

will print a bunch of window titles, one of which reads

user32.go:1039:10: cannot use flag (type uint32) as type uintptr in argument to procRedrawWindow.Call · Issue #83 · AllenDang/w32 - Mozilla Firefox

which ends in Mozilla Firefox. This gives me the HWND window handle of the browser. Unfortunately browsers are typically implemented with custom controls, see this stackoverflow question and answer. This means you cannot just call EnumChildWindows and search for URLs but instead have to do something more involved. For this I do not know the solution. If you find it, please share it here, I would be interested as I have tried something like this in the past but then chose a different route eventually.

gonutz avatar Oct 29 '20 14:10 gonutz

@gonutz Thank your for your quick response. I am working on it, if i get any solution definitely share with you.

could you please give me an example of EnumProcesses() ? how i get process list using this func? Also don't forget to share your email.

mateors avatar Oct 29 '20 15:10 mateors

Alright, I just updated the API of EnumProcesses and added a new function EnumAllProcesses. Please pull the latest changes and just call EnumAllProcesses to get all process IDs in the system.

gonutz avatar Oct 29 '20 20:10 gonutz