AllenDang / w32

A wrapper of windows apis for the Go Programming Language.
Other
766 stars 247 forks source link

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

Open Kareny opened 6 years ago

Kareny commented 6 years ago

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

tecnologer commented 6 years ago

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

gonutz commented 4 years ago

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

mateors commented 4 years ago

@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 commented 4 years ago

@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.

gonutz commented 4 years ago

@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.

mateors commented 4 years ago

@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.

gonutz commented 4 years ago

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.