找回密码
 加入
搜索
查看: 1569|回复: 7

Func下不能再有一个Func,请问用什么来代替这个Func?

[复制链接]
发表于 2009-3-24 03:54:25 | 显示全部楼层 |阅读模式
事情是这样子的,之前在论坛上面看到一个例子.
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
$Form1_1 = GUICreate("清理系统日志", 485, 493, 293, 154)
GUISetOnEvent($GUI_EVENT_CLOSE, "_form1")

$Button1 = GUICtrlCreateButton("清理系统日志", 56, 312, 129, 33, 0)
GUICtrlSetOnEvent($Button1, "_Button1")

GUISetState(@SW_SHOW)

While 1
        Sleep(1000)
WEnd

Func _form1()
        Exit
EndFunc


Func _Button1()
        
EndFunc


我想把清理系统日志这段代码放上去,
                        _CleanEvent(1)
                        Func _CleanEvent($s = 1)
                                $strComputer = "."
                                $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & $strComputer & "\root\cimv2")
                                Dim $mylogs[4]
                                $mylogs[1] = "application"
                                $mylogs[2] = "system"
                                $mylogs[3] = "security"

                                For $logs In $mylogs
                                        $colLogFiles = $objWMIService.ExecQuery('Select * from Win32_NTEventLogFile where LogFileName="' & $logs & '"')
                                        For $objLogfile In $colLogFiles
                                                $objLogfile.ClearEventLog()
                                        Next
                                Next
                                GUICtrlSetState($Button50, $GUI_DISABLE)
                        EndFunc


那么这个按钮就会有两个Func,请问类似上面的这种情况,怎么去解决呢?
我想好多跟我一样的新手都一样不知道怎么去处理的,因为语法本身就有错误,在网上面找了两天的例子,没找到类似的.
麻烦知道的帮个忙处理下好吗?如果解决了,我想很多遇到这个问题的人都会感谢这个帖的...

[ 本帖最后由 laojikelly 于 2009-3-25 09:35 编辑 ]
 楼主| 发表于 2009-3-24 05:48:19 | 显示全部楼层
我已经解决了......
 楼主| 发表于 2009-3-24 05:53:21 | 显示全部楼层
#NoTrayIcon
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1_1 = GUICreate("", 230, 132, 193, 115)
$Button1 = GUICtrlCreateButton("清除系统日志",48, 24, 129, 65, 0)

GUISetState(@SW_SHOW)

Opt("WinTitleMatchMode", 2)
 
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[4]
        $mylogs[1]="application"
        $mylogs[2]="system"
        $mylogs[3]="security"
 
        For $logs in $mylogs
        $colLogFiles = $objWMIService.ExecQuery ('Select * from Win32_NTEventLogFile where LogFileName="' & $logs & '"')
        For $objLogfile in $colLogFiles
            $objLogFile.ClearEventLog()
        Next
        Next
    EndFunc


给更多的人看看,我是看过N多个例子无意中变通得来的...我很菜的...大家不要取笑我......
 楼主| 发表于 2009-3-24 07:04:15 | 显示全部楼层
又遇到新问题了。。。
新手真是惨。。。
等我查多点资料如果还是没果再发上来。
到时希望可以得到帮助。。。
发表于 2009-3-25 04:30:39 | 显示全部楼层
我觉得在你继续学习下去之前 最好先看看帮助的一些基础部分
 楼主| 发表于 2009-3-25 09:35:48 | 显示全部楼层
恩恩,,,谢谢,,,我最大的缺点就是急于求成...
发表于 2009-3-25 21:46:34 | 显示全部楼层
func中可以调用func
 楼主| 发表于 2009-3-27 09:47:08 | 显示全部楼层
敢问298311657君,能给个例子我看看吗???
我学AU3不知从何学起...
基础十分差...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 14:29 , Processed in 0.075360 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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