再次求问:GUIOnEventMode和Button间的错误.
本人天生愚笨,学了那么久的AU3,基础还是不理想,之前由基础学起,但是语文水平查,理解能力弱,很多时候看了很多遍都不清楚说什么.之前有人在论坛上面说过"世风日下"这个词...但我竟然不知道这个是什么意思,但三恨大师就却知道是什么意思,我查了下百度才知道是什么意思.这么偏门的词居然都有人知道是什么意思,可见我语文水平真的很低.
下面我给出我的例子,但求得到大家的解决方法,我来论坛都是通过看例子学习的...我想这是我最好的办法了...
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 210, 114, 646, 607)
$Button1 = GUICtrlCreateButton("清理系统日志", 40, 24, 137, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("系统自动登陆", 40, 56, 137, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button2, "_Button2")
GUISetOnEvent($GUI_EVENT_CLOSE,"_form1")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _form1()
Exit
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_CleanEvent(1)
EndSwitch
WEnd
Func _CleanEvent($s = 1)
$strComputer = "."
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & $strComputer & "\root\cimv2")
Dim $mylogs
$mylogs = "application"
$mylogs = "system"
$mylogs = "security"
For $logs In $mylogs
$colLogFiles = $objWMIService.ExecQuery('Select * from Win32_NTEventLogFile where LogFileName="' & $logs & '"')
For $objLogfile In $colLogFiles
$objLogfile.ClearEventLog()
Next
Next
EndFunc ;==>_CleanEvent
Func _Button2()
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
当上面的Opt("GUIOnEventMode", 1)为1的时候,$Button1就运行不了了,
当Opt("GUIOnEventMode", 1)为0的时候,$Button1可以运行,但是$Button2就不能运行了.
大家可以给出解决方案吗??
其实大家可以看下我发的帖,这几天以来一直为这种类型的问题而烦,目的就是为了学习更多这方面的语法.
之前sxd大哥已经叫我先看看帮助的一些基础部分.但是我不是没去看,好多东西看了还是不明白...我觉得我还是通过看例子能够更快的提高自己.
其实上面的清理日志,那些语法我一直都不懂...而我还没有能理解这个WMI的地步...希望论坛上面的哥哥姐姐不吝赐教啦...
:face (27): :face (27): :face (27):
[ 本帖最后由 laojikelly 于 2009-3-27 11:33 编辑 ] 这其实就是消息模式和事件模式的区别 中文资料区有很多资料 楼主可以先去看下 原来这就是消息模式和事件模式,行...偶这就漂移过去... 谢谢,我按照你说的去看.....
已经解决了...最基础的东西,我都不懂...真没用........... 下面我贴出代码来...
让更多比我蠢的人懂...
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 210, 114, 646, 607)
$Button1 = GUICtrlCreateButton("清理系统日志", 40, 24, 137, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("系统自动登陆", 40, 56, 137, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button2, "_Button2")
GUISetOnEvent($GUI_EVENT_CLOSE,"_form1")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func _form1()
Exit
EndFunc
While 1
$Msg = GUIGetMsg()
Select
Case $msg = $Button1
_CleanEvent(1)
Case $msg = $Button2
_Button2()
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
Func _CleanEvent($s = 1)
$strComputer = "."
$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & $strComputer & "\root\cimv2")
Dim $mylogs
$mylogs = "application"
$mylogs = "system"
$mylogs = "security"
For $logs In $mylogs
$colLogFiles = $objWMIService.ExecQuery('Select * from Win32_NTEventLogFile where LogFileName="' & $logs & '"')
For $objLogfile In $colLogFiles
$objLogfile.ClearEventLog()
Next
Next
EndFunc ;==>_CleanEvent
Func _Button2()
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 非常谢谢大绯狼君啊...
没有把我这只兔子给吃了,还指了一条生路给我...
万分感谢... 多动手。多思考。事实AU3也并没有你想象中的那么复杂。 多动手,我已经觉得我经常动手的了...
但是多思考却不知从何思考,因为我还没有很好的根基,何谈思考?
只能看例子,看代码就是多思考,没找到代码还思考什么呢?
页:
[1]