autoIT将最近的文件路径复制到剪贴板

问题描述 投票:1回答:1

您好我正在编写一个脚本,打开Windows 10相机,然后在关闭相机然后使用GUI时显示最新图像,询问用户图像是否正常。如果他们选择yes,则脚本会将文件路径复制到clibpoard,然后能够将此文件路径传递到Microsoft Excel单元格。我每个人都在努力工作,直到我需要将文件路径复制到剪贴板。到目前为止,这是我的代码。

#include <MsgBoxConstants.au3>

Camera()

Func Camera()
    ; Execute Camera and wait for Camera to close
    Local $iPID = ShellExecuteWait("explorer.exe", "shell:AppsFolder\Microsoft.WindowsCamera_8wekyb3d8bbwe!App")
    Sleep(3000)
    WinWaitClose("Camera")
EndFunc

#include-once
#include <Array.au3>
#include <File.au3>
#include <GUIComboBox.au3>
#include <GUIConstantsEx.au3>
#include <Process.au3>

$dst        = "C:\Users\Cex\Pictures\Camera Roll" ; specify folder
$a_FileList = _FileListToArray2()

_ArraySort($a_FileList, 1, 1, $a_FileList[0][0], 1)
ShellExecute($a_FileList[1][0])

Func _FileListToArray2($s_Mask='*')
    $h_Search   = FileFindFirstFile($dst & '\' & $s_Mask)
    $s_FileName = FileFindNextFile($h_Search)

    If Not @error Then
        Dim $a_File[100][2]

        While Not @error
            If StringInStr($s_FileName,'.',0,-1) Then
                $s_FullName    = $dst & '\' & $s_FileName
                $a_File[0][0] += 1

                If $a_File[0][0] >= UBound($a_File) Then
                    ReDim $a_File[$a_File[0][0] * 2][2]
                EndIf

                $a_File[$a_File[0][0]][0] = FileGetLongName($s_FullName)
                $a_File[$a_File[0][0]][1] = FileGetTime($s_FullName,0,1)
            EndIf
            $s_FileName = FileFindNextFile($h_Search)
        WEnd

        ReDim $a_File[$a_File[0][0] + 1][2]

        Return $a_File
    EndIf

    Return ''
EndFunc

#include <GUIConstantsEx.au3>
#include <IE.au3>

WinWaitActive("Photos", "")

Local $qGUI   = GUICreate("Example", 200, 125, 1000, 200)
                GUICtrlCreateLabel("Are you happy with this image?", 30, 30)
Local $bYes   = GUICtrlCreateButton("Yes", 6, 60, 85, 25)
                GUICtrlSetOnEvent($bYes, "xYes")
Local $bNo    = GUICtrlCreateButton("Yes", 107, 60, 85, 25)
                GUICtrlSetOnEvent($bNo, "xNo")
Local $bClose = GUICtrlCreateButton("Close", 57, 90, 85, 25)

GUISetState(@SW_SHOW, $qGUI)

While 1
    Switch GUIGetMsg()
        Case $bYes
            bYes()
            GUIDelete($qGUI)
            Exit

        Case $bNo
            bNo()
            GUIDelete($qGUI)
            Exit

        Case $bClose, $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func bYes()
    _RunAU3("YesTest.au3")
EndFunc

Func bNo()
    _RunAU3("NoTest.au3")
EndFunc

Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0)
    Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag)
EndFunc

就像我说的那样,我希望复制最新照片的文件路径,然后将其复制到剪贴板,然后将其粘贴到excel的单元格中。我的编码知识有限,所以我的代码可能有很多不好的地方,但我一直在学习,所以如果有人可以帮助我,请不要混淆我,如果你必须,那么所有的帮助表示赞赏!

excel autoit
1个回答
1
投票

AutoIT已经为剪贴板构建了函数,例如ClipPut和ClipGet。

ClipPut($filepath)

这将是你的情况

ClipPut($a_FileList[1][0])
© www.soinside.com 2019 - 2024. All rights reserved.