robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

cannot use ps.Pids() (value of type []int) as []int32 value in return statement

Open historydev opened this issue 1 year ago • 11 comments

  • Robotgo version (or commit ref): 1.0.0-rc1
  • Go version: 1.20.3
  • Gcc version: gcc.exe (tdm64-1) 10.3.0
  • Operating system and bit: win11/64
  • Resolution:
  • Can you reproduce the bug at Examples:
    • [ ] Yes (provide example code)
    • [ ] No
    • [ ] Not relevant
  • Provide example code:
package main

import (
	"github.com/go-vgo/robotgo"
)

func main() {
	robotgo.MouseSleep = 100
}

  • Log gist:

First error i have this:

hook.go:98:17: invalid operation: geve == 0 (mismatched types bool and untyped int)
ps.go:23:9: cannot use ps.Pids() (value of type []int) as []int32 value in return statement

Second error after change robotgo version on 1.0.0-beta1 have only this:

ps.go:23:9: cannot use ps.Pids() (value of type []int) as []int32 value in return statement

historydev avatar Apr 30 '23 13:04 historydev

The same here, and even more. I guess this is related to the Windows compiler (gcc or something)

go: upgraded github.com/go-vgo/robotgo v0.100.10 => v1.0.0-beta1 \golang\mouseClick> go run .\cmd\main.go

..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:23:9: cannot use ps.Pids() (value of type []int) as []int32 value in return statement
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:28:22: cannot use pid (variable of type int32) as int value in argument to ps.PidExists
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:37:4: cannot use nps[i].Pid (variable of type int) as int32 value in struct literal
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:49:21: cannot use pid (variable of type int32) as int value in argument to ps.FindName
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:61:9: cannot use ps.FindIds(name) (value of type []int) as []int32 value in return statement        
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:66:21: cannot use pid (variable of type int32) as int value in argument to ps.FindPath
..\..\go\src\pkg\mod\github.com\go-vgo\[email protected]\ps.go:76:17: cannot use pid (variable of type int32) as int value in argument to ps.Kill

iuli-dercaci avatar May 01 '23 13:05 iuli-dercaci

i have same error

parsibox avatar Jul 02 '23 05:07 parsibox

I'm getting the same. Should I rollback to an old version?

tfmeneses avatar Aug 04 '23 19:08 tfmeneses

Same. As far as I can tell, robotgo is completely unusable on Windows from a fresh install.

drgrib avatar Aug 06 '23 13:08 drgrib

For anyone looking for a workaround on Windows, I ended up using AutoHotkey. It certainly leaves a lot to be desired in terms of syntax and data structures but I was able to accomplish what I needed with a few Map() data structures.

drgrib avatar Aug 08 '23 17:08 drgrib

Because the robotgo version does not match its dependency versions. Run go mod graph check it.

Re download the go mod dependencies will solve it.

Just like this:

  1. Update robotgo go get -u github.com/go-vgo/robotgo.
  2. Clear go.mod file second require.
  3. Then run go mod tidy.
module tests

go 1.18

require (
	github.com/go-vgo/robotgo v1.0.0-rc1.0.20230706172004-af321105215d
)

- require (
- 	github.com/vcaesar/gops v0.30.1 // indirect
- 	github.com/vcaesar/imgo v0.30.2 // indirect
- 	github.com/vcaesar/keycode v0.10.0 // indirect
- 	github.com/vcaesar/tt v0.20.0 // indirect
- 	...
- )

wilon avatar Aug 09 '23 01:08 wilon

@wilon This isn't for go 1.18. This is for people running go 1.20+ on Windows.

We have to use:

go get -u github.com/go-vgo/[email protected]

Or otherwise we get this issue documented in the OPs post:

hook.go:98:17: invalid operation: geve == 0 (mismatched types bool and untyped int)

But using the beta causes the second issue in the OPs post:

ps.go:23:9: cannot use ps.Pids() (value of type []int) as []int32 value in return statement

I've tried to manually set my go.mod file to use go 1.15 but this seems to be an issue with the go 1.20 base installation I have.

drgrib avatar Aug 09 '23 16:08 drgrib

It doesn't matter which go version, try execute steps 2 and 3.

wilon avatar Aug 11 '23 00:08 wilon

I don't have the second require in my go.mod file, so step 2 is not possible.

drgrib avatar Aug 12 '23 23:08 drgrib

I don't have the second require in my go.mod file, so step 2 is not possible.

Run go mod graph check the dependencies, then find out the mismatching package, reinstall it. Or remove the go.mod and reinstall all dependencies.

wilon avatar Aug 15 '23 01:08 wilon

Thanks @wilon. Just removing whatever was in my second require (even though it didn't match what you wrote) and running go mod tidy worked. It is really strange to me that these issues pop up on a fresh install but it was likely because I didn't start with the beta but instead switched to it after trying the non-beta.

drgrib avatar Aug 15 '23 19:08 drgrib