如何使用AutoIT右键单击目录中存在的文件? [英] How to right click on a file present in a directory using AutoIT?

查看:254
本文介绍了如何使用AutoIT右键单击目录中存在的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试模拟自动在Windows资源管理器中的特定文件或文件夹上单击鼠标右键的功能,这是我编写的用于模拟该功能的代码段:

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:\Windows\addins"

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 :

"C:\ Program Files(x86)\ AutoIt3 \ SciTE .. \ autoit3.exe"/ErrorStdOut"C:\ Users \ asablok \ Desktop \ My Documents \ Calculator.au3"
"C:\ Users \ asablok \ Desktop \ My Documents \ Calculator.au3"(15):==> 下标用于不可访问的变量.:MouseClick("Right", $ aClient [0] + $ aPos [0] + 4,$ aClient [1] + $ aPos [1] + 4) MouseClick("Right",$ aClient ^错误 退出代码:1时间:1.593

"C:\Program Files (x86)\AutoIt3\SciTE..\autoit3.exe" /ErrorStdOut "C:\Users\asablok\Desktop\My Documents\Calculator.au3"
"C:\Users\asablok\Desktop\My Documents\Calculator.au3" (15) : ==> Subscript used on non-accessible variable.: MouseClick("Right", $aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4) MouseClick("Right", $aClient^ ERROR Exit code: 1 Time: 1.593

任何人都可以向我建议一种解决方法,以解决如何使用AutoIT模拟鼠标右键单击的问题.

Can anyone suggest me a workaround as to how to address this problem of simulating right clicking using AutoIT.

推荐答案

尝试一下:

#include<GUIListView.au3>

Local $filepath = "C:\Windows\addins"

Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)

Sleep(1000)

Send('+{F10}')

这篇关于如何使用AutoIT右键单击目录中存在的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆