Skip to content

Mouse Move slow and blocks main thread : Win11 #714

@andrewfstratton

Description

@andrewfstratton

I am using the Move method to move the mouse pointer and I am seeing long main thread delays, e.g. 260ms, even 400ms,.

I have checked the following :

  • running with the same location as the current mouse coordinates - this gives no (extra) delay
  • just adding one pixel x (move) to the current location - this has long delays, e.g. 260ms

Separating the code out from my application, there is an interval function which mainly contains :

var last_time time.Time = time.Now()

func interval(move movePair) { // note: ignoring update to movePair
	new_time := time.Now()
	time_diff := new_time.Sub(last_time)
	last_time = new_time
	fmt.Println(time_diff)
...
        current_x, current_y := robotgo.Location()
        robotgo.Move(current_x+1, current_y, robotgo.GetMainId()) 
}

This is called through a goroutine containing :

	for {
		select {
		case new_move := <-moves: // get an update from a channel
		// do some update to move_pair
		case <-time.After(INTERVAL): // INTERVAL is 33ms
			interval(move_pair)
		}
	}

Note: I tried putting the robotogo move in a go routine but this made no noticeable difference - the main thread still delays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions