; ~ Small portion of the test AutoHotkey script source code template model .ahk

;

 

; ~ Small portion of the test AutoHotkey script source code template model .ahk

 

; ~ Please put a small amount of one or more lines of code into this file, the actual test,
; ~ to see how the test results, when the code function can be achieved until then copy it to your own script code file
; ~ constant testing, continuous improvement, continuously refining, continuous optimization,
; ~ to the code package label or a subroutine or function-based process in (object) name, thereby facilitating re-use in future similar codes
; ~ Please SciTE4AutoHotkey script editor shortcut key <F5> and test run the script code snippet
; ~ minus the selected block of source code or shortcut key numeric keypad comment block Ctrl + Q

TestAutoHotkeyCode Test Fragment _ 1st function ()
{
WinActivate, SciTE4AutoHotkey ahk_class SciTEWindow ahk_exe SciTE.exe
WinWaitActive, SciTE4AutoHotkey ahk_class SciTEWindow ahk_exe SciTE.exe
the Send, FS {} {AltDown AltUp}
; ========== press F5 test code runs after the beginning of the next line hotkey ==========

SetTimer, RunExeFile run the program _03, -100
SetTimer, SwitchToThisWindow active window _04,100
SetTimer, ControlSend send simulated keystrokes to control _06,100
SetTimer, ControlClick send mouse button or mouse wheel event to a control _07,100
SetTimer, SetTimerDelete disable and delete all Timer auto-repeat cycle operation routines _08,100

; ========== by running the hot key F5 to the end of a line test code ==============
}

;~ http://www.autoahk.com/archives/16127
;
;~ https://gitee.com/weiyunwps618/codes/h45dz2c31nrqwtm8ufxyv57
;~ https://www.cnblogs.com/delphixx/p/11812580.html

Parameters for this ConfigThisScript script _ second function (); calls the function directly by the function name, the function as the code in the body where
TestAutoHotkeyCode test code fragment _ a first function ()
Hotkey, the F5, the new script examples replace the currently running instance of _ the first three functions; create and enable a hot key, when the user inputs a hot key to perform the function pointed to hotkey immediately.
return; Because this script is set up so the script will wait hotkey shortcut key is pressed, then the script will not quit

Alternatively _ currently running instance of the third function () with the new instance of the script
{
Reload
}

Parameters for this ConfigThisScript script _ second function ()
{
# the SingleInstance, Force; When this script has run automatically replace the old instance run again.
#Persistent; let the script run lasting (that is, until the user closes or experiencing ExitApp).
#NoEnv; does not check whether a variable is empty environment variables (recommended for all new scripts).
#WinActivateForce; active window method mandatory. Taskbar button to stop flashing.
; ~ #NoTrayIcon; tray icon does not display.
; ~ #Warn;. WarningMode all warnings specified application types supported by
SetWorkingDir,% A_ScriptDir%; change the current working directory script.
DetectHiddenWindows, On; setup script can "see" hidden window.
SetTitleMatchMode, 2; window title match mode into a position must include WinTitle.
SendMode, Input; SendInput generally faster and more reliable buffer any physical keyboard or mouse activity during transmission to avoid the inclusion of users when sending keystrokes.

CoordMode,Mouse,Screen
CoordMode,Pixel,Screen
CoordMode,ToolTip,Screen
ListLines,Off
SetBatchLines,-1
SetStoreCapsLockMode, On

;~ SetBatchLines,
;~ SetKeyDelay,
;~ SetWinDelay,
;~ SetControlDelay,
}

; ========== 函数定义代码块段落代码从下一行开始,接下来集中定义各类函数,函数名以两位数字序号后缀结尾 ==========

RunExeFile运行程序_03()
{
IfWinNotExist,记事本 ahk_class Notepad
Run,notepad
}

SwitchToThisWindow激活窗口_04()
{
IfWinNotActive,记事本
{
;~ WinActivate [, WinTitle, WinText, ExcludeTitle, ExcludeText]
WinGet, WinID, ID,记事本
DllCall("SwitchToThisWindow", "UInt", WinID, "UInt", 1)
;~ WinGetActiveTitle,WinActiveTitlekp
;~ IfInString,WinActiveTitlekp,窗口标题
}
}

ControlFocus设置焦点到指定控件_05()
{
;~ ControlFocus [, Control, WinTitle, WinText, ExcludeTitle, ExcludeText]
}

ControlSend发送模拟键击到控件_06()
{
IfWinActive,记事本
{
IfWinNotExist,打开 ahk_class #32770, 地址
{
ControlSend, Edit1,{CtrlDown}o{CtrlUp},记事本 ahk_class Notepad
}
}
}

ControlClick发送鼠标按钮或鼠标滚轮事件到控件_07()
{
;~ IfWinActive,记事本
;~ ControlClick [, Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText]
}

SetTimerDelete禁用并删除所有Timer自动重复周期运行子程序_08()
{
IfWinExist,记事本 ahk_class Notepad
{
IfWinActive,打开 ahk_class #32770, 地址
{
SetTimer,RunExeFile运行程序_03,Delete
SetTimer,SwitchToThisWindow激活窗口_04,Delete
;~ 不要使用某个功能函数时只需注释掉调用代码即可,无需注释函数体定义部分的代码
;~ SetTimer,ControlFocus设置焦点到指定控件_05,Delete
SetTimer,ControlSend发送模拟键击到控件_06,Delete
SetTimer,ControlClick发送鼠标按钮或鼠标滚轮事件到控件_07,Delete
SetTimer,SetTimerDelete禁用并删除所有Timer自动重复周期运行子程序_08,Delete

ToolTip,并发运行脚本测试完毕
SetTimer, RemoveToolTip定时关闭置顶提示窗口_09, 5000
}
}
}

; 让ToolTip提示在一段时间后消失
RemoveToolTip定时关闭置顶提示窗口_09:
SetTimer, RemoveToolTip定时关闭置顶提示窗口_09, Off
ToolTip
return

无条件终止此脚本()
{
ExitApp
}

; ===== 此脚本到此行结束 =====

 

 

 

 

 

;~ 【管理员】徐晓亮(595076941)
;~ 有了此QQ群和代码测试模板和百度这3个法宝就可以玩AutoHotkey脚本源代码
;~ 【管理员】徐晓亮(595076941)
;~ 就可以轻轻松松的玩AHK源代码了
;~ 【管理员】徐晓亮(595076941)
;~ 开始接受ahk的SciTE了,先搜集大量小工具(类似AHKInfo 1.3.5)或者用Delphi或Visual Studio 自制一些有特殊要求的小工具软件并手动集成到SciTE4AutoHotkey的工具栏中(最好有2行工具栏用于存放常用自制工具,这样在写源代码时比较方便快捷),最后还是要注意资源搜集,资源备份,资源全文检索,全网源代码搜索

;~ 小部分AutoHotkey源代码片段测试模板2019年9月22日.ahk

;~ 此脚本用于测试执行一行或多行AHK脚本源代码的效果
;~ 此脚本最后修改于2019年9月22日20时03分
;~ 把此源代码复制到SciTE4AutoHotkey文本编辑器中
;~ 在SciTE4AutoHotkey文本编辑器窗口中按快捷键F5运行脚本
;~ 在SciTE4AutoHotkey文本编辑器窗口中按快捷键Ctrl+Break终止此脚本运行
;~ 按快捷键F9运行需要测试的代码
;~ 选中源代码块后按快捷键 Ctrl+Q 注释代码块
;~ 请使用 "星雨朝霞" 制作的 "AHKInfo 1.3.5.ahk" 窗口信息抓取工具来获取控件操作源代码和控件的ClassNN类别名称

; 源代码作用:并发运行AHK脚本演示,脚本测试模板 打印日期:2019年10月10日 源代码作者:徐晓亮(aahk6188) 第X页【共Y页】


;~ Sleep,500
;~ WinClose, 桌面控制 ahk_class SDL_app ahk_exe SunloginClient.exe,
;~ Sleep,500
;~ WinKill, 桌面控制 ahk_class SDL_app ahk_exe SunloginClient.exe,
;等待指定标题窗口出现
;~ WinKill, 向日葵远程控制 ahk_class SDL_app ahk_exe SunloginClient.exe,

;~ WinKill, 桌面控制 ahk_class SDL_app ahk_exe SunloginClient.exe,
;~ Sleep,500
;~ Process,Close,SunloginClient.exe

;~ IfExist,C:\Program Files (x86)\Oray\SunLogin\SunloginClient\SunloginClient.exe
;~ Run,C:\Program Files (x86)\Oray\SunLogin\SunloginClient\SunloginClient.exe
;~ Sleep,5000
;~ IfWinNotExist,,连接服务器成功
;~ MsgBox,99999999999

;等待指定标题窗口出现
;~ Process,Exist,Executor.exe
;~ if (%ErrorLevel%=0)
;~ {
;~ MsgBox
;~ ToolTip,2222a
;~ }

;~ SetTimer,RunExeFile运行程序_03,-500
;~ SetTimer,SwitchToThisWindow激活窗口_04,500
;~ SetTimer,ControlSend发送模拟键击到控件_06,500
;~ SetTimer,ControlClick发送鼠标按钮或鼠标滚轮事件到控件_07,500
;~ SetTimer,SetTimerDelete禁用并删除所有Timer自动重复周期运行子程序_08,500

;~ 经过试验得知运行程序每次都成功所以这里用负数-500表示0.5秒后运行定时器函数
;~ 单次运行 [v1.0.46.16+]: 使用负的 周期 来表示计时器只运行一次.
;~ 例如,指定 -100 将会从现在开始的 100 ms 后运行计时器,
;~ 然后就像使用 SetTimer, Label, Off 那样禁用计时器。
;~ 不要使用某个功能函数时只需注释掉调用代码即可,无需注释函数体定义部分的代码
;~ SetTimer,ControlFocus设置焦点到指定控件_05,500

;~ 并发运行的AutoHotkey脚本真机实际测试模板参考20191010.ahk

;~ 在SciTE4AutoHotkey窗口中选中代码块并按<Ctrl>+Q 注释代码
;~ 在SciTE4AutoHotkey窗口中按<F5>运行脚本
;~ 按<F6>测试AHK代码片段
;~ 按<Ctrl>+<F6>无条件终止此脚本
;~ 按<F7>重新启动此脚本并测试代码片段
;~ 在SciTE4AutoHotkey窗口中按<Ctrl>+<Break>终止运行脚本

;~ 2019年10月10日
;~ 徐晓亮(aahk6188)
;~ 操作系统测试环境: Windows 7 专业版 32位 系统 On Website https://msdn.itellyou.cn/
;~ AHK系统测试环境: AutoHotkey_1.1.31.00_setup.exe On Website https://www.autohotkey.com/
;~ 并发运行可以防止错过对一些窗口的操作
;~ 并发运行可以精确等待操作时机的出现
;~ 并发运行可以使脚本运行更流畅,可以有效防止脚本应等待窗口或控件的出现而出现卡死现象

;~ Hotkey,F6,Hotkey_F6定义F6热键_01 ;创建并启用热键,当用户输入热键时立即执行热键所指向的函数。
;~ Hotkey,^F6,无条件终止此脚本
;~ Hotkey,F7,重新启动此脚本并测试代码片段
;~ 请在SciTE4AutoHotkey窗口中按<F5>运行脚本,, 在SciTE4AutoHotkey窗口中按<Ctrl>+<Break>终止运行脚本
;~ MsgBox,按<F6>快捷键打开记事本

;显示热键提示信息窗口并暂停脚本执行直到用户按确定按钮控件。

;~ 接下来定义函数名是“ConfigThisScript设置此脚本的参数_01() ”的函数,
;~ 便于用SetTimer定时器或直接通过函数名调用此函数,
;~ 函数类似于子程序 (Gosub), 不过它可以从调用者那里接受参数 (输入).
;~ 同时, 函数还可以返回值给其调用者.
;~ 函数可以减少代码书写量(代码复用,代码重用),只在一处统一定义函数可以有效防止代码不一致出错,
;~ 只在一处定义便于今后修改维护,实现模块化积木化编程,
;~ 把大的任务用SetTimer定时器函数的形式切割细分为很多小功能函数使得比较困难的事情容易实现,
;~ 在工作、学习、生活、社交、人生规划等方面也可以用笔在A4纸上切割和细分,以此类推,触类旁通。

;
; 本文的最后修改日期是 公元2019年11月07日
; 本文的网址是 https://gitee.com/weiyunwps618/codes
; 本文的网址是 https://www.cnblogs.com/delphixx
; 晓亮(weiyunwps618)的腾讯QQ邮箱地址是 [email protected]
; 晓亮(weiyunwps618)的中国移动手机号码是 138####5488 )
; 此AHK脚本的测试环境是 Windows 7 Pro SP1 VL 和 AutoHotkey v1.1.30.01
;

Guess you like

Origin www.cnblogs.com/delphixx/p/11812580.html