问题描述
我正在尝试模拟在 Windows 资源管理器中的特定文件或文件夹上自动右键单击鼠标的功能,这是我编写的用于模拟的代码片段:
#include本地 $filepath = "C:Windowsaddins"本地 $iPid = Run("explorer.exe/n,/e,/select," & $filepath)ProcessWait($iPid)睡眠(1000)本地 $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")本地 $aClient = WinGetPos($hList)本地 $aPos = _GUICtrlListView_GetItemPosition($hList, _GUICtrlListView_GetSelectedIndices($hList))鼠标点击(右",$aClient[0] + $aPos[0] + 4,$aClient[1] + $aPos[1] + 4)
但这会返回一个错误提示:
"C:Program Files (x86)AutoIt3SciTE..autoit3.exe"/ErrorStdOut "C:UsersasablokDesktopMy DocumentsCalculator.au3"
C:UsersasablokDesktopMy DocumentsCalculator.au3"(15):==>用于不可访问变量的下标.:MouseClick("Right",$aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4)鼠标点击(右",$aClient^ 错误退出代码:1 时间:1.593
谁能建议我解决这个使用 AutoIT 模拟右键单击的问题的解决方法.
试试这个:
#include本地 $filepath = "C:Windowsaddins"本地 $iPid = Run("explorer.exe/n,/e,/select," & $filepath)ProcessWait($iPid)睡眠(1000)发送('+{F10}')
I am trying to simulate the functionality of automating right click of a mouse on a specific file or a folder in windows explorer and this is the code snippet I have written to simulate that :
#include<GUIListView.au3>
Local $filepath = "C:Windowsaddins"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
Local $aClient = WinGetPos($hList)
Local $aPos = _GUICtrlListView_GetItemPosition($hList, _GUICtrlListView_GetSelectedIndices($hList))
MouseClick("Right", $aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4)
but this returns me an error saying this :
Can anyone suggest me a workaround as to how to address this problem of simulating right clicking using AutoIT.
Try this:
#include<GUIListView.au3>
Local $filepath = "C:Windowsaddins"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Send('+{F10}')
这篇关于如何使用 AutoIT 右键单击目录中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!