#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 100, 50, 192, 114)
$Button1 = GUICtrlCreateButton("MyButton", 0, 0, 97, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
If ProcessExists("notepad.exe") Then
If GUICtrlRead($Button1)<>"关闭" Then
GUICtrlSetData($Button1,"关闭")
GUICtrlSetBkColor($Button1, 0xFF0000)
Sleep(1000)
EndIf
Else
If GUICtrlRead($Button1)<>"启动" Then
GUICtrlSetData($Button1,"启动")
GUICtrlSetBkColor($Button1, 0x00FF00)
Sleep(1000)
EndIf
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If GUICtrlRead($Button1)="启动" Then
Run("notepad.exe")
ElseIf GUICtrlRead($Button1)="关闭" Then
ProcessClose("notepad.exe")
EndIf
EndSwitch
WEnd
不知道我猜对了楼主的意思了没。 斗胆给个代码。 |