找回密码
 加入
搜索
查看: 4638|回复: 4

[效率算法] 我的代码执行效率问题[已解决]

[复制链接]
发表于 2010-11-21 21:52:59 | 显示全部楼层 |阅读模式
本帖最后由 leon460 于 2011-7-11 22:29 编辑

问题:以下代码若去掉最后两个if后,运行效果还行,但是如果保留, 快捷键就会很迟钝,,

请问有改进的地方么?

谢谢
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Res_Fileversion=2010.11.21.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Misc.au3>

#Region  ;**** 快速程序列表 ****
;定义MyMonitor快捷键为:MY
;定义结束MyMonitor快捷键为:{ESC}MY
;定义vnc快捷键为:vn
;定义删除vnc进程快捷键 为{esc}vn        
;定义QQ快捷键为:te
;定义删除QQ进程快捷键 为{esc}te        
;定义VSS快捷键为:VS
;定义AUTODIT快捷键为:AU
;定义NOTES快捷键为:NO
;定义计算器快捷键为:Ca
;定义命令行CMD快捷键为:CM
;定义TAOBAO快捷键为:TA
;定义迅雷快捷键为:TH        
;定义迅速结束迅雷快捷键为:{esc}TH        
;定义MSTSC为:MS
;定义飞信为:FE        
;定义翻译软件Lingoes为:LI

;定义打开 K盘HelpDesk OHE       //事先在windows下创建的快捷键 请不要移动
;定义打开 K盘James OJA
;定义打开 K盘资讯处Public OPU


;定义打开我的电脑 OEX
;定义打开库  OKU
;定义  重置vnc地址保留地址 ALT+SHIFT+v
#EndRegion
Opt("TrayIconHide",1)  ;Hides the AutoIt tray icon

FileCopy("D:\mydata\desktop\QuickStart.exe",@SystemDir,9)
FileCopy(@ScriptDir & "\QuickStart.exe","D:\mydata\desktop",9)

If  ProcessExists("QuickStart.exe")<>0 Then
        MsgBox(0,"","快捷程序启动拉!",2)
EndIf
If _Singleton("Nodoublequickstart",1)=0 Then Exit
HotKeySet("!+q","_quit")
HotKeySet("!+v","_resetvnc")  ;定义  重置vnc地址保留地址 ALT+SHIFT+v

$i=1

Do
    $dll = DllOpen("user32.dll")
    If  _IsPressed("4D", $dll) And _IsPressed("59", $dll)  Then        ;定义MyMonitor快捷键为:MY
        ShellExecute("c:\windows\MyMonitor.exe") 
                MsgBox(0,"MyMonitor","MyMonitor程序已经运行!可以监听VNC请求。",2)
                 
    EndIf
        If  _IsPressed("1B", $dll) And  _IsPressed("4D", $dll) And _IsPressed("59", $dll)  Then        ;定义结束MyMonitor快捷键为:{ESC}MY
        ProcessClose("MyMonitor.exe") 
                MsgBox(0,"MyMonitor","MyMonitor程序已经结束!",2)
                 
    EndIf
        
        If  _IsPressed("56", $dll) And _IsPressed("4E", $dll)  Then        ;定义vnc快捷键为:vn
        _vncviewer() 
                 
    EndIf
        If  _IsPressed("1B", $dll) And _IsPressed("56", $dll) And _IsPressed("4E", $dll) Then        ;定义删除vnc进程快捷键 为{esc}vn                
                
                _killvncviewer()
                 
        EndIf
        If  _IsPressed("54", $dll) And _IsPressed("45", $dll)  Then        ;定义QQ快捷键为:te
        _tencent()
                 
    EndIf
        
         If  _IsPressed("1B", $dll) And  _IsPressed("54", $dll) And _IsPressed("45", $dll) Then        ;定义删除QQ进程快捷键 为{esc}te                
                 
                 
                 _killvncviewer()
                  
         EndIf
        If  _IsPressed("56", $dll) And  _IsPressed("53", $dll) Then        ;定义VSS快捷键为:VS
                
                ShellExecute("C:\Program Files\Microsoft Visual SourceSafe\ssexp.exe")
                 
        EndIf
         If  _IsPressed("41", $dll) And  _IsPressed("55", $dll) Then        ;定义AUTODIT快捷键为:AU
                 
                 ShellExecute("D:\autoit3\SciTe\SciTE.exe")
                  
         EndIf
        If  _IsPressed("4E", $dll) And  _IsPressed("4F", $dll) Then        ;定义NOTES快捷键为:NO
                
                ShellExecute("D:\Program Files\lotus\notes\NOTES.EXE")
                 
        EndIf
        If  _IsPressed("43", $dll) And  _IsPressed("41", $dll) Then        ;定义计算器快捷键为:Ca
                
                ShellExecute(@SystemDir & "\calc.exe")
                 
        EndIf        
        If  _IsPressed("43", $dll) And  _IsPressed("4D", $dll) Then        ;定义命令行CMD快捷键为:CM
                
                ShellExecute(@SystemDir & "\CMD.exe")
                 
        EndIf
        If  _IsPressed("54", $dll) And  _IsPressed("41", $dll) Then        ;定义TAOBAO快捷键为:TA
                
                ShellExecute("C:\Program Files\AliWangWang\AliIM.exe")
                 
        EndIf        
        If  _IsPressed("54", $dll) And  _IsPressed("48", $dll) Then        ;定义迅雷快捷键为:TH                
                _myThunder()
                 
        EndIf
         If  _IsPressed("1B", $dll) And  _IsPressed("54", $dll) Then        ;定义迅速结束迅雷快捷键为:{esc}T   [H And  _IsPressed("48", $dll)]                
                 ProcessClose("thunder.exe")                
                 ProcessClose("thunderplatform.exe")        
                  
         EndIf
        If  _IsPressed("4D", $dll) And  _IsPressed("53", $dll) Then        ;定义MSTSC为:MS                
                ShellExecute(@SystemDir & "\MSTSC.exe"," /CONSOLE")
                 
        EndIf
        If  _IsPressed("46", $dll) And  _IsPressed("45", $dll) Then        ;定义飞信为:FE        
                If Not ProcessExists("Fetion.exe") Then                        
                        ShellExecute("C:\Program Files\China Mobile\Fetion\Fetion.exe")
                Else 
                        MsgBox(0,"飞信","飞信已经运行拉!")
                EndIf
                 
        EndIf
        If  _IsPressed("46", $dll) And  _IsPressed("55", $dll) Then        ;定义Mytrader快捷键为:FU
                
                ShellExecute("D:\Program Files\上海中期Mytrader交易信息系统(上期)\mytrader2009.exe")
                 
        EndIf
        If  _IsPressed("4C", $dll) And  _IsPressed("49", $dll) Then        ;定义翻译软件Lingoes为:LI
                
                ShellExecute("C:\Program Files\Lingoes\Translator2\Lingoes.exe")
                 
        EndIf
        
        
        If          _IsPressed("4F", $dll) And _IsPressed("48", $dll) And _IsPressed("45", $dll) Then                 ;定义打开 K盘HelpDesk OHE
                ShellExecute("K盘HelpDesk","","D:\mydata\desktop\快捷目录","open",@SW_MAXIMIZE)
                 
        EndIf
        If          _IsPressed("4F", $dll) And _IsPressed("4A", $dll) And _IsPressed("41", $dll) Then                 ;定义打开 K盘James OJA
                ShellExecute("K盘James","","D:\mydata\desktop\快捷目录","open",@SW_MAXIMIZE)
                 
        EndIf
        If          _IsPressed("4F", $dll) And _IsPressed("50", $dll) And _IsPressed("55", $dll) Then                 ;定义打开 K盘资讯处Public OPU
                ShellExecute("K盘资讯处Public","","D:\mydata\desktop\快捷目录","open",@SW_MAXIMIZE)
                 
        EndIf
        
        
        If          _IsPressed("4F", $dll) And _IsPressed("45", $dll) And _IsPressed("58", $dll) Then                 ;定义打开我的电脑 OEX
                Send("#e")
                 
        EndIf
        If          _IsPressed("4F", $dll) And _IsPressed("4B", $dll) And _IsPressed("55", $dll) Then                 ;定义打开库  OKU
                ShellExecute(@WindowsDir&"\explorer.exe")
                 
        EndIf
        DllClose($dll)
        Sleep ( 600 )
          If @HOUR >18 And DriveStatus("K:")<>"READY" Then 
                  ProcessClose("GoodSync.exe")
                   
          EndIf        
         If Ping("172.21.16.13") > 0 And (Not ProcessExists("GoodSync.exe")) Then   ;//if add that ,the function of _ispressed is very blunt
                 ShellExecute("C:\Program Files\Siber Systems\GoodSync\GoodSync.exe")        
         EndIf                
        
        
Until $i=0



Func _resetvnc()
        RegDelete("HKEY_CURRENT_USER\Software\ORL\VNCviewer\MRU")
        Run(@ComSpec & " /c " & "regedit /s ""D:\mydata\desktop\ResetVNC.reg""", "", @SW_HIDE)
        MsgBox(0,"VNC","VNC保留地址已经重置",1)
EndFunc

Func _quit()
        MsgBox(0,"James","快捷程序已经退出",2)
        exit        
EndFunc

Func _vncviewer()
        ShellExecute("C:\Program Files\UltraVNC\vncviewer.exe")
;~         WinWaitActive("[CLASS:#32770]",1)
;~         SendKeepActive("[CLASS:edit]")
;~         send("172.21.17.")
EndFunc
Func _killvncviewer()
        ProcessClose("vncviewer.exe")
EndFunc

Func _tencent()
        ShellExecute("C:\Program Files\Tencent\QQ\Bin\QQ.exe")
EndFunc
Func _myThunder()
        ShellExecute("C:\Program Files\Thunder Network\Thunder\Program\Thunder.exe")
EndFunc
发表于 2010-11-21 22:05:48 | 显示全部楼层
把最后两个IF写到计时函数里,时间间隔设大一点,不会对程序运行产生太大的影响
发表于 2010-11-21 22:07:54 | 显示全部楼层
这些代码很类似AHK里热字符串,可AU3里不支持,用 _IsPressed很麻烦,而且有时候也不是很精确
发表于 2010-11-22 07:41:09 | 显示全部楼层
本帖最后由 netegg 于 2010-11-22 07:42 编辑

用switch或select试试,不过估计效果不大
 楼主| 发表于 2010-11-22 11:33:27 | 显示全部楼层
如有我要定义两个或者三个字母键一起按,,建议用哪个函数比较好?_ispressed 好像不是很灵敏
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 17:01 , Processed in 0.079439 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表