2
您好我正在編寫一個腳本,將打開Windows 10相機,然後顯示最近的圖像,當我關閉相機,然後用GUI時,詢問用戶圖像是否正常。如果他們選擇是,那麼腳本會將文件路徑複製到clibpoard,然後能夠將此文件路徑放到Microsoft Excel單元格中。我一直在努力工作,直到我需要將文件路徑複製到剪貼板爲止。這是我的代碼到目前爲止。autoIT將最新的文件路徑複製到剪貼板
#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
就像我說的,我期待複製的最新照片的文件路徑,然後將其複製到隨後將被粘貼到Excel單元格剪貼板。我有限的編碼知識,所以可能有很多不好的地方給我的代碼,但我一直在學習,因爲如果有人可以幫助我,請不要混淆我,但是,如果你必須,那麼所有的幫助表示讚賞!
這工作perfec謝謝! –