@@ -95,55 +95,64 @@ def reset_hid(self):
9595 """
9696 self .call ("reset_hid" )
9797
98- def mouse_move_abs (self , x : int , y : int ):
98+ def mouse_move_abs (self , x : float , y : float ):
9999 """
100100 Move mouse to absolute coordinates
101101
102102 Args:
103- x: X coordinate (0-65535, scaled to screen resolution )
104- y: Y coordinate (0-65535, scaled to screen resolution )
103+ x: X coordinate (0.0 to 1.0, where 0.0 is left and 1.0 is right )
104+ y: Y coordinate (0.0 to 1.0, where 0.0 is top and 1.0 is bottom )
105105
106106 Example::
107107
108- # Move to center of screen (assuming 1920x1080)
109- hid.mouse_move_abs(32768, 32768)
108+ # Move to center of screen
109+ hid.mouse_move_abs(0.5, 0.5)
110+
111+ # Move to top-left corner
112+ hid.mouse_move_abs(0.0, 0.0)
113+
114+ # Move to bottom-right corner
115+ hid.mouse_move_abs(1.0, 1.0)
110116 """
111117 self .call ("mouse_move_abs" , x , y )
112118
113- def mouse_move_rel (self , dx : int , dy : int ):
119+ def mouse_move_rel (self , dx : float , dy : float ):
114120 """
115121 Move mouse relative to current position
116122
117123 Args:
118- dx: X movement delta (-127 to 127 )
119- dy: Y movement delta (-127 to 127 )
124+ dx: X movement delta (-1.0 to 1.0, where 1.0 is full screen width )
125+ dy: Y movement delta (-1.0 to 1.0, where 1.0 is full screen height )
120126
121127 Example::
122128
123- # Move right and down
124- hid.mouse_move_rel(50, 50)
129+ # Move right by 10% of screen width and down by 10%
130+ hid.mouse_move_rel(0.1, 0.1)
131+
132+ # Move left by 20%
133+ hid.mouse_move_rel(-0.2, 0.0)
125134 """
126135 self .call ("mouse_move_rel" , dx , dy )
127136
128- def mouse_click (self , button : str = "left" , x : int | None = None , y : int | None = None ):
137+ def mouse_click (self , button : str = "left" , x : float | None = None , y : float | None = None ):
129138 """
130139 Click a mouse button
131140
132141 Args:
133142 button: Mouse button to click ("left", "right", "middle")
134- x: Optional X coordinate for absolute positioning before click
135- y: Optional Y coordinate for absolute positioning before click
143+ x: Optional X coordinate (0.0 to 1.0) for absolute positioning before click
144+ y: Optional Y coordinate (0.0 to 1.0) for absolute positioning before click
136145
137146 Example::
138147
139148 # Click at current position
140149 hid.mouse_click("left")
141150
142- # Click at specific coordinates
143- hid.mouse_click("left", 32768, 32768 )
151+ # Click at center of screen
152+ hid.mouse_click("left", 0.5, 0.5 )
144153
145- # Right-click
146- hid.mouse_click("right")
154+ # Right-click at specific location
155+ hid.mouse_click("right", 0.75, 0.25 )
147156 """
148157 if x is not None and y is not None :
149158 self .call ("mouse_click" , button , x , y )
@@ -204,25 +213,25 @@ def mouse():
204213 pass
205214
206215 @mouse .command ()
207- @click .argument ("x" , type = int )
208- @click .argument ("y" , type = int )
216+ @click .argument ("x" , type = float )
217+ @click .argument ("y" , type = float )
209218 def move (x , y ):
210- """Move mouse to absolute coordinates (0-65535 )"""
219+ """Move mouse to absolute coordinates (0.0-1.0 )"""
211220 self .mouse_move_abs (x , y )
212221 click .echo (f"Mouse moved to ({ x } , { y } )" )
213222
214223 @mouse .command ()
215- @click .argument ("dx" , type = int )
216- @click .argument ("dy" , type = int )
224+ @click .argument ("dx" , type = float )
225+ @click .argument ("dy" , type = float )
217226 def move_rel (dx , dy ):
218- """Move mouse by relative offset (-127 to 127 )"""
227+ """Move mouse by relative offset (-1.0 to 1.0, where 1.0 is full screen )"""
219228 self .mouse_move_rel (dx , dy )
220229 click .echo (f"Mouse moved by ({ dx } , { dy } )" )
221230
222231 @mouse .command (name = "click" )
223232 @click .option ("--button" , "-b" , default = "left" , type = click .Choice (["left" , "right" , "middle" ]))
224- @click .option ("--x" , type = int , default = None , help = "Optional X coordinate" )
225- @click .option ("--y" , type = int , default = None , help = "Optional Y coordinate" )
233+ @click .option ("--x" , type = float , default = None , help = "Optional X coordinate (0.0-1.0) " )
234+ @click .option ("--y" , type = float , default = None , help = "Optional Y coordinate (0.0-1.0) " )
226235 def mouse_click_cmd (button , x , y ):
227236 """Click a mouse button"""
228237 self .mouse_click (button , x , y )
0 commit comments