找回密码
 加入
搜索
查看: 5435|回复: 11

[AU3基础] 不用windows的任务计划 如何实现定时某个软件运行[已解决]

[复制链接]
发表于 2011-6-1 20:49:57 | 显示全部楼层 |阅读模式
本帖最后由 kaitou8 于 2011-6-2 20:26 编辑

RT..
任务计划 不喜欢 有的电脑没开..
怎么实现每天.按星期几 .按每个月月的某一天
发表于 2011-6-2 08:51:15 | 显示全部楼层
在论坛上搜一下。定时关机之类的就可以改一下了
发表于 2011-6-2 10:06:16 | 显示全部楼层
不用计划任务就需要有一个程序一直运行着
发表于 2011-6-2 10:52:23 | 显示全部楼层
本帖最后由 东挑西点 于 2011-6-2 10:56 编辑

#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
发表于 2011-6-2 11:56:47 | 显示全部楼层
需要一个程序或者服务开机就一直运行,然后在特定的时间去调用运行其它程序
发表于 2011-6-2 13:08:48 | 显示全部楼层
4l的程序挺实用的哈
发表于 2011-6-2 15:02:01 | 显示全部楼层
可以写在代码里啊,程序一直驻留内存就行哈
 楼主| 发表于 2011-6-2 20:23:36 | 显示全部楼层
事实上还是比较喜欢3楼和5楼的回答...3楼的上次提个问题也回答了  谢了..最近忙着布线..有个方向是好的.
发表于 2011-6-14 18:53:25 | 显示全部楼层
谢谢,学习了。。
发表于 2016-10-16 15:08:58 | 显示全部楼层
东挑西点 发表于 2011-6-2 10:52
看到了这段代码,对楼主的感谢之情滔滔不绝....
发表于 2016-12-26 20:18:41 | 显示全部楼层
正在解决这样的问题,学习下
发表于 2017-9-7 08:47:00 | 显示全部楼层
不用计划任务就需要有一个程序一直运行着
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 14:22 , Processed in 0.084112 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表