36158130 发表于 2009-7-6 11:22:52

GUI问题

$Button1                = GuiCtrlCreateButton("运行", 260, 90, 50, 20)
$Button2                = GuiCtrlCreateButton("停止", 260, 90, 50, 20)
怎样做到点击“运行”就显示“停止”
而且运行时要执行一个自动操作。
停止时就停止这个操作。
弄了好久都没有实现。
哪位大侠帮帮忙。。

kn007 发表于 2009-7-6 11:41:12

本帖最后由 kn007 于 2009-7-6 14:39 编辑

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("测试", 133, 65, 192, 124)
GUISetState(@SW_SHOW)
$Button1 = GUICtrlCreateButton("运行", 15, 36, 58, 25, 0)
While 1

      $nMsg = GUIGetMsg()
      Switch $nMsg
          Case $GUI_EVENT_CLOSE
                Exit
                Case $Button1
                        abc()
      EndSwitch

WEnd

Func abc()
      If GUICtrlRead($Button1) = "运行" Then
                GUICtrlSetData($Button1, "停止")
      Else
                GUICtrlSetData($Button1, "运行")
      EndIf
EndFunc

36158130 发表于 2009-7-6 14:03:37

While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $Button1
                        abc()
      EndSwitch

WEnd

但是这个死会循环的
如果我点击了一下“运行”
显示“停止”时就会立即的自动跳到“运行”

顽固不化 发表于 2009-7-6 14:17:42

关键是理解别人代码的思路。

kn007 发表于 2009-7-6 14:39:47

While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $Button1
                        abc()
      EndSwitch

WEnd

但是这个死会循环的
如果我点击了一下“运行”
显示 ...
36158130 发表于 2009-7-6 14:03 http://www.autoitx.com/images/common/back.gif

修改好了,你自己不会改啊。。。给你个思路而已

36158130 发表于 2009-7-6 17:25:02


还是没有搞定
不过用另一种解决方案了
谢谢啦

lynfr8 发表于 2009-7-6 19:05:24

楼主的意思其实关键是暂停脚本的运行
这个论坛很多相关的资料了
http://www.autoitx.com/search.php?searchid=196&orderby=lastpost&ascdesc=desc&searchsubmit=yes

kn007 发表于 2009-7-6 19:13:23

你不觉得按你这样理解不对题?

大概是我想错了,而且我这种也可以达到你所说的要求。。。。

算了,不想太多了,你那键盘数组能帮我不?
页: [1]
查看完整版本: GUI问题