求一个autohotkey鼠标脚本脚本

一个非常棒的AutoHotKey脚本 - 疯狂的菠菜 - ITeye技术网站
博客分类:
引用; Function to run a program or activate an already running instance
RunOrActivateProgram(Program, WorkingDir="", WindowSize=""){
&&& SplitPath Program, ExeFile
&&& Process, Exist, %ExeFile%
&&& PID = %ErrorLevel%
&&& if (PID = 0) {
&&&
Run, %Program%, %WorkingDir%, %WindowSize%
&&& }else{
&&&
WinActivate, ahk_pid %PID%
&&& }
}
^!w::RunOrActivateProgram("D:\Program Files\EditPlus\editplus.exe")
^!f::RunOrActivateProgram("C:\Program Files\mozilla firefox\firefox.exe")
^!o::RunOrActivateProgram("C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE")
^!c::RunOrActivateProgram("D:\Program Files\SecureCRT+FX\SecureCRT.exe")
^!d::RunOrActivateProgram("D:\Program Files\Q-Dir\Q-Dir.exe")
^!e::RunOrActivateProgram("D:\eclipse\eclipse-java-helios-win32\eclipse.exe")
我觉得RunOrActivateProgram是一个非常棒的万能函数, 我用它定义了一些快捷键, 在我常用的程序之间切换
浏览: 1887616 次
来自: 杭州
先点个赞,写的非常好!有个问题请教下,如果我再bolt里不用e ...
能不能直接弄个demo
现在这么用(JDK7将实现该功能): 这个说法是错误的,JDK ...关注51Testing
如何编写AutoHotKey的脚本
发表于: 14:34 &作者:Kiki & 来源:Kiki的专栏
推荐标签:
&&&&&&&介绍了AutoHotKey的基本功能和大致模块,这次用一个简单的例子来说说AutoHotKey的脚本编写。和流行的工具一样,可以通过录制在编写脚本,也可以直接手工写脚本。但是对于GUI的应用程序来说,基本上都需要录制操作,生成针对记录游历过的对象或坐标的脚本。AutoHotKey功能相对简单,基本上只记录坐标,少数对于Window的操作是用对象表示的,相当于流行自动化中的低级录制。&&&&&&& 下面就是我用AutoHotKey中的AutoScriptWriter (recorder)录制打开桌面坐下方“Quick Launch”栏中的IE浏览器,然后在地址栏中直接输入,然后回车,在google的搜索中输入,在回车的一个过程。---------WinWait, ,IfWinNotActive, , , WinActivate, ,WinWaitActive, ,MouseClick, left,& 125,& 22Sleep, 100WinWait, Blank Page -
Internet Explorer,IfWinNotActive, Blank Page - Windows Internet Explorer, , WinActivate, Blank Page - Windows Internet Explorer,WinWaitActive, Blank Page - Windows Internet Explorer,Send,}WinWait, Google - Windows Internet Explorer,IfWinNotActive, Google - Windows Internet Explorer, , WinActivate, Google - Windows Internet Explorer,WinWaitActive, Google - Windows Internet Explorer,Send, test{ENTER}WinWait, test - Google Search - Windows Internet Explorer,IfWinNotActive, test - Google Search - Windows Internet Explorer, , WinActivate, test - Google Search - Windows Internet Explorer,WinWaitActive, test - Google Search - Windows Internet Explorer,MouseClick, left,& 1016,& 13Sleep, 100--------------&&&&&&& 大家可以看到输入用Send, &字符&表示,点击为MouseClick, left,& &x&,& &y&。至于很多的IfWinNotActive类似于测试工具中的同步语句。因为坐标经常会变,所以如果能用按键的尽量用按键,避免坐标。象上面的Enter其实是可以用鼠标点击“Google search”按钮来实现的,但保险起见用Enter键更好。&&&&&&& AutoHotKey也提供比较好的脚本语言,还是和vbscript比较相似。很好,可以打开AutoHotkey Help File来查找。经过简单的修改后,脚本如下:--------------Run %A_ProgramFiles%\Internet Explorer\iexplore.exe&&&&&&&&&&&&&&&&&&&& ; start IE browserSleep 5000&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; wait launch IE browserSend,}&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; input google's website in address barSleep 5000&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; wait open google's home pageSend, test{ENTER}&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; input keyword in search fieldSleep 5000&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; wait search resultMouseClick, left,& 1016,& 13&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; click x button to close IE window--------------&&&&&&& 在上面的脚本我用Sleep来同步操作,其实还有很多别的方法,例如WaitObject语句就是通过等待某个区域或点的颜色为期望的颜色时执行下一步操作,还有类似等待某个图片的。由于不提供针对对象的,的方式不是太灵活而且太多地方需要使用,也就没有采用。对于一些比较重要的地方,可以使用如下方法Loop, 5{IfWinExist, Save As&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; check whether Save As dialogbox existsbreakelsesleep %ShortSleepTime%}&&&&&&& 关闭窗口也可以用WinClose, A来关闭当前活动的窗口。类似还有很多的这样的语句,就和以前写代码一样,唯一的就是没发现可以调用其他的脚本,只能在当前脚本内有效。不过自己本来就不是正道使用,呵呵。&&&&&&& 先说到这,有兴趣的朋友可以一起探讨。更多工具的文章:
官方活动:
搜索风云榜
51Testing官方微信
51Testing官方微博
测试知识全知道

参考资料

 

随机推荐