• 歡迎訪問奇跡の海網站,本站不上傳任何資源,所有資源均來自于網絡,歡迎加入奇跡の海~!奇跡の海-WordPress QQ群
  • 本站下載資源為網絡上收集整理而來,并且以計算機技術研究交流為目的,版權歸原作者所有,僅供大家參考,學習,不存在任何商業目的與商業用途.
  • 本站系統鏡像均來自于官方原版,ed2k可視為P2P下載鏈接。所有操作系統默認均為試用版,如有正版密鑰可以有效激活,本站不提供任何激活和相關服務。

AutoIt3(au3)源碼-實現某個程序/軟件定時運行

AutoIT3 奇跡の海 2年前 (2017-09-23) 2757次瀏覽 已收錄 0個評論 掃描二維碼

AutoIt3(au3)源碼-實現某個程序/軟件定時運行

簡介

不用windows的任務計劃 如何實現定時某個軟件運行

代碼

#Region ;**** 參數創建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=a.ico
#AutoIt3Wrapper_outfile=多功能定時重啟配置工具.exe
#AutoIt3Wrapper_Res_Description=runTime 制作 snow
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Snow
#AutoIt3Wrapper_Res_Field=作者|Snow(雪花)
#AutoIt3Wrapper_Res_Field=作者QQ|68627139
#AutoIt3Wrapper_Res_Field=技術支持群|51366958 (迅閃高級技術交流群)
#AutoIt3Wrapper_Res_Field=版權|版權所有(C)1997-2008 ㊣Snow技術小組
#AutoIt3Wrapper_Res_Field=Snow技術小組|
#EndRegion ;**** 參數創建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3> 
 
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form1.kxf
FileInstall("幫助說明.txt",@ScriptDir & "\幫助說明.txt",1)
Opt("GUIOnEventMode", 1) ;設置驅動模式
$Form1_1 = GUICreate("配置向導", 485, 493, 293, 154)
GUISetIcon(@ScriptDir & "\a.ico", 53)
GUISetBkColor(0x008080)
GUISetOnEvent($GUI_EVENT_CLOSE,"_form1")
 
$Button1 = GUICtrlCreateButton("每天定時重啟", 56, 72, 105, 33, 0)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUICtrlSetOnEvent($Button1,"_Button1")
 
$Button2 = GUICtrlCreateButton("清除每天定時重啟的任務", 232, 72, 169, 33, 0)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetOnEvent($Button2,"_Button2")
 
$Button3 = GUICtrlCreateButton("以星期數重啟", 56, 128, 105, 33, 0)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUICtrlSetOnEvent($Button3,"_Button3")
 
$Button4 = GUICtrlCreateButton("清除以星期數重啟的任務", 232, 128, 169, 33, 0)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetOnEvent($Button4,"_Button4")
 
$Button5 = GUICtrlCreateButton("具體日期重啟", 56, 184, 105, 33, 0)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUICtrlSetOnEvent($Button5,"_Button5")
 
$Button6 = GUICtrlCreateButton("清除具體日期重啟任務", 232, 184, 169, 33, 0)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetOnEvent($Button6,"_Button6")
 
$Button10 = GUICtrlCreateButton("間隔時間重啟", 56, 240, 105, 33, 0)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUICtrlSetOnEvent($Button10,"_Button10")
 
$Button11 = GUICtrlCreateButton("清除間隔時間重啟任務", 232, 240, 169, 33, 0)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetOnEvent($Button11,"_Button11")
 
$Button12 = GUICtrlCreateButton("系統自動登陸工具", 56, 312, 129, 33, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlSetOnEvent($Button12,"_Button12")
 
$Button7 = GUICtrlCreateButton("完成配置", 208, 312, 65, 33, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlSetOnEvent($Button7,"_Button7")
 
$Button8 = GUICtrlCreateButton("查看配置", 296, 312, 65, 33, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlSetOnEvent($Button8,"_Button8")
 
$Button9 = GUICtrlCreateButton("查看幫助", 384, 312, 65, 33, 0)
GUICtrlSetColor(-1, 0xFF00FF)
GUICtrlSetOnEvent($Button9,"_Button9")
 
;---------------下面不用處理-------------
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\log.gif", 32, 368, 169, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("請選擇任務模式", 144, 16, 151, 24)
GUICtrlSetFont(-1, 15, 800, 0, "楷體_GB2312")
GUICtrlSetColor(-1, 0x00FFFF)
$Label2 = GUICtrlCreateLabel(" 雪花技術--值得關注 ", 232, 392, 176, 20)
GUICtrlSetFont(-1, 12, 800, 0, "楷體_GB2312")
GUICtrlSetColor(-1, 0x00FF00)
$Label3 = GUICtrlCreateLabel("Snow技術小組開發    業務QQ68627139", 224, 448, 219, 17)
GUICtrlSetColor(-1, 0xFFFF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;
Opt("TrayIconHide", 1)   ;0=顯示, 1=隱藏托盤圖標
Global $config,$title
$config = (@ScriptDir & "\config.ini")
$title = "設置向導"
 
While 1 ; 不做任何事
  Sleep(1000)  
WEnd
 
Func _form1() ;關閉主窗口
        Exit
EndFunc
 
Func _Button1() ;設置每天定時重啟
        _runTime("everyday","每天重啟")
EndFunc
 
Func _msgBox($function,$text) ;信息提示和循環。
        MsgBox(0+48,"提示",$text)
        Call ($function)
EndFunc
 
Func  _runTime($iniName,$iniVar) ;驗證時間格式的正確性和寫入配置
                $runTime = InputBox($title,"       請設定重啟時間   "&@CRLF&@CRLF & "    格式24小時制 XX:XX",@HOUR&":"&@MIN,"",120,150)
If @error = 0 Then ; 如果用戶按下確定鍵
        $time = StringSplit($runTime,":")
        If @error = 1 Then 
        _msgBox("_Button1",'請用英文狀態下的冒號":"分隔開小時和分鐘  ')
        ElseIf $time[0] > 2 Then 
        _msgBox("_Button1","格式錯誤,只能有一個冒號,請重新設置   ")
        ElseIf (Not StringIsDigit($time[1])) Or (Not StringIsDigit($time[2])) Then ;檢查是否輸入數字
        _msgBox("_Button1","只能輸入數字,請重新設定  ")
        Elseif $time[1] > 23 Or $time[2] > 59 Then 
        _msgBox("_Button1","小時大于23或分鐘大于59,請重新設置  ")
        ElseIf  (StringLen($time[1]) < 2 Or StringLen($time[2]) < 2) Or (StringLen($time[1]) > 2 Or StringLen($time[2]) > 2) Then 
        _msgBox("_Button1","時間格式為 XX:XX 請重新設定")
        Else
        IniWrite($config,$iniName,$iniVar,$runTime)
        EndIf
Else
EndIf
EndFunc
 
Func _Button2() ;清除每天定時重啟的任務
        IniDelete($config,"everyday")
        _msgBox("","清除每天重啟任務完成  ")
EndFunc
 
Func _Button3() ;設置以星期數重啟
        $week = InputBox($title,"   請設定按星期數重啟時間  "&@CRLF&@CRLF & "1-7 依次表示星期天到星期六",@WDAY,"",120,150)
If @error = 0 Then ; 如果用戶按下確定鍵
        If (Not StringIsDigit($week)) Or (Not StringIsDigit($week)) Then 
        _msgBox("_Button3","只能輸入數字,請重新設定  ")
        Elseif $week <= 0 Or $week >= 8 Then 
        _msgBox("_Button3","超出范圍! 1-7 依次表示星期天到星期六 請重新設置  ")
        Else
        Dim $weekDay[8] 
        $weekDay[0] = ""
        $weekDay[1] = "星期日"
        $weekDay[2] = "星期一"
        $weekDay[3] = "星期二"
        $weekDay[4] = "星期三"
        $weekDay[5] = "星期四"
        $weekDay[6] = "星期五"
        $weekDay[7] = "星期六"
                If MsgBox(1+48,"提示","你選擇了 " &$weekDay[$week]& " 重電腦是嘛?接下來設置時間  ") = 1 Then 
                _runTime("week",$weekDay[$week])
                Else
                Call ("_Button3")
                EndIf   
        EndIf   
Else
EndIf
EndFunc
 
Func _Button4() ;清除以星期數重啟的任務
        IniDelete($config,"week")
        _msgBox("","清除所有的星期數重啟任務完成  ")
EndFunc
 
Func _Button5() ;具體日期重啟
        $yearDay = InputBox($title,"  請設定具體日期重啟時間  "&@CRLF&@CRLF & "    時間格式: 年-月-日",_NowDate(),"",120,150)
If @error = 0 Then ; 如果用戶按下確定鍵
        If _DateIsValid ( $yearDay ) Then ;確認日期是否合法。
                $yearDayVar = StringSplit($yearDay,"-")
                If  $yearDayVar[0] = 3  Then
                        If $yearDay < _NowDate() Then
                                MsgBox(1,"錯誤","你所輸入的時間: " &$yearDay& " 是過去的日期,請重新設定! ")
                                Call ("_Button5")
                        ElseIf MsgBox(1+48,"提示","你選擇了 " &$yearDay& " 重電腦是嘛?接下來設置時間  ") = 1 Then 
                        _runTime("yearDay",$yearDay)
                        Else
                        Call ("_Button5")
                        EndIf
                Else
                _msgBox("_Button5",'請用英文狀態下的 " - " 把日期分隔開'  )
                EndIf
        Else
                _msgBox("_Button5"," 給定的日期不合法,請重新設定   ")
        EndIf
Else
EndIf
EndFunc
 
Func _Button6() ;清除具體日期重啟任務
        IniDelete($config,"yearDay")
        _msgBox("","清除所有的具體日期重啟任務完成  ")
EndFunc
 
Func _Button7() ;完成配置
        $configVar = IniReadSectionNames ($config)
If Not @error Then
        If Not ProcessExists("runTime.exe") Then
                If MsgBox(1+48,"提示","    配置已生成,是否須要馬上運行?" &@CR&@CR& "你也可以稍候再運行主程序 runTime 執行任務  ") = 1 Then
                        Run (@ScriptDir &"\runTime.exe")
                        Exit
                Else
                        ToolTip(@CR&" * 雪花 * -----  看來是值得你花!  謝謝你的使用!", @DesktopWidth-500, @DesktopHeight-500,"Snow技術小組",0,2)
                        Sleep(2000)
                        Exit
                EndIf
        Else
                If MsgBox(1+48,"提示",@CR&"  配置已更新,是否須要重新運行?  " ) = 1 Then
                        ProcessClose("runTime.exe")
                        While 1
                        If Not ProcessExists("runTime.exe") Then 
                                Run (@ScriptDir &"\runTime.exe")
                                Exit
                        Else
                                ProcessClose("runTime.exe")
                        EndIf
                        Sleep(500)
                        WEnd
                EndIf
        EndIf
                        
Else 
        MsgBox(0+48,"    提示","現在的配置內容為空!!  " )
Exit
EndIf
EndFunc
 
Func _Button8() ;查看配置
        ShellExecute($config,@ScriptDir,@SW_MAXIMIZE)
EndFunc
 
Func _Button9() ;查看幫助
        ShellExecute(@ScriptDir & "\幫助說明.txt",@ScriptDir,@SW_MAXIMIZE)
EndFunc
 
Func _Button10() ;設定間隔時間
        $delayTime = InputBox($title,"    請設定間隔重啟時間"&@CR&@CR&"      時間單位為:小時 ",'15',"",120,150)
        If @error = 0 Then ; 如果用戶按下確定鍵
                If Not StringIsDigit ( $delayTime ) Then
                                _msgBox("_Button10","只能輸入數字和整數 ,請重新設定  ")
                        ElseIf $delayTime <= 0 Then
                                _msgBox("_Button10","間隔時間不能為 0 請重新設定  ")
                        Else    
                                
                                IniWrite($config,"delay","間隔時間",$delayTime)
                        EndIf
        Else
        EndIf
EndFunc
 
Func _Button11();清除間隔時間重啟任務
        IniDelete($config,"delay")
        _msgBox("","清除間隔時間重啟任務完成  ")
EndFunc
 
Func _Button12();系統自動登陸工具
        If MsgBox(1+48,"提示","是否設置windows自動登陸系統  ") = 1 Then
        $localName = regread ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName") ;讀用戶名
        $name = inputbox ("自動登設置","你當前的用戶名是: " &$localName&@CR&@CR&"請輸入您要自動登陸的用戶名   ",$localName,"",120,150)
                If  @error = 0 Then ; 如果按下在確定鍵
                        If MsgBox(1+48,"提示","如果你所寫的用戶并不存在,會造成無法進入系統" &@CR&@CR&"  如果你不清楚情況,請默認即可!是否確定? ") = 1 Then
                                         $passWord = inputbox ("自動登設置",@CR&@CR&"請輸入您要自動登陸的密碼:","","*",120,150)
                                         If @error = 0 Then ; 如果按下在確定鍵
                                                regwrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName","reg_sz",$name) ;寫入用戶名
                                                regwrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultPassWord","reg_sz",$passWord) ;寫入密碼
                                                regwrite ("HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon","AutoAdminLogon","reg_sz","1")
                                                MsgBox(0+48,"提示","  設置完成,重啟即可生效!  ")
                                         EndIf
                        Else
                        EndIf
                Else
                EndIf
        Else
        EndIf
EndFunc

版權聲明:本站所有文章和資源使用CC BY-NC-SA 4.0協議授權發布 , 轉載應當以相同方式注明文章來自“SeaOMC.COM->AutoIt3(au3)源碼-實現某個程序/軟件定時運行!在下邊可以分享本文哦!
喜歡 (3)
[]
分享 (0)
奇跡の海
關于作者:
一個WordPress菜鳥!
發表我的評論
取消評論

表情 貼圖 加粗 刪除線 居中 斜體 簽到

Hi,您需要填寫昵稱和郵箱!

  • 昵稱 (必填)
  • 郵箱 (必填)
  • 網址
中国福利彩票36选7开奖结果