如何使用AutoIT右键单击目录中存在的文件



我试图模拟在windows资源管理器中对特定文件或文件夹自动右键单击鼠标的功能,这是我为模拟而编写的代码片段:

#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)

但是这会返回一个错误说:

"C:Program Files (x86)AutoIt3SciTE.. AutoIt3 .exe"/ErrorStdOut "C:UsersasablokDesktopMy DocumentsCalculator.au3"
"C: 用户桌面 asablok 我的文档计算器。Au3 " (15): ==>在不可访问的变量上使用下标。: MouseClick("正确",美元aClient[0] + 13美元[0]+ 4,aClient美元[1]+ 13美元[1]+ 4)鼠标点击("右",$客户端^错误退出代码:1时间:1.593

有谁能给我一个建议,如何解决这个问题模拟右键点击使用AutoIT。

试试这个:

#include<GUIListView.au3>
Local $filepath = "C:Windowsaddins"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Send('+{F10}')

第二个问题:

这些是你需要的功能。摆弄一下,你就知道了。

#include-once
#include <GuiMenu.au3>
;#include <GuiToolbar.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Opt("MustDeclareVars", 1)
Global $gaPopups[1][3] = [[0, 0]]
Func _Lib_PopupGetHwnd($iIndex = 1)
    _Lib_PopupWait()
    Return $gaPopups[$iIndex][0]
EndFunc   ;==>_Lib_PopupGetHwnd
Func _Lib_PopupScan()
    Local $iI, $sClass, $hWnd, $hMenu
    ReDim $gaPopups[1][3]
    $gaPopups[0][0] = 0
    ReDim $winapi_gaWinList[64][2]
    $winapi_gaWinList[0][0] = 0
    $winapi_gaWinList[0][1] = 64
    _WinAPI_EnumWindowsPopup()
    For $iI = 1 To $winapi_gaWinList[0][0]
        $hWnd = $winapi_gaWinList[$iI][0]
        $sClass = $winapi_gaWinList[$iI][1]
        Select
            Case $sClass = "#32768"
                $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0)
                _Lib_PopupAdd($hMenu, 1, $hWnd)
            Case $sClass = "ToolbarWindow32"
                _Lib_PopupAdd($hWnd, 2, _WinAPI_GetParent($hWnd))
            Case $sClass = "ToolTips_Class32"
                _Lib_PopupAdd($hWnd, 3, _WinAPI_GetParent($hWnd))
        EndSelect
    Next
EndFunc   ;==>_Lib_PopupScan
Func _Lib_PopupWait()
    Local $iLoop = 0
    While $iLoop < 50
        If $gaPopups[0][0] > 0 Then Return
        Sleep(100)
        _Lib_PopupScan()
        $iLoop += 1
    WEnd
    ConsoleWrite("Timeout waiting for popup window to appear" & @CRLF)
EndFunc   ;==>_Lib_PopupWait
Func _Lib_PopupAdd($hWnd, $iType, $hParent)
    Local $iCount
    $gaPopups[0][0] += 1
    $iCount = $gaPopups[0][0]
    ReDim $gaPopups[$iCount + 1][3]
    $gaPopups[$iCount][0] = $hWnd
    $gaPopups[$iCount][1] = $iType
    $gaPopups[$iCount][2] = $hParent
EndFunc   ;==>_Lib_PopupAdd

相关内容

  • 没有找到相关文章

最新更新