### `pyautogui.move()` 用法
1. 基本用法:
```python
pyautogui.move(x, y)
```
- 将鼠标指针从当前坐标移动到相对坐标 (`x`, `y`) 的位置。
2. 相对移动:
```python
pyautogui.move(400, 0) # 向右移动 400 像素
pyautogui.move(0, 100) # 向下移动 100 像素
```
3. 绝对移动:
```python
pyautogui.moveTo(x, y)
```
- 将鼠标指针移动到屏幕上的绝对坐标 (`x`, `y`)。
4. 移动韶光:
```python
pyautogui.move(x, y, duration=1) # 在 1 秒内移动
```
- `duration` 参数指定移动的韶光,使移动更加平滑。
5. 移动到某个元素:
- 可以结合 `pyautogui.locateOnScreen()` 利用,先找到元素位置,再移动到该位置。
```python
button_location = pyautogui.locateOnScreen('button.png')
if button_location:
pyautogui.move(button_location[0], button_location[1]) # 移动到按钮位置
```
6. 利用相对位置:
```python
pyautogui.moveTo(x, y, duration=1) # 移动到绝对位置
pyautogui.move(0, 50, duration=0.5) # 从当前位置向下移动 50 像素
```
### 其他干系函数
- `moveRel()`:
```python
pyautogui.moveRel(xOffset, yOffset, duration)
```
- 类似于 `move()`,但 `xOffset` 和 `yOffset` 是相对当前鼠标位置的偏移量。
- `click()`:
```python
pyautogui.click(x, y)
```
- 在指定位置点击鼠标,可以先用 `move()` 移动到该位置再点击。
### 总结
`pyautogui.move()` 供应了多种移动鼠标的方法,可以根据须要调度移动的办法、韶光和目标位置。利用这些功能可以实现更灵巧的自动化操作。