为什么会出现热键失效
#AutoIt3Wrapper_Icon=PalmOS.ico#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
HotKeySet("{F1}","zx28")
HotKeySet("{F2}","zx28j")
hotkeyset("{F3}","DHS36")
hotkeyset("{F4}","DHS36jl")
HotKeySet("{F6}","copy")
HotKeySet("{F7}","sys")
HotKeySet("{F9}","dlink3226p")
HotKeySet("{F10}","dlink3226pjl")
hotkeyset("{end}","_exit")
$w=GUICreate("交换机配置选择窗口",450,450)
GUISetFont(15, 400)
GUICtrlCreateLabel("通用交换机vlan自动配置:",110,30,360,60)
GUISetFont(9.5, 400)
$b1=GUICtrlCreateButton("中兴28按钮",120,100,80,30)
$b4=GUICtrlCreateButton("DLINK32按钮",250,100,80,30)
$b5=GUICtrlCreateButton("DLINK36按钮",120,150,80,30)
$b6=GUICtrlCreateButton("DLINK3226P",250,150,80,30)
GUISetFont(12, 400)
GUICtrlCreateGroup("", 120, 210, 210, 140)
GUICtrlCreateLabel("请按键选择需要做数据的交换机类型,退出做数据请按end按钮回到主界面:",130,230,190,100)
$w1=GUICreate("中兴交换机vlan自动配置",450,450)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F1做单交换机vlan:",130,5,280,20)
$a=GUICtrlCreateInput("",130,30,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入pvid开始vlan:",5,30,120,20)
$b=GUICtrlCreateInput("",130,60,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入端口数:",5,60,90,20)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F2做级联vlan:",130,120,300,20)
$c=GUICtrlCreateInput("",130,150,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联开始vlan:",5,150,120,20)
$d=GUICtrlCreateInput("",130,180,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联截止vlan:",5,180,120,20)
$e=GUICtrlCreateInput("1-",130,210,280,20)
GUICtrlCreateLabel("请输入级联端口",5,210,120,20)
$f=GUICtrlCreateButton("退出",200,250,60,30)
$w2=GUICreate("dlink交换机vlan自动配置程序",450,450)
GUICtrlCreateLabel("请激活交换机窗口后按F6做pvid",120,10,200,30)
$a1=GUICtrlCreateInput("16",110,30,220,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入端口数:",5,30,100,30)
$c1=GUICtrlCreateInput("1101",110,60,220,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入端口pvid:",5,60,100,30)
GUICtrlCreateLabel("请激活交换机窗口后按F7做vlan级联vlan",120,120,230,30)
$e1=GUICtrlCreateInput("1105",110,150,220,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输开始vlan:",5,150,100,30)
$f1=GUICtrlCreateInput("1121",110,180,220,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输结束vlan:",5,180,100,30)
$g1=GUICtrlCreateInput("eeeeee",110,210,220,20)
GUICtrlCreateLabel("请输入成员数:",5,210,100,30)
$h1=GUICtrlCreateInput("tttttt",110,240,220,20)
GUICtrlCreateLabel("请输入tag数:",5,240,100,30)
$l1=GUICtrlCreateInput("3226",110,270,220,20)
GUICtrlCreateLabel("请输入型号:",5,270,100,30)
$m1 = GUICtrlCreateButton("telnet",350,300,60,30)
$n=GUICtrlCreateInput("10.",110,300,220,20)
GUICtrlCreateLabel("请输入ip地址:",5,300,100,30)
$w3=GUICreate("交换机36系列vlan自动配置程序",450,450)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F3:",100,30,200,30)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F4: ",100,120,200,30)
$a2=GUICtrlCreateInput("",130,60,200,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入端口数:",5,60,80,20)
$b2=GUICtrlCreateInput("",130,90,200,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入开始vlan:",5,90,90,20)
$a3=GUICtrlCreateInput("",130,150,200,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联开始vlan:",5,150,120,20)
$b3=GUICtrlCreateInput("",130,180,200,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联结束vlan:",5,180,120,20)
$c2=GUICtrlCreateInput("1-",130,210,200,20)
GUICtrlCreateLabel("请输入级联端口:",5,210,120,20)
$w4=GUICreate("dlink3226p vlan自动配置",450,450)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F9做单机vlan:",130,5,280,20)
$n1=GUICtrlCreateInput("",130,30,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入pvid开始vlan:",5,30,120,20)
GUICtrlCreateLabel("请激活交换机登陆窗口后按F10做级联vlan:",130,120,300,20)
$n2=GUICtrlCreateInput("",130,150,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联开始vlan:",5,150,120,20)
$n3=GUICtrlCreateInput("",130,180,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联截止vlan:",5,180,120,20)
$n4=GUICtrlCreateInput("1",130,210,280,20,BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlCreateLabel("请输入级联端口",5,210,120,20)
GUISwitch($w)
GUISetState(@SW_SHOW)
Func _exit()
GUISetState(@SW_HIDE)
GUISwitch($w)
GUISetState(@SW_SHOW)
while 1
$nmsg=GUIGetMsg(1)
Switch $nmsg
case $GUI_EVENT_CLOSE
switch $nmsg
case $w
Exit
case $w1
GUISwitch($w1)
GUISetState(@SW_HIDE,$w1)
guisetstate(@sw_show,$w)
case $w2
GUISwitch($w2)
GUISetState(@SW_HIDE,$w2)
guisetstate(@sw_show,$w)
case $w3
GUISwitch($w3)
GUISetState(@SW_HIDE,$w3)
guisetstate(@sw_show,$w)
case $w4
GUISwitch($w4)
GUISetState(@SW_HIDE,$w4)
guisetstate(@sw_show,$w)
EndSwitch
case $b1
GUISwitch($w1)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w1)
case $b4
GUISwitch($w2)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w2)
case $b5
GUISwitch($w3)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w3)
case $b6
GUISwitch($w4)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w4)
case $f
GUISwitch($w1)
GUISetState(@SW_HIDE,$w1)
GUISetState(@SW_SHOW,$w)
case $m1
GUISwitch($w2)
run("telnet " & GUICtrlRead($n))
endswitch
wend
endfunc
Func copy()
$b=GUICtrlRead($a1)
$d=GUICtrlRead($c1)
for $i=1 to $b step 1
sleep(50)
send($i & "{down}")
sleep(50)
send($i & "{down}")
sleep(50)
send($d & "{down}")
sleep(50)
$d=$d+1
send("{Enter}")
sleep(100)
send("{down}")
sleep(100)
Next
EndFunc
Func sys()
$xinhao=GUICtrlRead($l1)
select
Case $xinhao=3226
$a1=GUICtrlRead($e1)
$a2=GUICtrlRead($f1)
$a3=GUICtrlRead($g1)
$a4=GUICtrlRead($h1)
$i1=$a1
if $a2>$a1 then
for $i1=$a1 to $a2 step 1
sleep(100)
send($i1 & "{down 2}")
sleep(100)
send($a3 & "{down 3}")
sleep(100)
send($a4 & "{down 3}")
sleep(100)
send("{Enter 2}")
sleep(100)
send("{down}")
sleep(100)
Next
else
MsgBox(0,"vlan输入错误","vlan输入错误请重新输入")
endif
case $xinhao=3218
$b1=GUICtrlRead($e1)
$b2=GUICtrlRead($f1)
$b3=GUICtrlRead($g1)
$b4=GUICtrlRead($h1)
$i1=$b1
if $b2>$b1 then
for $i1=$b1 to $b2 step 1
sleep(100)
send($i1 & "{down 2}")
sleep(100)
send($b3 & "{down 2}")
sleep(100)
send($b4 & "{down 2}")
sleep(100)
send("{Enter 2}")
sleep(100)
send("{down}")
sleep(100)
Next
else
MsgBox(0,"vlan输入错误","vlan输入错误请重新输入")
endif
case Else
MsgBox(0,"输入型号","错误")
EndSelect
EndFunc
Func zx28j()
if GUICtrlRead($d)>GUICtrlRead($c) then
for $i=GUICtrlRead($c) to GUICtrlRead($d) step 1
send("create vlan " & $i & " name v" & $i & "{enter}")
send("set vlan " & $i & " enable" & "{enter}")
send("set vlan " & $i & " add port " & GUICtrlRead($e) & " tag" & "{enter}")
next
send("save" & "{enter}")
else
MsgBox(0,"vlan输入错误","vlan输入错误请重新输入")
endif
EndFunc
Func zx28()
$j=GUICtrlRead($a)
for $i=1 to GUICtrlRead($b) Step 1
send("create vlan " & $j & " name v" & $j & "{enter}")
send("set vlan " & $j & " add port 1 tag" & "{enter}")
send("set vlan " & $j & " add port " & $i & " untag" & "{enter}")
send("set port " & $i & " pvid " & $j & "{enter}")
send("set vlan " & $j & " enable" & "{enter}")
$j = $j+1
next
send("save" & "{enter}")
EndFunc
Func DHS36()
$c=GUICtrlRead($a2)
$d=GUICtrlRead($b2)
send("conf vlan default del" & " 1-" & $c)
send("{enter}")
for $i=1 to $c step 1
sleep(50)
send("creat vlan v" & $d & " tag " & $d & "{enter}")
sleep(50)
send("conf vlan v" & $d & " add tag " & $c-1 & "-" & $c & "{enter}")
send("conf vlan v" & $d & " add untag " & $i & "{enter}")
$d=$d+1
Next
send("save" & "{Enter}")
EndFunc
Func DHS36jl()
ifGUICtrlRead($b3)>GUICtrlRead($a3) Then
for $j=GUICtrlRead($a3) to GUICtrlRead($b3) step 1
send("creat vlan v" & $j & " tag " & $j & "{enter}")
send("conf vlan v" & $j & " add tag " & GUICtrlRead($c2) & "{enter}")
Next
send("save" & "{Enter}")
else
MsgBox(0,"vlan输入错误","vlan输入错误请重新输入")
endif
EndFunc
Func dlink3226p()
$v=GUICtrlRead($n1)
$u=GUICtrlRead($n1)+23
send("configure" & "{enter}" & "vlan database" & "{enter}" & "vlan " & GUICtrlRead($n1) & "-" & $u & "{enter}" & "exit" & "{enter}")
send("int eth 25" & "{enter}" & "switch mode trunk" & "{enter}" & "switch trunk allow vlan add " & GUICtrlRead($n1) & "-" & $u & "{enter}")
for $i=1 to 24 step 1
send("int eth " & $i & "{enter}" & "switch access vlan " & $v & "{enter}")
$v=$v+1
next
send("end" & "{enter}" & "copy run start" & "{enter}")
sleep(100)
send("yes" & "{enter}")
EndFunc
Func dlink3226pjl()
$u=guictrlread($n3)
$v=guictrlread($n2)
if $u>$v then
send("config" & "{enter}" & "int eth " & guictrlread($n4) & "{enter}")
send("switch mode trunk" & "{enter}" & "switch trunk allow vlan add " & $v & "-" & $u & "{enter}")
send("end" & "{enter}" & "copy run start" & "{enter}")
sleep(100)
send("yes" & "{enter}")
else
MsgBox(0,"vlan输入错误","vlan输入错误请重新输入")
endif
EndFunc
while 1
$nmsg=GUIGetMsg(1)
Switch $nmsg
case $GUI_EVENT_CLOSE
switch $nmsg
case $w
Exit
case $w1
GUISwitch($w1)
GUISetState(@SW_HIDE,$w1)
guisetstate(@sw_show,$w)
case $w2
GUISwitch($w2)
GUISetState(@SW_HIDE,$w2)
guisetstate(@sw_show,$w)
case $w3
GUISwitch($w3)
GUISetState(@SW_HIDE,$w3)
guisetstate(@sw_show,$w)
case $w4
GUISwitch($w4)
GUISetState(@SW_HIDE,$w4)
guisetstate(@sw_show,$w)
EndSwitch
case $b1
GUISwitch($w1)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w1)
case $b4
GUISwitch($w2)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w2)
case $b5
GUISwitch($w3)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w3)
case $b6
GUISwitch($w4)
GUISetState(@SW_HIDE,$w)
GUISetState(@SW_SHOW,$w4)
case $f
GUISwitch($w1)
GUISetState(@SW_HIDE,$w1)
GUISetState(@SW_SHOW,$w)
case $m1
GUISwitch($w2)
run("telnet " & GUICtrlRead($n))
endswitch
WEnd
现有问题,按了F7后,按F6就不起作用,其它热键都正常.原来是变量重复引起的,谢谢大家了。以后确实要注意变量的定义了,主要是english太差了。
[ 本帖最后由 bin0131 于 2009-2-22 19:01 编辑 ] 似乎代码不完整,光看上述代码看不出有什么问题。 自己顶一下先了 我想问一下, send($i & "{down}")是什么意思?
$i是数字,也就是说,Send(1 & "{down}")
不知道你怎么理解这个的,按一次向下的方向键??Send好像不是这样用的,语法错误。
另外,你编程的习惯实在是……a,b,c,m,i这样的变量,恐怕过2个月,你自己都看不懂你写什么东西 这个应该没关系,功能可以实现的,就是按了F7后,按F6就不起作用 是冲突还是程序自身问题,编一个简单的代码测试一下就知道。
HotKeySet("{f6}","_f6")
HotKeySet("{f7}","_f7")
HotKeySet("{esc}","_exit")
While 1
sleep(100)
WEnd
Func _f6()
MsgBox(0,0,"F6========",1)
EndFunc
Func _f7()
MsgBox(0,0,"F7........",1)
EndFunc
Func _exit()
MsgBox(0,0,"拜拜******",1)
Exit
EndFunc
[ 本帖最后由 顽固不化 于 2009-2-21 15:02 编辑 ] 那程序有什么问题呢? 其它都没问题,为什么就F7与F6之间有以上问题那? 怎么解决的
页:
[1]