脚本已经写好 界面上就几个按钮 如何实现操作
本帖最后由 吕偏执先生 于 2013-4-24 08:53 编辑我的脚本已经写好了,如何把脚本带入到这个操作界面中。要实现的功能是:按选项,顺序从上到下运行。
24724 麻烦说明白点 回复 2# netegg
就是脚本写好了 不知道如何做个界面出来。
#include <GUIConstantsEx.au3>
$DriveList = DriveGetDrive("FIXED")
If @error Then Exit
Dim $List
For $i=2 To $DriveList Step 1
$List = $List & StringUpper($DriveList[$i])
If $i <> $DriveList Then $List = $List & "|"
Next
GUICreate("GUICtrlCreateRadio 函数演示",360,80)
$ComboList = GUICtrlCreateCombo(StringUpper($DriveList),10,10,38)
GUICtrlSetData(-1,$List,$DriveList)
$Button_1 = GUICtrlCreateButton("检测",10,50)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
$Combo = GUICtrlRead($ComboList)
If $msg = $Button_1 Then
MsgBox("","",$Combo)
EndIf
WEnd #include <GUIConstantsEx.au3>
GUICreate("GUICtrlCreateRadio 函数演示",360,80)
$radio1 = GUICtrlCreateRadio("单选按钮 1",10,10,120,20)
$radio2 = GUICtrlCreateRadio("单选按钮 2",10,30,120,20)
$Button_1 = GUICtrlCreateButton("检测",10,50)
GUICtrlSetState($radio2, $GUI_CHECKED)
GUISetState()
While 1
$msg = GUIGetMsg()
$radioC1 = GUICtrlRead($radio1)
$radioC2 = GUICtrlRead($radio2)
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $Button_1 Then
MsgBox("","",$radioC1 & " " & $radioC2)
EndIf
WEnd #include <GUIConstantsEx.au3>
GUICreate("GUICtrlCreateButton 函数演示",360,60)
$Button_1 = GUICtrlCreateButton("启动记事本",10,10,100)
$Button_2 = GUICtrlCreateButton("测试",120,10)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
Run('Notepad.exe')
Case $msg = $Button_2
MsgBox(0,'测试','测试按钮被点击')
EndSelect
WEnd #include <GUIConstantsEx.au3>
GUICreate("GUICtrlCreateCheckbox 函数演示",360,80)
$Checkbox1 = GUICtrlCreateCheckbox("复选框 1",10,10,120,20)
$Checkbox2 = GUICtrlCreateCheckbox("复选框 2",10,30,120,20)
$Button_1 = GUICtrlCreateButton("检测",10,50)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
$Check1 = GUICtrlRead($Checkbox1)
$Check2 = GUICtrlRead($Checkbox2)
If $msg = $Button_1 Then
MsgBox("","",$Check1 & " " & $Check2)
EndIf
WEnd #include <GUIConstantsEx.au3>
GUICreate("GUICtrlCreateLabel 函数演示",360,60)
GUICtrlCreateLabel("文本行 1",10,10,40)
GUICtrlCreateLabel("文本行 2",10,35)
GUISetState()
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE 简单的就是点击的时候判断下$radio就行了,不过不知道你的具体要求,没法说明白 回复 9# netegg
我写了4个小脚本 想让这个界面上有4个选择项 选中其中几个 或者全选 能让4个脚本按照选项从上到下顺序运行的。我现在不知道如何使界面的4个选项 分别指向这4个脚本 回复 10# 吕偏执先生
我那几个简单的测试代码学会了就能灵活运用,不能做伸手党! 回复netegg
我写了4个小脚本 想让这个界面上有4个选择项 选中其中几个 或者全选 能让4个脚本按 ...
吕偏执先生 发表于 2013-4-24 09:41 http://www.autoitx.com/images/common/back.gif
没搞明白你想要那样?
我的理解是:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#region ### START Koda GUI section ### Form=
Local $Radio
$Form1 = GUICreate("Form1", 218, 449, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Radio = GUICtrlCreateCheckbox("Radio1", 48, 32, 113, 17)
$Radio = GUICtrlCreateCheckbox("Radio2", 48, 88, 113, 17)
$Radio = GUICtrlCreateCheckbox("Radio3", 56, 136, 113, 17)
$Radio = GUICtrlCreateCheckbox("Radio4", 56, 192, 113, 17)
$Button1 = GUICtrlCreateButton("Button1", 72, 280, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
Sleep(10)
WEnd
Func Button1Click()
If GUICtrlRead($Radio) = $GUI_CHECKED Then
MsgBox(0, '', '你选择了' & GUICtrlRead($Radio,1))
EndIf
If GUICtrlRead($Radio) = $GUI_CHECKED Then
MsgBox(0, '', '你选择了' & GUICtrlRead($Radio,1))
EndIf
If GUICtrlRead($Radio) = $GUI_CHECKED Then
MsgBox(0, '', '你选择了' & GUICtrlRead($Radio,1))
EndIf
If GUICtrlRead($Radio) = $GUI_CHECKED Then
MsgBox(0, '', '你选择了' & GUICtrlRead($Radio,1))
EndIf
EndFunc ;==>Button1Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
按钮应该是复选框吧。怎么是单选框呢? 本帖最后由 netegg 于 2013-4-24 12:23 编辑
懒得写全了
while 1
switch guigetmsg()
case
case
case
case
endselect
wend #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = Guicreate("界面操作", 220, 160, -1, -1)
$Button1 = GuiCtrlCreateButton("全選", 10, 110, 50, 20)
$Button2 = GuiCtrlCreateButton("取消全選", 80, 110, 60, 20)
$Button3 = GuiCtrlCreateButton("運行", 150, 110, 50, 20)
$Checkbox1 = GUICtrlCreateCheckbox("腳本1", 20, 20, 80, 20)
$Checkbox2 = GUICtrlCreateCheckbox("腳本2", 130, 20, 80, 20)
$Checkbox3 = GUICtrlCreateCheckbox("腳本3", 20, 70, 80, 20)
$Checkbox4 = GUICtrlCreateCheckbox("腳本4", 130, 70, 80, 20)
GuiSetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetState($Checkbox1,$GUI_CHECKED)
GUICtrlSetState($Checkbox2,$GUI_CHECKED)
GUICtrlSetState($Checkbox3,$GUI_CHECKED)
GUICtrlSetState($Checkbox4,$GUI_CHECKED)
Case $Button2
GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox2,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox3,$GUI_UNCHECKED)
GUICtrlSetState($Checkbox4,$GUI_UNCHECKED)
Case $Button3
If BitAND(GUICtrlRead($Checkbox1),$gui_checked) Then
RunWait("界面操作\腳本1.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox2),$gui_checked) Then
RunWait("界面操作\腳本2.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox3),$gui_checked) Then
RunWait("界面操作\腳本3.exe",@ScriptDir)
EndIf
If BitAND(GUICtrlRead($Checkbox4),$gui_checked) Then
RunWait("界面操作\腳本4.exe",@ScriptDir)
EndIf
EndSwitch
Wend
页:
[1]
2