Hen5ei 发表于 2010-4-12 14:23:45

Help Me! 遇到问题了,帮帮忙,关于事件模式的

#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) 那段运行不出。。。

waxy 发表于 2010-4-12 16:23:13

新来的,看不懂。

kinghu318 发表于 2010-4-12 16:29:31

$sRootPath这个变量没声明

dtooboss 发表于 2010-4-12 16:30:20

$sRootPath
非公共变量

kinghu318 发表于 2010-4-12 16:31:50

Global $sRootPath把这段代码写在GUISetState(@SW_SHOW)下面,就OK啦!!!!

dtooboss 发表于 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

Hen5ei 发表于 2010-4-12 18:00:19

回复 6# dtooboss


    这样的话,就达不到目的了
页: [1]
查看完整版本: Help Me! 遇到问题了,帮帮忙,关于事件模式的