右键单击​​目录中的文件

右键单击​​目录中的文件

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

问题描述

我正在尝试模拟在 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 右键单击​​目录中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:49