开机时自动启动的AutoHotkey脚本 2019年10月09日

;
;
; 开机时自动启动的AutoHotkey脚本 2019年10月09日
;
; http://www.autoahk.com/archives/16600
; https://www.cnblogs.com/delphixx/p/11965929.html
;
; 计时器创建代码段 -----------------------------------------------------------------------------------------
; SetTimer可以模拟多线程从而不影响主线程的流畅执行
; 请在SciTE4AutoHotkey中选中单词并按快捷键F12跳转到函数定义处
; 绿色免安装程序,统一都分类保存在本地磁盘D分区文件夹 D:\DIYTOOLSram 中
; 例如: MasterSeeker就长期坚持固定不变保存位置在 D:\DIYTOOLSram\MasterSeeker\MasterSeeker.exe
; 例如: FileLocator Pro就长期坚持固定不变保存位置在 D:\DIYTOOLSram\FileLocator\FileLocator.exe
; #####################################################################
;
global ProgramDir
;~ ProgramDir=%A_ScriptDir%\..\..\..
ProgramDir=D:\DIYTOOLS
SetTimer,01设置全局无窗口快捷键,-1000
; 请养成按<Win> + F 隐藏MasterSeeker窗口的习惯
SetTimer,12保持MasterSeeker窗口常驻内存,9000
SetTimer,13设置此脚本的运行参数,-1000
SetTimer,14设置此脚本用户自定义变量,-1000
SetTimer,15防止重复运行此脚本,-1000
SetTimer,16运行国税金税盘开票软件,-100
SetTimer,17运行一些软件应用程序,-1000
SetTimer,18关广告窗口删除广告文件,3000
; 设置插入当前日期和时间的热字串WT ( What is the time now )
::wt::
NowTimeString=%A_YYYY%年%A_MM%月%A_DD%日%A_Hour%时%A_Min%分
Clipboard=%NowTimeString%
Send ^v
return
return
;
; 此脚本相关信息说明段 ---------------------------------------------------------------------------------------
; 用法 把此AHK脚本文件复制到 “shell:startup”文件夹中
; shell:startup”文件夹一般位于开始菜单->所有程序->启动 文件夹
; 作者 徐晓亮 vlanweiyun618
; 电子邮箱地址 [email protected]
; 手机号码
;
; 函数子程序定义段 --------------------------------------------------------------------------------------------
;
01设置全局无窗口快捷键()
{
Hotkey,``,00打开随身U盘_办公专用盘
Hotkey,`#n,02激活或隐藏窗口EmEditor
Hotkey,`#e,03激活或隐藏窗口TotalCommander ; 按热键 Win+E 激活 TotalCommander
Hotkey,`#f,04激活或隐藏窗口MasterSeeker
Hotkey,`#g,05激活或隐藏窗口Everything
Hotkey,`!s,06激活或隐藏窗口SogouExplorer
Hotkey,`#c,07激活或隐藏窗口计算器Calc ; 按热键 Win + C,打开计算器
Hotkey,`^!E,08用SciTE4AutoHotkey编辑此脚本
Hotkey,`^!R,09重启此脚本
Hotkey,^F12,10终止此脚本执行 ;按Ctrl+Alt+F10键此脚本立即停止执行并退出
}
;
00打开随身U盘_办公专用盘()
{
随身固态U盘的盘符:=搜索随身固态U盘并设置盘符()
if (随身固态U盘的盘符<>0)
{
;~ MsgBox,%随身固态U盘的盘符%
Run,%随身固态U盘的盘符%:\01-办公文件
WinWait,01-办公文件 ahk_class CabinetWClass
loop,3
{
WinMove,01-办公文件 ahk_class CabinetWClass,,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight-50
Sleep,100
}
}
else
ToolTip,没有找到随身U盘
}
搜索随身固态U盘并设置盘符()
{
找到U盘:=false
DriveGet,盘符清单,List
loop,Parse,盘符清单
{
DriveGet,卷标,Label,%A_LoopField%:
IfInString,卷标,随身U盘
{
找到U盘:=true
return,%A_LoopField%
}
}
if (not 找到U盘)
{
return,0
}
}
02激活或隐藏窗口EmEditor()
{
根据窗口类名激活或者隐藏窗口()
}
;
03激活或隐藏窗口TotalCommander()
{
根据窗口类名激活或者隐藏窗口("TotalCMD","TTOTAL_CMD")
}
;
04激活或隐藏窗口MasterSeeker()
{
根据窗口类名激活或者隐藏窗口("MasterSeeker","WindowsForms10.Window.8.app.0.218f99c")
;----- 全选激活MasterSeeker窗口的搜索编辑框:
loop,3
{
ControlFocus,Filename,ahk_class WindowsForms10.Window.8.app.0.218f99c
Sleep,10
ControlSend,Filename,{End},ahk_class WindowsForms10.Window.8.app.0.218f99c
}
Sleep,10
ControlSend,Filename,{ShiftDown}{Home}{ShiftUp},ahk_class WindowsForms10.Window.8.app.0.218f99c
Sleep,10
}
;
05激活或隐藏窗口Everything()
{
; 当窗口标题测试不通过的话只好用窗口类了
Process,Close,Everything.exe
根据窗口类名激活或者隐藏窗口("Everything","EVERYTHING")
}
;
06激活或隐藏窗口SogouExplorer()
{
根据窗口类名激活或者隐藏窗口("SogouExplorer","SE_SogouExplorerFrame")
}
;
07激活或隐藏窗口计算器Calc()
{
Run,calc
}
;
08用SciTE4AutoHotkey编辑此脚本()
{
IfExist,%ProgramDir%\AutoHotkey\SciTE\SciTE.exe
Run,%ProgramDir%\AutoHotkey\SciTE\SciTE.exe %A_ScriptName%
else
{
ToolTip,找不到文件%ProgramDir%\AutoHotkey\SciTE\SciTE.exe ,% A_ScreenWidth/2-150,% A_ScreenHeight/2-150
SetTimer, RemoveToolTip, 5000
Sleep,3000
}
}
;
09重启此脚本()
{
Reload
}
;
10终止此脚本执行()
{
ToolTip,%A_ScriptName% (即此脚本)已经退出
SetTimer, RemoveToolTip, 500
Sleep,500
ExitApp
}
;
12保持MasterSeeker窗口常驻内存()
{
Process,Exist,MasterSeeker.exe
if (%ErrorLevel%=0)
{
IfWinNotExist,MasterSeeker 1.5.1 by DxCK
{
IfWinNotExist,ahk_exe MasterSeeker.exe
{
IfExist,%ProgramDir%\MasterSeeker\MasterSeeker.exe
Run,%ProgramDir%\MasterSeeker\MasterSeeker.exe
WinWait,ahk_class WindowsForms10.Window.8.app.0.218f99c
loop,3
{
WinHide,ahk_class WindowsForms10.Window.8.app.0.218f99c
Sleep,100
}
}
}
}
}
;
13设置此脚本的运行参数()
{
#SingleInstance,force ;当此脚本已经运行时自动替换旧实例再次运行。
#Persistent ;让脚本持久运行(即直到用户关闭或遇到 ExitApp)。
#NoEnv ;不检查空变量是否为环境变量(建议所有新脚本使用)。
#WinActivateForce ;用强制的方法激活窗口。阻止任务栏按钮的闪烁.
;~ #NoTrayIcon ;不显示托盘图标。
;~ #Warn
SetWorkingDir,%A_ScriptDir% ;改变脚本的当前工作目录。
DetectHiddenWindows,On ;设置脚本可以“看见”隐藏的窗口。
SetTitleMatchMode,2 ;窗口标题匹配模式改成某个位置必须包含WinTitle。
SendMode,Input ;SendInput 通常更快更可靠. 缓存了发送期间任何物理的键盘或鼠标活动, 避免了在发送时夹杂用户的键击.
CoordMode,Mouse,Screen
CoordMode,Pixel,Screen
CoordMode,ToolTip,Screen
ListLines,Off
SetBatchLines,-1
SetStoreCapsLockMode, On

;~ SetBatchLines,
;~ SetKeyDelay,
;~ SetWinDelay,
;~ SetControlDelay,
}
;
14设置此脚本用户自定义变量()
{
;~ global 移动硬盘盘符 ;带冒号:
}
;
15防止重复运行此脚本()
{
#SingleInstance,force
loop,33
{
DetectHiddenWindows,On
Sleep,33
IfWinExist,QQ595076941_AutoRunAHK
ExitApp
}
Gui, Show, Hide,QQ595076941_AutoRunAHK
}
;
16运行国税金税盘开票软件()
{
SetTimer,运行开票软件,-500
SetTimer,激活登录窗口,500
SetTimer,单击登录窗口中的确定按钮,500
SetTimer,关闭上报汇总已成功提示窗口,500
SetTimer,等待主窗口出现后停止并删除所有Timer定时器,500
}
运行开票软件()
{
IfExist,D:\开票软件\MainExecute.exe
{
Process,Exist,Aisino.Framework.Startup.exe
if (%ErrorLevel%=0)
{
IfWinNotExist,SysMessageBox ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 提示
{
IfWinNotExist,增值税发票税控开票软件
Run,D:\开票软件\MainExecute.exe
}
}
}
}
激活登录窗口()
{
WinGet, WinID, ID,税控发票开票软件
DllCall("SwitchToThisWindow", "UInt", WinID, "UInt", 1)
}
单击登录窗口中的确定按钮()
{
ControlClick, WindowsForms10.BUTTON.app.0.2bb23b_r11_ad12, 税控发票开票软件 ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 增值税发票税控开票软
}
关闭上报汇总已成功提示窗口()
{
WinClose,SysMessageBox ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 提示
}
等待主窗口出现后停止并删除所有Timer定时器()
{
;等待指定标题窗口出现
IfWinExist, 增值税发票税控开票软件(金税盘版) ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 系统设置
停止并删除所有Timer定时器()
IfWinExist, 增值税发票税控开票软件(金税盘版) ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 发票管理
停止并删除所有Timer定时器()
IfWinExist, 增值税发票税控开票软件(金税盘版) ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 报税处理
停止并删除所有Timer定时器()
IfWinExist, 增值税发票税控开票软件(金税盘版) ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 系统维护
停止并删除所有Timer定时器()
}

停止并删除所有Timer定时器()
{
SetTimer,运行开票软件,Delete
SetTimer,激活登录窗口,Delete
SetTimer,单击登录窗口中的确定按钮,Delete
SetTimer,关闭上报汇总已成功提示窗口,Delete
SetTimer,等待主窗口出现后停止并删除所有Timer定时器,Delete
;~ MsgBox,开票软件启动成功
Run,C:\Windows\System32\Rundll32.Exe user32.dll LockWorkStation,,Hide
}
;
17运行一些软件应用程序()
{
SetTimer,定时重启向日葵远程控制保持远程访问可用,3600000
IfExistRun("WiseDesktop") ; WiseDesktop 1.3 虚拟桌面管理程序
;~ IfExistRun("Rolan")
IfExistRun("PCOff") ;定时强制关机精灵1.0 在 17:05 下班后定时强制关闭电脑
SetTimer,超时锁定桌面,30000
;~ Run,"D:\DIYTOOLS\AHKManage\AHKManage.ahk"
;~ FileCreateShortcut,http://www.weiyun.com,%A_DesktopCommon%\微云网页版.lnk
; D:\DIYTOOLS\AutoHotkey\SciTE 文件夹用于保存AHK脚本编辑器程序,此程序可用uTools搜索并运行
FileCreateDir,D:\DIYTOOLS\AutoHotkey\SciTE
; D:\DIYTOOLS\MasterSeeker 文件夹用于保存MasterSeeker程序,此程序需要微软的dotNetFx2.0运行库支持才能运行
FileCreateDir,D:\DIYTOOLS\MasterSeeker
; D:\DIYTOOLS\AutoRun 文件夹用于保存开机自动启动的AHK脚本
FileCreateDir,D:\DIYTOOLS\AutoRun
; D:\DIYTOOLS\uTools\lnks 文件夹用于保存uTools的自定义快捷方式,可用uTools缓存和搜索快捷方式,网址可以保存在批处理脚本的快捷方式中
FileCreateDir,D:\DIYTOOLS\uTools\lnks
}
;
定时重启向日葵远程控制保持远程访问可用()
{
loop,9
{
;~ WinMove
;~ WinMaximize
;~ WinHide
;~ WinClose
;~ WinKill
;~ Process,Close,
;~ WinGet, active_id, PID, A
;~ run, taskkill /PID %active_id% /F,,Hide
;~ Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]
;~ 要想得到pid, 需要把WorkingDir的参数置空,否则就得不到,真是坑爹
Sleep,500
WinClose, 桌面控制 ahk_class SDL_app ahk_exe SunloginClient.exe,
Sleep,500
WinKill, 桌面控制 ahk_class SDL_app ahk_exe SunloginClient.exe,
Sleep,500
Process,Close,SunloginClient.exe
}
loop,2
{
Sleep,3000
Run,"C:\Program Files\Oray\SunLogin\SunloginClient\SunloginClient.exe"
}
}
;
超时锁定桌面()
{
if(A_TimeIdle>50000)
{
if(A_TimeIdlePhysical>50000)
{
Run,C:\Windows\System32\Rundll32.Exe user32.dll LockWorkStation,,Hide
SendMessage, 0x112, 0xF170, 2,, Program Manager ; 关闭显示器: 0x112 为 WM_SYSCOMMAND, 0xF170 为 SC_MONITORPOWER. ; 可使用 -1 代替 2 打开显示器,1 代替 2 激活显示器的节能模式
}
}
}
18关广告窗口删除广告文件()
{
;等待指定标题窗口出现
WinHide, USB KEY PIN ahk_class #32770 ahk_exe Aisino.Framework.Startup.exe, 请输入KEY的PIN
WinClose, USB KEY PIN ahk_class #32770 ahk_exe Aisino.Framework.Startup.exe, 请输入KEY的PIN
;等待指定标题窗口出现
WinHide, ahk_class TXGuiFoundation ahk_exe QQPCTray.exe,
WinClose, Microsoft Windows ahk_class #32770, 稍后重新启动(&L)
WinClose, ahk_class TXGuiFoundation ahk_exe QQPCTray.exe,
WinClose,头条新闻
WinClose,向日葵远程控制 ahk_class SDL_app,
WinClose,今日热点 ahk_class SGNewsWindow,
WinClose,到期抄报税提示 ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe,

; 请用 AHKInfo 1.3.5 窗口信息查询工具来获取窗口标题和窗口类名
;~ 广告弹窗专杀语句格式 WinClose,ahk_exe SohuNews.exe
;~ ;; ;; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;~ WinClose,ahk_exe
;~ WinClose,USB KEY PIN,请输入KEY的PIN码
;~ WinClose,ahk_exe QQPCSoftTrayTips.exe
;~ WinClose,ahk_exe QQPCTray.exe
;~ WinClose,ahk_exe SohuNews.exe
;~ WinClose,ahk_exe SGTool.exe
;~ WinClose,ahk_exe PicFaceTool.exe
;~ WinClose,ahk_exe wpscEnter.exe
;~ WinClose,ahk_exe WindowsForms10.Window.20008.app.0.261f82a_r13_ad1
;~ WinClose,ahk_exe AutoShow.exe
;~ WinClose,ahk_exe skinbox.exe
;~ WinClose,ahk_exe WnComMgr.exe
;~ WinClose,ahk_exe WnMoniter.exe
;~ WinClose,ahk_exe WnHelper64.exe
;~ WinClose,ahk_exe WnUserPage.exe
;~ WinClose,ahk_class TXGuiFoundation
;~ WinClose,到期抄报税提示
;~ WinClose,USB KEY PIN,请输入KEY的PIN码
;等待指定标题窗口出现
;~ WinClose,FF新推荐 ahk_class #32770,
}
;
; 请使用 窗口信息工具 AHKInfo 1.3.5 获取窗口的类名
根据窗口类名激活或者隐藏窗口(VarExeFileName:="EmEditor",VarWinClassName:="EmEditorMainFrame3")
{
; 1、如果程序没有运行则运行程序
Process,Exist,%VarExeFileName%.exe
if (%ErrorLevel%=0)
{
IfExist,%ProgramDir%\%VarExeFileName%\%VarExeFileName%.exe
{
Run,%ProgramDir%\%VarExeFileName%\%VarExeFileName%.exe
return
}
else
{
MsgBox,找不到文件 %ProgramDir%\%VarExeFileName%\%VarExeFileName%.exe
return
}
}
; 2、如果窗口未置顶则显示并激活(切换到)指定窗口
IfWinNotActive,ahk_class %VarWinClassName%
{
loop,3
{
WinShow,ahk_class %VarWinClassName%
WinMaximize,ahk_class %VarWinClassName%
WinGet, WinID, ID,ahk_class %VarWinClassName%
DllCall("SwitchToThisWindow", "UInt", WinID, "UInt", 1)
}
return
}
; 3、如果窗口已经显示并置顶则隐藏窗口
;~ WinMinimize,ahk_class %VarWinClassName%
WinHide,ahk_class %VarWinClassName%
}
IfExistRun(TargetEXE) ;检查文件是否存在并运行程序
{
IfExist,%ProgramDir%\%TargetEXE%\%TargetEXE%.exe
Run,%ProgramDir%\%TargetEXE%\%TargetEXE%.exe
else
{
ToolTip,未找到文件%ProgramDir%\%TargetEXE%\%TargetEXE%.exe
SetTimer, RemoveToolTip, 5000
}
}
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
;
; #####################################################################
;
; 此脚本到此行结束

猜你喜欢

转载自www.cnblogs.com/delphixx/p/11965929.html