自动将最新的文件path复制到剪贴板

您好我正在编写一个脚本,将打开Windows 10相机,然后显示最近的图像时,我closures相机,然后用GUI,询问用户,如果图像是好的。 如果他们selectyes,那么脚本会将文件path复制到clibpoard,然后能够将该文件path放到Microsoft Excel单元格中。 我一直在努力,直到我需要将文件path复制到剪贴板为止。 这是我的代码到目前为止。

#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 <File.au3> #Include <Array.au3> #include <GUIConstantsEx.au3> #include <GUIComboBox.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 Else Return '' EndIf 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 

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

AutoIT具有剪贴板的function,比如ClipPut和ClipGet。

 ClipPut($filepath) 

这将在你的情况

 ClipPut($a_FileList[1][0])