判断文件是否存在+复制文件

If FileExists($file_way & "\" & $i & ".jpg") Then
            ExitLoop            
        Else
            ;MsgBox(0,"","循环中的"&$i)
        EndIf


FileCopy("图片1\默认.jpg", $file_way&"\1.jpg", 9)

日志记录到txt记事本

;soft_log('hello worl' , 'xx', '222')
Func soft_log($ident,$iden1, $place1, $place2)
    $chr = $place2
    $place1 = "d:\data\file_" & $place1 & ".log"
    $place2 = "d:\data\001_" & $place2
    $TEXT_TIME = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC
    Local $file = FileOpen($place1, 1)
    FileWrite($file, $TEXT_TIME & "  " & $ident &"|"&$iden1& @CRLF)
    FileClose($file)


    If StringLen($chr) > 2 Then

        Local $file2 = FileOpen($place2, 1)
        ;FileClose($file)
        If $file2 = -1 Then
            MsgBox(0, "错误", "不能打开文件.")
        Else

            FileWrite($file2, $TEXT_TIME & "  " & $ident &"|"&$iden1&  @CRLF)

        EndIf
        FileClose($file2)

    EndIf

EndFunc   ;==>soft_log

au3写注册表实现简单的软件注册机

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
;RegDelete("HKEY_CURRENT_USER\Software\Test", "TestKey")

;RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_SZ", "Hello this is a test")
RegWrite("HKEY_CURRENT_USER\Software\Test")
RegWrite("HKEY_CURRENT_USER\Software\Test1")


;RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey3", "REG_MULTI_SZ", "line1" & @LF & "line2" & @LF)


;Local $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
;MsgBox(4096, "Program files are in:", $var)

Local $var = RegRead("HKEY_CURRENT_USER\Software\Test", "TestKey")


$Form1 = GUICreate("Form1", 800,800)
$MenuItem3 = GUICtrlCreateMenu("选项")
$regist = GUICtrlCreateMenuItem("注册", $MenuItem3)
$MenuItem5 = GUICtrlCreateMenuItem("延时", $MenuItem3)
$about1 = GUICtrlCreateMenu("关于")
$about = GUICtrlCreateMenuItem("关于本软件", $about1)


$read=GUICtrlCreateEdit("",200,200,500,60)
GUICtrlSetData($read,"注册信息1111 注册后重启动本软件完成注册",1)


If $var="1111" then
$input=GUICtrlCreateEdit("恭喜,已经完成注册!!",20,500)
;GUISetState($input,$GUI_INDETERMINATE)

EndIf 

$regist_button=GUICtrlCreateButton("注册本软件",400,22)
;GUISetState(-1,$GUI_DISABLE)

;MsgBox(0,"","读取的值"&$var)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $regist 
            $regist_code=InputBox("请输入注册码!",11,0)
            RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_SZ", $regist_code)
            exit

        Case $regist_button 

            If $var<>"1111" then
            $regist_code=InputBox("请输入注册码!",11,0)
            RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_SZ", $regist_code)
           Exit
       EndIf
          MsgBox(0,"","已经注册")
        Case $about
            MsgBox(0,"","软件注册机!")
    EndSwitch
WEnd

au3遍历进程、关闭进程、防止重复运行程序

;AutoItSetOption("TrayIconHide",1);隐藏任务栏图标

local $key = "定时登出程序"
If WinExists($key) Then
MsgBox(4096, "出错了", "本程序已经运行了一个实例!")
Exit
Endif
AutoItWinSetTitle($key)
MsgBox(4096, "正常工作", "本程序正常启动了!")


While 1

$list = ProcessList()      ;获得所有进程
for $i = 1 to $list[0][0]    ;遍历进程  
    ;MsgBox(0,"",$list[$i][0],2)
    If (StringInStr($list[$i][0],"记事本") or $list[$i][0]=='notepad.exe') Then
        MsgBox(0,"","系统将在x秒后退出!",2)
        ;Sleep(34000)

        $c=MsgBox(17,"登出警告","若无操作,系统将退出记事本,选择【取消】将取消系统登出.",6)
    If $c<>2 Then 
    ProcessClose(" notepad.exe")
    ;ProcessExists ( "进程名")  ;成功返回进程的 PID,失败返回0,进程不存在。
    ProcessClose($list[$i][0])  ;如果进程名中包含就关闭该进程。
    ;If Not ProcessExists("notepad.exe") Then  Run("notepad.exe") ;进程不存在则启动
    EndIf

    ;MsgBox(0,"","mei you ")
    Endif
next

;MsgBox(0,"","查找完毕!")

WEnd 

检测windows窗口隐藏激活状态

While 1
    Sleep(2000)

$qq=WinGettext("无标题 - 记事本")
 ;MsgBox(0,0,$qq)

 ;If StringLen($qq)<10 Then ContinueLoop 

 ; MsgBox(262144,0,$qq,1)
 $info=StringSplit($qq,@CRLF)

 ;19 栏目
;  For $i=1 To $info[0]-1 Step 1
;    MsgBox(0,0,$info[$I]) 

;next
;WinActivate
WinSetState ("无标题 - 记事本","",@SW_DISABLE)
;WinSetState ("无标题 - 记事本","",@SW_HIDE)
Sleep(15000)
;WinSetState ("无标题 - 记事本","",@SW_SHOW)
;WinSetState ("无标题 - 记事本","",@SW_ENABLE)

WinClose ( "无标题 - 记事本" ,"" )

WEnd
最后编辑: admin  文档更新时间: 2021-03-16 21:53   作者:admin