x/sys/windows: error among CGO OR golang.org/x/sys/windows OR syscall #54188
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH=amd64
GOOS=windows
go env
OutputWhat did you do?
my code using syscall OR sys/windows :
var (
user32, _ = windows.LoadDLL("user32.dll")
sendInputProc = user32.MustFindProc("SendInput")
getInfoProc = user32.MustFindProc("GetMessageExtraInfo")
)
func scrollTest(scroll int) {
type mouseInput struct {
DwFlags uint32
Time uint32
MouseData uint32
Dx int32
Dy int32
DwExtraInfo uintptr
}
type Input struct {
InputType uint32
Mi mouseInput
}
x, y := robotgo.GetMousePos()
} // a code to simulate mouse wheel rotation.
I also used w32 wrapper by AllenDang for some constant, and I have make sure that these constant are the same value as the ones in win32api. This code is able to run, and able to scroll my mouse. However, we should focus on the type of
MouseData
, it is uint type, means the value should not be negative. However, in win32api, it is a DWORD type value ,which means it is a int32 type in golang. The positive or negative of the value means the mouse wheel rotate towards user or forwards user. When I try to change the type into int32, the code seems not correct. I can compile and run it, but this code will leads to an unexpected screen lock. When I run the code, I observed the screen scrolls as expected, and then my screen shutdown and my computer seems to sleep. When I awake it, I found the code run successfully without error. I think this case may be similar to #31685, is theSendInput
dll function cause the accident?Then here is my CGO code, I think there may be something wrong with syscall or windows, so I turned to CGO.
UINT ScrollMouse(int scroll)
{
INPUT input;
POINT pos;
GetCursorPos(&pos);
}
*/
import "C"
Here is my code, which also leads to the same result. The code run successfully and scroll successfully but my computer sleep again, without any error.
Finally, I have to use the os/exec to run an exe file directly. And the code is just same as the one in CGO, I succeed this time. Why does the syscall leads to my computer sleeping? I confued if it is a bug or just my ignorance to something when coding. Sorry for that I have only one windows PC so I cannot try if it is the problem of my computer.
What did you expect to see?
The screen scrolled by the rotation input of mouse wheel which send by the go program.
What did you see instead?
The mouse wheel rotated, however, my computer sleep unexpected.
The text was updated successfully, but these errors were encountered: