找回密码
 加入
搜索
查看: 2891|回复: 6

[AU3基础] Help Me! 遇到问题了,帮帮忙,关于事件模式的

  [复制链接]
发表于 2010-4-12 14:23:45 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

GUICreate("提取文件演示", 304, 82, 192, 124)
$Extract = GUICtrlCreateInput("", 32, 20, 150, 21)
$Browse = GUICtrlCreateButton("浏 览", 200, 20, 75, 21)
GUICtrlSetOnEvent(-1,"Browse")
$Go = GUICtrlCreateButton("进行下一步操作", 32, 50, 150, 21)
GUICtrlSetOnEvent(-1,"Go")
$Quit = GUICtrlCreateButton("退 出", 200, 50, 75, 21)
GUICtrlSetOnEvent(-1, "Quit")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd

Global $sRootPath

Func Browse()
        $sRootPath = FileSelectFolder("选择要提取文件的所在目录", "", 1)
        If @error Then
                MsgBox(8192, "提示", "此次操作未选择,请重新选择")
        Else
                GUICtrlSetData($Extract, $sRootPath)
        EndIf
EndFunc

Func Go()
        If GUICtrlRead($Extract) <> "" Then
                Copy($sRootPath)
        Else
                Other("没有选择相关文件")
        EndIf
EndFunc



Func Other($a)
        MsgBox(0,0,$a)
EndFunc

Func Copy($sPath)    ;就是这一段运行不出
        MsgBox(0,0,$sPath)
EndFunc   ;==>copy

Func Quit()
        Exit
EndFunc
帮忙看看  Copy($sPath) 那段运行不出。。。
发表于 2010-4-12 16:23:13 | 显示全部楼层
新来的,看不懂。
发表于 2010-4-12 16:29:31 | 显示全部楼层
$sRootPath  这个变量没声明
发表于 2010-4-12 16:30:20 | 显示全部楼层
$sRootPath
非公共变量
发表于 2010-4-12 16:31:50 | 显示全部楼层
Global $sRootPath  把这段代码写在GUISetState(@SW_SHOW)下面,就OK啦!!!!
发表于 2010-4-12 16:34:49 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

GUICreate("提取文件演示", 304, 82, 192, 124)
$Extract = GUICtrlCreateInput("", 32, 20, 150, 21)
$Browse = GUICtrlCreateButton("浏 览", 200, 20, 75, 21)
;GUICtrlSetOnEvent(-1,"Browse")
$Go = GUICtrlCreateButton("进行下一步操作", 32, 50, 150, 21)
GUICtrlSetOnEvent(-1,"Go")
$Quit = GUICtrlCreateButton("退 出", 200, 50, 75, 21)
GUICtrlSetOnEvent(-1, "Quit")
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")



#EndRegion ### END Koda GUI section ###
        $sRootPath = FileSelectFolder("选择要提取文件的所在目录", "", 1)
        If @error Then
                MsgBox(8192, "提示", "此次操作未选择,请重新选择")
        Else
                GUICtrlSetData($Extract, $sRootPath)
                        EndIf
GUISetState(@SW_SHOW)                        
While 1
        Sleep(100)
WEnd

Global $sRootPath

;Func Browse()

;EndFunc

Func Go()
        If GUICtrlRead($Extract) <> "" Then
                Copy($sRootPath)
        Else
                Other("没有选择相关文件")
        EndIf
EndFunc



Func Other($a)
        MsgBox(0,0,$a)
EndFunc

Func Copy($sPath)    ;就是这一段运行不出
        MsgBox(0,0,$sPath)
EndFunc   ;==>copy

Func Quit()
        Exit
EndFunc
 楼主| 发表于 2010-4-12 18:00:19 | 显示全部楼层
回复 6# dtooboss


    这样的话,就达不到目的了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-20 11:00 , Processed in 0.077984 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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