Giáo Trình How To Use AutoIt A Professional Manner part 26 docx

6 261 0
Giáo Trình How To Use AutoIt A Professional Manner part 26 docx

Đang tải... (xem toàn văn)

Thông tin tài liệu

precedence. Also, if you create a shortcut with the same path\name as as a pre- existing shortcut, it gets overwritten with your new version. Related FileGetShortcut Example ; Sets a shortcut with ctrl+alt+t hotkey FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE) Function Reference FileDelete Xóa file. FileDelete ( "path" ) Parameters Path đường dẫn tới file muốn xóa, kí tự đại diện đc hỗ trợ (vd \*.bak) Return Value Success: Return 1. Failure: Returns 0 nếu ko xóa đc hoặc file ko tồn tại Remarks chú ý: nếu path dẫn tới một folder (có tồn tại) thì hàm sẽ xóa tất cả file trong folder đó xem thêm hàm FileFindFirstFile để biết thêm về kí tự đại diện một số thuộc tính của file có thể ko cho xóa file Related FileCopy, FileMove, FileRecycle, DirRemove Example FileDelete("D:\*.tmp") Function Reference FileExists kiểm tra file hay thư mục có tồn tại hay ko FileExists ( "path" ) Parameters Path đường dẫn Return Value Success: Returns 1. Failure: Returns 0 nếu ko tồn tại Remarks Fileexists trả về 0 nếu bạn chỉ định một ổ đĩa mà không có đĩa. Related FileGetAttrib, DriveStatus Example If FileExists("C:\autoexec.bat") Then MsgBox(4096, "C:\autoexec.bat File", "Exists") Else MsgBox(4096,"C:\autoexec.bat File", "Does NOT exists") EndIf If FileExists("C:\") Then MsgBox(4096, "C:\ Dir ", "Exists") Else MsgBox(4096,"C:\ Dir" , "Does NOT exists") EndIf If FileExists("D:") Then MsgBox(4096, "D: Drive", "Exists") Else MsgBox(4096,"D: Drive", "Does NOT exists") EndIf Function Reference FileFindFirstFile trả lại sự tìm kiếm "handle" của file FileFindFirstFile ( "filename" ) Parameters filename tên file muốn tìm. (kí tự đại diện * và ? đc hỗ trợ) Return Value Success: trả lại "handle" tìm thấy Failure: trả lại -1 nếu có bất kì lỗi gì sảy ra. nếu thư mục rỗng thì đặt @error = 1. Remarks tên file có hỗ trợ kí tự đại diện kí tự * đại diện cho nhiều kí tự kí tự ? đại diện cho 1 kí tự vd: có các file sau abc.dat, asc.dat, abc.exe thì search "*.dat" sẽ đc 2 file abc.dat, asc.dat "a?c.dat" sẽ đc 2 file abc.dat, asc.dat "abc.*" sẽ đc 2 file abc.dat, abc.exe Khi bạn đã hoàn tất tìm kiếm với các hàm FileFind , bạn phải gọi hàm FileClose () để kết thúc quá trình tìm kiếm Tên thư mục được trả lại theo kí tự đại diện nếu có. Related FileClose, FileFindNextFile Example ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search) Function Reference FileFindNextFile tìm kiếm tiếp sau hàm FileFindFirstFile. FileFindNextFile ( search ) Parameters search handle file đc trả lại bởi hàm FileFindFirstFile. Return Value Success: trả lại tên file Failure: Sets @error = 1 nếu ko tìm thấy. Remarks cần thiết gọi hàm FileFindFirstFile trước để thiết lập tìm kiếm và nhận được file handle. Tất cả các cuộc gọi đến FileFindNextFile sẽ trả lại tập tin kế tiếp được tìm thấy theo chuỗi cung cấp để tìm kiếm FileFindFirstFile. Khi @error = 1 thì không có thêm các tập tin được tìm thấy phù hợp với chuỗi tìm kiếm ban đầu. Khi bạn đã hoàn tất tìm kiếm với các hàm FileFind , bạn phải gọi hàm FileClose () để kết thúc quá trình tìm kiếm Related FileClose, FileFindFirstFile Example ; Shows the filenames of all files in the current directory $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search) . file sau abc.dat, asc.dat, abc.exe thì search "*.dat" sẽ đc 2 file abc.dat, asc.dat " ;a? c.dat" sẽ đc 2 file abc.dat, asc.dat "abc.*" sẽ đc 2 file abc.dat, abc.exe. precedence. Also, if you create a shortcut with the same path ame as as a pre- existing shortcut, it gets overwritten with your new version. Related FileGetShortcut Example ; Sets a shortcut. Example If FileExists("C:autoexec.bat") Then MsgBox(4096, "C:autoexec.bat File", "Exists") Else MsgBox(4096,"C:autoexec.bat File", "Does NOT

Ngày đăng: 08/07/2014, 20:20

Tài liệu cùng người dùng

Tài liệu liên quan