AHKManager-2021年2月19日

AHKManager-2021年2月19日

 

说明:本文的段落分割符号是一行连续的斜杠 ////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////

 

rem 一键安装AutoHotkey自动化热键脚本语言编程环境
md D:greenAutoHotkey
xcopy %~dp0AutoHotkey*.* D:greenAutoHotkey /s /h /d /y

D:
cd greenAutoHotkey
rem 由于AutoHotkey的安装包会记住上次安装的位置,
rem 为了软件安装位置固定到 D:greenAutoHotkey 文件夹所以此处必需指定安装目标文件夹
D:greenAutoHotkeyAutoHotkey_1.1.33.02_setup.exe  /S /D=D:greenAutoHotkey

rem 设置ahk文件类型关联到AutoHotkeyU32.exe
rem 添加ahk文件类型鼠标右键菜单
rem 运行、编辑、编译脚本的关联,感谢作者写出这么好的脚本
D:greenAutoHotkeyautohotkeyu32.exe D:greenAutoHotkeyMenuSetup.ahk
rem ping -n 5 127.0.0.1>nul
rem D:greenAutoHotkeyautohotkeyu32.exe D:greenAutoHotkeyMenuSetup.ahk

rem 一键设置AHKManager跟随系统自动启动的AHK自化热键脚本
md D:greenAHKManager
xcopy %~dp0AHKManager*.* D:greenAHKManager /s /h /d /y

C:
cd “ProgramDataMicrosoftWindowsStart MenuProgramsStartUp”
copy /y D:greenAHKManagerAHKManager.lnk      .
start      .
rem start shell:startup

exit

////////////////////////////////////////////////////////////

/*
AutoHotkey 版本: 1.x
操作系统:    WinXP
作者:        甲壳虫<jdchenjian@gmail.com>
博客:        http://hi.baidu.com/jdchenjian
脚本说明:   此工具用来修改 AutoHotkey 脚本的右键菜单关联,适用于 AutoHotkey 安装版、绿色版。
脚本版本:   2009-01-21

修改作者: 兔子
更新说明:
2010.01.09 之前某个时间,修改AHK路径、编辑器路径、编译器路径,默认全部在当前目录下寻找
2010.01.09 去掉默认在新建菜单的勾
2010.06.21 如果SCITE为默认编辑器,则复制个人配置文件“SciTEUser.properties”到%USERPROFILE%
2010.06.25 修正因#NoEnv使%USERPROFILE%变量直接引用无效
2016.04.18 删除“2010.06.21”的改动
*/

; — 20190207 晓亮修改 —

#NoEnv
#SingleInstance, force
SendMode Input
SetWorkingDir %A_ScriptDir%

; 版本(仅用于显示)
Script_Version=v1.0.3.2

; AutoHotkey 原版的相关信息写在注册表HKCR主键中,
; 尝试是当前用户否有权操作该键,如果无权操作HKCR键(受限用户),
; 可通过操作注册表HKCU键来实现仅当前用户关联AHK脚本。
IsLimitedUser:=0
RegWrite, REG_SZ, HKCR, .test
if ErrorLevel
 IsLimitedUser:=1
RegDelete, HKCR, .test
if ErrorLevel
 IsLimitedUser:=1

if IsLimitedUser=0 ; 非受限用户操作HKCR键
{
 RootKey=HKCR
 Subkey=
}
else ; 受限用户操作HKCU键
{
 RootKey=HKCU
 Subkey=SoftwareClasses ; <– 为简化后面的脚本,此子键须以“”结尾
}

; 检查是否存在AHK注册表项
RegRead, FileType, %RootKey%, %Subkey%.ahk
if FileType<>
{
 RegRead, value, %RootKey%, %Subkey%%FileType%ShellOpenCommand ;AHK路径
 AHK_Path:=PathGetPath(value)
 RegRead, value, %RootKey%, %Subkey%%FileType%ShellEditCommand ;编辑器路径
 Editor_Path:=PathGetPath(value)
 RegRead, value, %RootKey%, %Subkey%%FileType%ShellCompileCommand ;编译器路径
 Compiler_Path:=PathGetPath(value)
 RegRead, Template_Name, %RootKey%, %Subkey%.ahkShellNew, FileName ;模板文件名
}
else
 FileType=AutoHotkeyScript

if AHK_Path=
{
 IfExist, %A_ScriptDir%AutoHotkey.exe
  AHK_path=%A_ScriptDir%AutoHotkey.exe
}

if Editor_Path=
{
 IfExist, %A_ScriptDir%SciTESciTE.exe
  Editor_Path=%A_ScriptDir%SciTESciTE.exe
}

if Compiler_Path=
{
 IfExist, %A_ScriptDir%CompilerAhk2Exe.exe
  Compiler_Path=%A_ScriptDir%CompilerAhk2Exe.exe
}

if Template_Name=
 Template_Name=Template.ahk

; — 20190207 晓亮修改 —
;设置AHK默认文件夹为  D:greenAutoHotkey
AHK_path=D:greenAutoHotkeyAutoHotkeyU32.exe
Editor_Path=D:greenAutoHotkeySciTESciTE.exe
Compiler_Path=D:greenAutoHotkeyCompilerAhk2Exe.exe

Gui, Add, Tab, x10 y10 w480 h250 Choose1, 设置|说明
 Gui, Tab, 1
  Gui, Add, GroupBox, x20 y40 w460 h50 , “运行脚本”关联的 AutoHotkey
  Gui, Add, Edit, x35 y60 w340 h20 vAHK_Path, %AHK_path%
  Gui, Add, Button, x385 y60 w40 h20 gFind_AHK, 浏览

  Gui, Add, GroupBox, x20 y100 w460 h50 , “编辑脚本”关联的编辑器
  Gui, Add, Edit, x35 y120 w340 h20 vEditor_Path, %Editor_Path%
  Gui, Add, Button, x385 y120 w40 h20 gChoose_Editor, 浏览
  Gui, Add, Button, x430 y120 w40 h20 gDefault_Editor, 默认

  Gui, Add, GroupBox, x20 y160 w460 h50 , “编译脚本”关联的编译器
  Gui, Add, Edit, x35 y180 w340 h20 vCompiler_Path, %Compiler_Path%
  Gui, Add, Button, x385 y180 w40 h20 gChoose_Compiler, 浏览
  Gui, Add, Button, x430 y180 w40 h20 gDefault_Compiler, 默认

  Gui, Add, Checkbox, x35 y230 w270 h20 gNew_Script vNew_Script, 右键“新建”菜单中增加“AutoHotkey 脚本”
  Gui, Add, Button, x310 y230 w80 h20 vEdit_Template gEdit_Template, 编辑脚本模板
  Gui, Add, Button, x400 y230 w80 h20 vDelete_Template gDelete_Template, 删除脚本模板

 Gui, Tab, 2
  Gui, Font, bold
  Gui, Add, Text,, AutoHotkey 脚本关联工具  ScriptSetting %Script_Version%
  Gui, Font
  Gui, Font, CBlue underline
  Gui, Add, Text, gWebsite, 作者:甲壳虫 <jdchenjian@gmail.com>`n`n博客:http://hi.baidu.com/jdchenjian
  Gui, Font
  Gui, Add, Text, w450, 此工具用来修改 AutoHotkey 脚本的右键菜单关联,适用于 AutoHotkey 安装版、绿色版。
  Gui, Add, Text, w450, 您可以用它来修改默认脚本编辑器、编译器,修改默认的新建脚本模板。设置后,在右键菜单中添加“运行脚本”、“编辑脚本”、“编译脚本”和“新建 AutoHotkey 脚本”等选项。
  Gui, Add, Text, w450, 要取消脚本的系统关联,请按“卸载”。注意:卸载后您将无法通过双击来运行脚本,也不能通过右键菜单来启动脚本编辑器…

Gui, Tab
Gui, Add, Button, x100 y270 w60 h20 Default gInstall, 设置
Gui, Add, Button, x200 y270 w60 h20 gUninstall, 卸载
Gui, Add, Button, x300 y270 w60 h20 gCancel, 取消

Gui, Show, x250 y200 h300 w500 CEnter, ScriptSetting %Script_Version%
GuiControl, Disable, Edit_Template ; 使“编辑脚本模板”按钮无效
IfNotExist, %A_WinDir%ShellNew%Template_Name%
 GuiControl, Disable, Delete_Template ; 使“删除脚本模板”按钮无效

; 当鼠标指向链接时,指针变成手形
hCurs:=DllCall(“LoadCursor”,”UInt”,NULL,”Int”,32649,”UInt”) ;IDC_HAND
OnMessage(0x200,”WM_MOUSEMOVE”)

; — 20190207 晓亮修改 —
goto,Install
return

; 改变鼠标指针为手形
WM_MOUSEMOVE(wParam,lParam)
{
 global hCurs
 MouseGetPos,,,,ctrl
 if ctrl in static2
  DllCall(“SetCursor”,”UInt”,hCurs)
 return
}
return

GuiClose:
GuiEscape:
Cancel:
 ExitApp

 ; 查找 AutoHotkey 主程序
Find_AHK:
 Gui +OwnDialogs
 FileSelectFile, AHK_Path, 3, , 查找 AutoHotkey.exe, AutoHotkey.exe
 if AHK_Path<>
  GuiControl,,AHK_Path, %AHK_Path%
 gosub Default_Compiler
return

; 选择脚本编辑器
Choose_Editor:
 Gui +OwnDialogs
 FileSelectFile, Editor_Path, 3, , 选择脚本编辑器, 程序(*.exe)
 if Editor_Path<>
  GuiControl,,Editor_Path, %Editor_Path%
return

; 默认脚本编辑器
Default_Editor:
 IfExist, %A_ScriptDir%SciTESciTE.exe
  Editor_Path=%A_ScriptDir%SciTESciTE.exe
 else ifExist, %A_WinDir%system32notepad.exe
   Editor_Path=%A_WinDir%system32notepad.exe
 GuiControl,, Editor_Path, %Editor_Path%
return

; 选择脚本编译器
Choose_Compiler:
 Gui +OwnDialogs
 FileSelectFile, Compiler_Path, 3, , 选择脚本编译器, 程序(*.exe)
 if Compiler_Path<>
  GuiControl,,Compiler_Path, %Compiler_Path%
return

; 默认脚本编译器
Default_Compiler:
 GuiControlGet, AHK_Path
 SplitPath, AHK_Path, ,AHK_Dir
 IfExist, %AHK_Dir%CompilerAhk2Exe.exe
 {
  Compiler_Path=%AHK_Dir%CompilerAhk2Exe.exe
  GuiControl,, Compiler_Path, %Compiler_Path%
 }
return

; 设置
Install:
 Gui, Submit
 IfNotExist, %AHK_Path%
 {
  MsgBox, 16, ScriptSetting %Script_Version%, AutoHotkey 路径错误 !
  return
 }

 IfNotExist, %Editor_Path%
 {
  MsgBox, 16, ScriptSetting %Script_Version%, 编辑器路径错误 !
  return
 }

 IfNotExist, %Compiler_Path%
 {
  MsgBox, 16, ScriptSetting %Script_Version%, 编译器路径错误 !
  return
 }

 ; 写入注册表
 RegWrite, REG_SZ, %RootKey%, %Subkey%.ahk,, %FileType%
 if New_Script=1
 {
  RegWrite, REG_SZ, %RootKey%, %Subkey%.ahkShellNew, FileName, %Template_Name%
  IfNotExist, %A_WinDir%ShellNew%Template_Name%
   gosub Create_Template
 }
 else
 {
  ; — 20190207 晓亮修改 —
  ; — 此处不要删除右键新建ahk文件的菜单所以注释掉此代码
  ;RegDelete, %RootKey%, %Subkey%.ahkShellNew
  IfExist, %A_WinDir%ShellNew%Template_Name%
   gosub Delete_Template
 }

 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%,, AutoHotkey 脚本
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%DefaultIcon,, %AHK_Path%`,1
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%Shell,, Open
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellOpen,, 运行脚本
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellOpenCommand,, “%AHK_Path%” “`%1” `%*
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellEdit,, 编辑脚本
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellEditCommand,, “%Editor_Path%” “`%1”
 RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellCompile,, 编译脚本
 IfInString, Compiler_Path, Ahk2Exe.exe
  RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellCompileCommand,, “%Compiler_Path%” /in “`%1”
 else
  RegWrite, REG_SZ, %RootKey%, %Subkey%%FileType%ShellCompileCommand,, “%Compiler_Path%” “`%1”

/*  新版的scite不需要将“SciTEUser.properties”放在“USERPROFILE”目录下了
if Editor_Path=%A_ScriptDir%SciTESciTE.exe
{
EnvGet,USERPROFILE,USERPROFILE
FileCopy,%A_ScriptDir%SciTESciTEUser.properties,%USERPROFILE%SciTEUser.properties,1
}
*/

 ;MsgBox, 64, ScriptSetting %Script_Version%, 设置完毕 !
 ExitApp

 ; 卸载
Uninstall:
 ; — 20190207 晓亮修改 —
 ;MsgBox, 36, ScriptSetting %Script_Version%
 ;, 注意:卸载后您将无法通过双击来运行脚本,也不能通过右键菜单来启动脚本编辑器…`n`n确定要取消 AHK 脚本的系统关联吗 ?
 ;IfMsgBox, Yes
 ;{
 ;RegDelete, %RootKey%, %Subkey%.ahk
 ;RegDelete, %RootKey%, %Subkey%%FileType%
 ;gosub Delete_Template
 ;ExitApp
 ;}
return

; 编辑脚本模板
Edit_Template:
 GuiControlGet, Editor_Path
 IfNotExist, %Editor_Path%
 {
  MsgBox, 64, ScriptSetting %Script_Version%, 脚本编辑器路径错误 !
  return
 }
 IfNotExist, %A_WinDir%ShellNew%Template_Name%
  gosub Create_Template
 Run, %Editor_Path% %A_WinDir%ShellNew%Template_Name%
return

; 使编辑脚本模板按钮有效/无效
New_Script:
 GuiControlGet, New_Script
 if New_Script=0
  GuiControl, Disable, Edit_Template
 else
  GuiControl, Enable, Edit_Template
return

; 新建脚本模板
Create_Template:
 GuiControlGet, AHK_Path
 FileGetVersion, AHK_Ver, %AHK_Path%

 FileAppend,
 (
/*
AutoHotkey 版本: %AHK_Ver%
操作系统:    %A_OSVersion%
作者:        %A_UserName%
网站:        http://www.AutoHotkey.com
脚本说明:
脚本版本:   v1.0
*/

#NoEnv
SendMode Input
SetWorkingDir `%A_ScriptDir`%

 ), %A_WinDir%ShellNew%Template_Name%

 GuiControl, Enable, Delete_Template ; 使“删除脚本模板”按钮有效
return

; 删除脚本模板
Delete_Template:

 ; — 20190207 晓亮修改 —
 ;MsgBox, 36, ScriptSetting %Script_Version%
 ; , 要删除当前的 AHK 脚本模板吗 ?`n`n脚本模板被删除后,仍可通过本工具重建模板。
 ;IfMsgBox, Yes
 ;FileDelete, %A_WinDir%ShellNew%Template_Name%
 ;GuiControl, Disable, Delete_Template ; 使“删除脚本模板”按钮无效
return

; 打开网站
Website:
 Run, http://hi.baidu.com/jdchenjian
return

; 从注册表值字符串中提取路径
PathGetPath(pSourceCmd)
{
 local Path, ArgsStartPos = 0
 if (SubStr(pSourceCmd, 1, 1) = “”””)
  Path := SubStr(pSourceCmd, 2, InStr(pSourceCmd, “”””, False, 2) – 2)
 else
 {
  ArgsStartPos := InStr(pSourceCmd, ” “)
  if ArgsStartPos
   Path := SubStr(pSourceCmd, 1, ArgsStartPos – 1)
  else
   Path = %pSourceCmd%
 }
 return Path
}

 

////////////////////////////////////////////////////////////

 

;~ AHKManager.ahk
;AHK管理器AHKManager.ahk

;~ 把下面这个函数丢到任何AHK脚本中,就可以限制单进程运行。
;– 限制单进程运行函数
OnlyOne(flag=””) {
  local
  static init:=OnlyOne(A_ScriptName)
  hash:=0
  Loop, Parse, flag
    hash:=(hash*31+Ord(A_LoopField))&0xFFFFFFFF
  MutexName:=”Ahk_OnlyOne_” . hash
  While (Mutex:=DllCall(“OpenMutex”,”uint”,0x100000,”int”,0,”str”,MutexName))
  {
    DllCall(“CloseHandle”, “ptr”,Mutex)
    DetectHiddenWindows, % (dhw:=A_DetectHiddenWindows) ? “On”:”On”
    WinGet, list, List, <<%flag%>> ahk_class AutoHotkeyGUI
    Loop, % list
    {
      WinGet, pid, PID, % “ahk_id ” . list%A_Index%
      WinClose, ahk_pid %pid% ahk_class AutoHotkey,, 3
      IfWinExist, ahk_pid %pid%,, Process, Close, %pid%
    }
    DetectHiddenWindows, %dhw%
  }
  DllCall(“CreateMutex”, “ptr”,0, “int”,0, “str”,MutexName)
  IfEqual, A_LastError, 0xB7, ExitApp
  Gui, __OnlyOne__: Show, Hide, <<%flag%>>
}

;~ 把上面这个函数丢到任何AHK脚本中,就可以限制单进程运行。
;~ isShow:=true
;源码
;~ 将exe文件发送到 自启动目录

; 作者:sunwind
; 日期:2013年1月29日,周二,下午3时58分
 
;描述:candy 插件 “将exe文件发送到 自启动目录”
;帮⑥① 2013-01-29 11:30:03 解决 :“经常有人喊我帮他某个软件设置成开机启动”
;配置位置:exe.ini 或者exe文件类型下
;配置项:SendTo自启动  =run|Extension发送到自启动目录.ahk  “{file:pathfull}” “{file:namenoext}”
;~ path_exe=%1%
;;   path_exe=D:toolsListary4Listary.exe
;;   SplitPath,path_exe,fileName
;;   ;~ alias=%2%
;;   RegRead, folder_startup, HKEY_CURRENT_USER, SoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders, Startup
;;   FileCreateShortcut, %path_exe%, %folder_startup%%fileName%.lnk
;;   IfExist,%folder_startup%%alias%.lnk
;;    TrayTip,,已经成功设置%alias%自启动!,10
;;   Sleep,3000

;~ 按 {Ctrl} + {Alt} + {F12} 立即无条件终止所有脚本
Hotkey,^!F12,ExitThisApp
ExitThisApp()
{
 gosub,ExitSubNow
 ExitApp
}
;by Sixtyone At 2016.4.10
;更新说明
/*
2016.4.24:
1.运行#脚本后,gui自动隐藏;
2.启动脚本目录后,gui自动隐藏。
2016.4.17:
1. 增加过滤中使用%A_ScriptDir%变量。
2016.4.14:
1.修复2016.4.13版本中的1个bug;
2.添加文件(夹)过滤功能:添加到过滤中的文件(夹),将不会被读取到AHK管理器中;
3.修复之前版本某些脚本不能关闭问题;
4.修复脚本不能正确读取ini配置问题。
2016.4.13:
1.更新添加“Scripts文件夹内的第一层子文件夹脚本”,但所有脚本不能同名。
2016.4.11:
1.脚本库中启动条目后,焦点自带设置为上一条,正在运行库同;
2.更新脚本库双击运行脚本,正在运行库双击关闭脚本;
3.脚本库增加右键菜单:”编辑”,”运行”–正在运行库增加右键菜单:”编辑”,”重载”,”关闭”。
*/
#SingleInstance Force
#NoEnv
;#Warn
SetWorkingDir %A_ScriptDir%
Process, Priority,, High
DetectHiddenWindows,On
Menu, Tray, NoStandard                  ;删除自带托盘菜单
Menu, tray, add, 管理,ShowGui  ;  显示Gui
Menu, tray, add  ; 创建分隔线.
Menu, tray, add ,过滤,Menu_Tray_过滤        ;  过滤
Menu, tray, add ,脚本目录,Menu_Tray_OpenDir          ;  脚本目录
Menu, tray, add ,重启管理器,Menu_Tray_Reload          ; 重启
Menu, tray, Add
Menu, tray, Add,帮助,Help ;Help
Menu, tray, Add,关于,About ;关于
Menu, tray, Add
Menu, tray, Add, 退出, ExitSub                  ; 创建    退出
Menu, Tray, Default, 管理  ;;默认  菜单:配置
Menu, Tray, Icon, Shell32.dll, 258
;IntelligentScript:
Gui,Destroy
Gui Add, ListView, x8 y30 w200 h400 AltSubmit vScriptLibrary g运行 , 脚本名称
Gui Add, Text, x10 y3 w120 h23 +0x200, 脚本库
Gui Add, ListView, x233 y30 w200 h400 AltSubmit vScriptRun g运行2, 脚本名称
Gui Add, Text, x234 y3 w120 h23 +0x200, 已运行脚本
Gui Add, Button, x440 y30 w60 h42 gtsk_open, 启动脚本
Gui Add, Button, x440 y100 w60 h42 gtsk_restart, 重载脚本
Gui Add, Button, x440 y170 w60 h42 gtsk_close, 关闭脚本
Gui Add, Button, x440 y240 w60 h42 gMenu_Tray_OpenDir, 脚本目录
Gui Add, Button, x440 y310 w60 h42 gMenu_Tray_Reload, 重启管理器
Gui Add, Button, x440 y380 w60 h42 gExitSub, 退出
;Gui Show,, AHK管理器
Gui Default
Gui,ListView,ScriptLibrary
scriptCount = 0
IniRead,Golv,过滤.ini,过滤
OpenList := Array()
UnOpenList := Array()
FileCreateDir,%A_ScriptDir%scripts
loop, %A_ScriptDir%scripts*.ahk,,1
{
 _Golv=0
 loop,Parse,Golv,`n,`r                  ;增加过滤判断
 {
  StringReplace,_GolvPath,A_LoopField,`%A_ScriptDir`%,%A_ScriptDir%
  IfInString,A_LoopFileLongPath ,%_GolvPath%
  {
   _Golv=1
   break
  }
 }
 if  _Golv=1
  continue
 if !(A_LoopFileLongPath~=”i).+?\scripts\[^\]*\?[^\]+.ahk”)                          ;增加一层子文件读取
  continue
 StringReplace, MenuName, A_LoopFileName, .ahk
 scriptCount += 1
 %MenuName%_Path :=A_LoopFileLongPath
 %MenuName%_Dir :=A_LoopFileDir
 scriptsName%scriptCount% := A_LoopFileName
 ;scriptsOpened%scriptCount% = 0
 UnOpenList.Insert(MenuName)
}
InsertionSort(UnOpenList)
for Index, MenuName in UnOpenList
{
 LV_Add(“”,MenuName)
}
LV_ModifyCol()
gosub tsk_openAll
;Gui,Show
return
运行:
if A_GuiEvent = DoubleClick
{
 goto,tsk_open
}
return
运行2:
 if A_GuiEvent = DoubleClick
  goto,tsk_close
return
GuiContextMenu:  ; 运行此标签来响应右键点击或按下 Appskey.
 if A_GuiControl = ScriptLibrary  ; 这个检查是可选的. 让它只为 ListView 中的点击显示菜单.
 {
  Gui,Default
  Gui,ListView,ScriptLibrary
  RowNumber = 0
  loop,%scriptCount%
  {
   RowNumber := LV_GetNext(RowNumber)
   if not RowNumber
    return
   break
  }
  Menu,PopC,Add,编辑,P_edit
  Menu,PopC,Add,运行,tsk_open
  Menu,PopC,Show
  return
 }
 if  A_GuiControl = ScriptRun
 {
  Gui,Default
  Gui,ListView,ScriptRun
  RowNumber = 0
  loop,%scriptCount%
  {
   RowNumber := LV_GetNext(RowNumber)
   if not RowNumber
    return
   break
  }
  Menu,PopC2,Add,编辑,P_edit
  Menu,PopC2,Add,重载,tsk_restart
  Menu,PopC2,Add,关闭,tsk_close
  Menu,PopC2,Show
  return
 }
return
P_edit:
 LV_GetText(thisScript, RowNumber)
 P_editpath :=%thisScript%_path
 Run, D:greenAutoHotkeySciTESciTE.exe  “%P_editpath%”
return
tsk_open:
 Gui,Default
 Gui,ListView,ScriptLibrary
 RowNumber = 0
 loop,%scriptCount%
 {
  RowNumber := LV_GetNext(RowNumber)
  if not RowNumber
   return
  LV_GetText(thisScript, RowNumber)
  Run,% %thisScript%_Path,% %thisScript%_Dir,,%thisScript%
  IfInString, thisScript, #
  {
   Gui, Hide
   return
  }
  ;scriptsOpened%A_Index% := 1
  break
 }
 Gui,ListView,ScriptRun
 LV_Add(“”,ThisScript)
 LV_ModifyCol()
 Gui,ListView,ScriptLibrary
 loop, %scriptCount%
 {
  LV_GetText(outputname,A_Index,1)
  if (outputname=ThisScript)
  {
   LV_Delete(A_Index)
   if A_Index<>1
   {
    LV_Modify(A_Index-1, “Select”)
   }
   else
   {
    LV_Modify(1, “Select”)
   }
   break
  }
 }
 LV_ModifyCol()
return
tsk_close:
 Gui,Default
 Gui,ListView,ScriptRun
 RowNumber = 0
 loop,%scriptCount%
 {
  RowNumber := LV_GetNext(RowNumber)
  if not RowNumber
   return
  LV_GetText(thisScript, RowNumber)
  ID:=%thisScript%
  WinClose, ahk_pid %ID%
  IfWinExist,ahk_pid %ID%
   Process,Close,%ID%
  ;scriptsOpened%A_Index% := 0
  break
 }
 Gui,ListView,ScriptLibrary
 LV_Add(“”,ThisScript)
 LV_ModifyCol()
 Gui,ListView,ScriptRun
 loop, %scriptCount%
 {
  LV_GetText(outputname,A_Index,1)
  if (outputname=thisScript)
  {
   LV_Delete(A_Index)
   if A_Index<>1
   {
    LV_Modify(A_Index-1, “Select”)
   }
   else
   {
    LV_Modify(1, “Select”)
   }
   break
  }
 }
 LV_ModifyCol()
return
tsk_restart:
 Gui,Default
 Gui,ListView,ScriptRun
 RowNumber = 0
 loop,%scriptCount%
 {
  RowNumber := LV_GetNext(RowNumber)
  if not RowNumber
   return
  LV_GetText(thisScript, RowNumber)
  ID:=%thisScript%
  WinClose, ahk_pid %ID%
  IfWinExist,ahk_pid %ID%
   Process,Close,%ID%
  Run,% %thisScript%_Path,% %thisScript%_Dir,,%thisScript%
  break
 }
return
tsk_openAll:
 loop, %scriptCount%
 {
  thisScript := scriptsName%A_Index%
  StringReplace, thisScript, thisScript, .ahk
  ;if scriptsOpened%A_Index% = 0
  ;{
  IfInString, thisScript, _          ;IfInString,%thisScript%_Path,%A_ScriptDir%Scripts_    不自动启动_文件夹内的脚本
  {
   continue
  }
  IfInString, thisScript, #
  {
   continue
  }
  Run, % %thisScript%_Path,% %thisScript%_Dir,,%thisScript%
  ;scriptsOpened%A_Index% = 1
  Gui,Default
  Gui,ListView,ScriptRun
  LV_Add(“”,thisScript)
  LV_ModifyCol()
  Gui,ListView,ScriptLibrary
  loop, %scriptCount%
  {
   LV_GetText(outputname,A_Index,1)
   if (outputname=thisScript)
   {
    LV_Delete(A_Index)
    break
   }
  }
  LV_ModifyCol()
  ;}
 }
 ;Gui,Show
return
Menu_Tray_过滤:
 Run, Notepad.exe  过滤.ini
return
Menu_Tray_OpenDir:
 FileCreateDir,%A_ScriptDir%scripts
 Run, %A_ScriptDir%scripts
 Gui,Hide
return
Menu_Tray_Reload:
 Gui,Hide
 Gui,Default
 Gui,ListView,ScriptRun
 loop % LV_GetCount()
 {
  LV_GetText(thisScript, A_Index)
  ID:=%thisScript%
  WinClose, ahk_pid %ID%
  IfWinExist,ahk_pid %ID%
   Process,Close,%ID%
 }
 Reload
return
GuiEscape:
GuiClose:
 Gui, Hide
return
ExitSub:
 MsgBox,260,是否退出?,退出脚本,将退出所有经过AHK管理器启动的脚本,你是否确认退出?
 IfMsgBox No
  return
ExitSubNow:
 Gui,Hide
 Gui,Default
 Gui,ListView,ScriptRun
 loop % LV_GetCount()
 {
  LV_GetText(thisScript, A_Index)
  ID:=%thisScript%
  WinClose, ahk_pid %ID%
  IfWinExist,ahk_pid %ID%
   Process,Close,%ID%
 }
 Gui,Destroy
 ExitApp
return
InsertionSort(ByRef array)
{
 target := Array()
 count := 0
 for Index, Files in array
 {
  files%Index% := Files
  count += 1
 }
 j := 2
 while (j <= count)
 {
  key := files%j%
  i := j-1
  while (i >= 0 && key < files%i%)
  {
   k := i+1
   files%k% := files%i%
   i -= 1
  }
  k := i+1
  files%k% := key
  j += 1
 }
 loop, %count%
 {
  target.Insert(files%A_Index%)
 }
 array := target
}
About:
 MsgBox,AHK管理器`n版本号:2016.4.24`nCopyRight?2016 Sixtyone.  All Rights Reserved.`n`n关于作者:`n`tName:Sixtyone`n`tQQ:576642385
return
Help:
 MsgBox,将AHK脚本放在脚本目录下进行管理:`n1.以_开头的脚本不会自动加载`n2.以#开头的脚本为临时脚本即运行完就退出`n3.脚本名字不能有空格及除_、#以为的符号`n4.脚本不能为快捷方式
return
!`::
 ;~ isShow:=!isShow
 ;~ if(isShow)
 ;~ {
ShowGui:
 Gui,Show,,AHK管理器
 ;~ }
 ;~ else
 ;~ Gui,Hide
return
;~ 作者:sixtyone
;~ 链接:https://www.jianshu.com/p/d88f47fa431d
;~ 來源:简书
;~ 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

;批量删除空白行的正则表达式  ^[st]*n

 

////////////////////////////////////////////////////////////

 

;~ %A_ScriptDir%scripts设置随系统启动的程序.ahk

#SingleInstance,force ;当此脚本已经运行时自动替换旧实例再次运行。
#Persistent  ;让脚本持久运行(即直到用户关闭或遇到 ExitApp)。
#NoEnv  ;不检查空变量是否为环境变量(建议所有新脚本使用)。
#WinActivateForce  ;用强制的方法激活窗口。阻止任务栏按钮的闪烁.
;~ #NoTrayIcon  ;不显示托盘图标。
;~ #Warn
SetWorkingDir,%A_ScriptDir%  ;改变脚本的当前工作目录。
DetectHiddenWindows,On  ;设置脚本可以“看见”隐藏的窗口。
SetTitleMatchMode,2  ;窗口标题匹配模式改成某个位置必须包含WinTitle。

;~ 【管理员】徐晓亮(595076941)  11:34:40
;~ 071-在电脑启动时自动设置WPS2019的定时备份时间间隔为1分钟备份文件保存的位置为D盘-20200809

;~ 【管理员】徐晓亮(595076941)  11:38:37
;~ 备份文件夹删除后WPS2019会自动重新新建文件夹
;~ 这一点非常好

;~ 每次启动电脑是通过导入注册表reg文件自动设置WPS的备份时间间隔为1分钟,备份位置是D:kingsoftoffice6backup

;~ 每次启动都覆盖一下设置,防止丢失设置,丢失文件

;~ 唯一缺点时,有泄密的可能,

;~ 当然也可以启动时调用WinRAR按照日期掩码生成压缩包名称并加密压缩一下备份文件,然后删除WPS备份文件,这样就不容易泄密了
;~ loop,5
;~ {
 ;~ FileCopy,”D:greenAHKManagerscriptsregconfig.ini”,”C:Program FilesOraySunLoginSunloginClient”,1
 ;~ Process,Close,SunloginClient.exe
;~ }
;~ IfExist,% “C:Program FilesOraySunLoginSunloginClientSunloginClient.exe”
;~ {
 ;~ Run,”C:Program FilesOraySunLoginSunloginClientSunloginClient.exe”
;~ }

;;  IfExist,% “D:greenAHKManagerscriptsregAutoBackupWPS.reg”
;;  {
;;   Run %comspec% /c “regedit /s D:greenAHKManagerscriptsregAutoBackupWPS.reg”
;;  }

;~ IfExist,% “D:greenTrafficMonitor显示网速TrafficMonitor显示网速.exe”
;~ {
 ;~ Run,”D:greenTrafficMonitor显示网速TrafficMonitor显示网速.exe”
;~ }

;              IfExist,% “D:greenAHKManagerscriptsdatfavorite3.dat”
;              {
;               FileCopy,% “D:greenAHKManagerscriptsdatfavorite3.dat”,C:UsersAdministratorAppDataRoamingSogouExplorerfavorite3.dat,1
;              }

;~ IfExist,% “D:greenRunZRunZ.ahk”
;~ Run,% “D:greenRunZRunZ.ahk”
IfExist,% “D:greenLaunchyLaunchy.exe”
 Run,% “D:greenLaunchyLaunchy.exe”
;~ SetTimer,WinCloseLaunchy,100
;~ WinCloseLaunchy()
;~ {
;~ WinClose, Launchy ahk_class QTool ahk_exe Launchy.exe
;~ WinCloseTime +=1
;~ if(WinCloseTime>30)
;~ SetTimer,WinCloseLaunchy,Delete
;~ }

IfExist,% “D:greenWiseDesktopWiseDesktop.exe”
 Run,% “D:greenWiseDesktopWiseDesktop.exe”
;~ IfExist,% “C:Program Files (x86)USB Safely RemoveUSBSafelyRemove.exe”
;~ Run,% “C:Program Files (x86)USB Safely RemoveUSBSafelyRemove.exe”
SetTimer,16运行国税金税盘开票软件,-100
return
16运行国税金税盘开票软件()
{
 SetTimer,运行开票软件,-500
 SetTimer,激活登录窗口,500
 SetTimer,单击登录窗口中的确定按钮,500
 SetTimer,关闭上报汇总已成功提示窗口,500
 SetTimer,等待主窗口出现后停止并删除所有Timer定时器,500
}
运行开票软件()
{
 ;~ FileCopy,;;;;;D:开票软件913205067037151092.2ConfigCommonConfigBak.xml,D:开票软件913205067037151092.2ConfigCommonConfig.xml,1
 Sleep,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.1ed9395_r14_ad12, 税控发票开票软件 ahk_class WindowsForms10.Window.8.app.0.1ed9395_r14_ad1, 增值税发票税控开票软
 ControlClick, WindowsForms10.BUTTON.app.0.2bb23b_r11_ad12, 税控发票开票软件 ahk_class WindowsForms10.Window.8.app.0.2bb23b_r11_ad1 ahk_exe Aisino.Framework.Startup.exe, 增值税发票税控开票软
 ControlClick, WindowsForms10.BUTTON.app.0.1ed9395_r12_ad12, 税控发票开票软件 ahk_class WindowsForms10.Window.8.app.0.1ed9395_r12_ad1 ahk_exe Aisino.Framework.Startup.exe, 增值税发票税控开票软
 ControlClick, x658 y322, 汇总信息 ahk_class WindowsForms10.Window.8.app.0.1ed9395_r14_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, SysMessageBox ahk_exe Aisino.Framework.Startup.exe, 登录错误
  停止并删除所有Timer定时器()

 IfWinExist,增值税发票税控开票软件(金税盘版) V2 ahk_exe Aisino.Framework.Startup.exe
  停止并删除所有Timer定时器()
}

停止并删除所有Timer定时器()
{
 SetTimer,运行开票软件,Delete
 SetTimer,激活登录窗口,Delete
 SetTimer,单击登录窗口中的确定按钮,Delete
 SetTimer,关闭上报汇总已成功提示窗口,Delete
 SetTimer,等待主窗口出现后停止并删除所有Timer定时器,Delete
 ;~ MsgBox,开票软件启动成功
 Run,C:WindowsSystem32Rundll32.Exe user32.dll LockWorkStation,,Hide
}
;
ExitApp

;  show = Please Waitting…
;  Gui, Font, S8 Cred Bold, Verdana
;  Gui, Add, Edit, x6 y7 w240 h320 vshow
;  Gui, Show, x131 y91 h337 w255, 批量导入注册表
;  GuiControl,, show, %show%
;  foloder = %A_ScriptDir%reg
;  FileAppend, dir “%foloder%” /b >”%A_ScriptDir%list.txt”, %A_ScriptDir%list.cmd
;  run, %A_ScriptDir%list.cmd, , min
;  sleep, 1000
;  GuiControl,, show,
;  Loop
;  {
;  FileReadLine, line, %A_ScriptDir%list.txt, %A_Index%
;  if ErrorLevel = 1
;      break
;  path = %foloder%%line%
;  SplitPath, path, name
;  show = %show%`n注册 %name%
;  GuiControl,, show, %show%
;  FileAppend, regedit /s “%path%”`n, %A_ScriptDir%reg.cmd
;  }
;  run, %A_ScriptDir%reg.cmd, , min
;  FileDelete, %A_ScriptDir%list.txt
;  FileDelete, %A_ScriptDir%list.cmd
;  FileDelete, %A_ScriptDir%reg.cmd
;  ExitApp
;
;  GuiClose:
;  ExitApp

 

////////////////////////////////////////////////////////////

 

;~ %A_ScriptDir%scripts无窗口全局热键定义.ahk
;
; 开机时自动启动的AutoHotkey脚本 2019年10月09日
;
; 计时器创建代码段 —————————————————————————————–
; SetTimer可以模拟多线程从而不影响主线程的流畅执行
; 请在SciTE4AutoHotkey中选中单词并按快捷键F12跳转到函数定义处
; 绿色免安装程序,统一都分类保存在本地磁盘D分区文件夹 D:green 中
; 例如: MasterSeeker就长期坚持固定不变保存位置在 D:greenMasterSeekerMasterSeeker.exe
; 例如: FileLocator Pro就长期坚持固定不变保存位置在 D:greenFileLocatorFileLocator.exe
; #####################################################################
;
#SingleInstance,force ;当此脚本已经运行时自动替换旧实例再次运行。
#Persistent  ;让脚本持久运行(即直到用户关闭或遇到 ExitApp)。

global ProgramDir
global OpednCount
OpenCount =0
ProgramDir=D:green
SetTimer,01设置全局无窗口快捷键,500
SetTimer,01设置全局无窗口快捷键,300
;  请养成按<Win> + F 隐藏MasterSeeker窗口的习惯
;~ SetTimer,12保持MasterSeeker窗口常驻内存,9000
SetTimer,10设置此脚本的运行参数,-1000
SetTimer,11设置此脚本用户自定义变量,-1000
SetTimer,12防止重复运行此脚本,-1000
return

return
;
; 此脚本相关信息说明段 —————————————————————————————
; 用法                把此AHK脚本文件复制到 “shell:startup”文件夹中
;                          shell:startup”文件夹一般位于开始菜单->所有程序->启动 文件夹
; 作者                  徐晓亮  vlanweiyun618
; 电子邮箱地址     595076941@QQ.com
; 手机号码
;
; 函数子程序定义段 ——————————————————————————————–
;
01设置全局无窗口快捷键()
{
 Sleep,200
 Hotkey,*#n,01激活或隐藏用EmEditor打开的log纯文本编辑窗口  ;  按热键F9手动记录电脑操作日志
 ;~ Hotkey,F9,01激活或隐藏用EmEditor打开的log纯文本编辑窗口  ;  按热键F9手动记录电脑操作日志
 ;~ Hotkey,“,01激活用WebDrive2019软件连接群晖的WebDAV共享文件夹窗口  ;  按热键`(即左上角的波浪号~)
 Sleep,200
 ;~ Hotkey,ScrollLock,关闭显示器屏幕
 Hotkey,ScrollLock,立即锁定电脑桌面
 Sleep,200
 ;~ Hotkey,*#n,02激活或隐藏窗口EmEditor
 Sleep,200
 ;~ 热键 {Win}+f 总是要被操作系统抢去,所以改成 {Win}+g
 ;~ Hotkey,*#g,03激活或隐藏窗口Everything
 Hotkey,*#g,03激活或隐藏窗口MasterSeeker
 Sleep,200
 Hotkey,*#b,04激活或隐藏窗口SogouExplorer
 Sleep,200
 ;~ Hotkey,`#t,05激活或隐藏窗口TotalCommander  ;  按热键 Win+E 激活 TotalCommander
 Hotkey,*#t,05激活或隐藏窗口TotalCommander  ;  按热键 Win+E 激活 TotalCommander
 Sleep,200
 Hotkey,*#c,06激活或隐藏窗口计算器Calc  ;  按热键 Win + C,打开计算器
 Sleep,200
 Hotkey,*^!E,07用SciTE4AutoHotkey编辑此脚本
 Sleep,200
 Hotkey,*^!R,08重启此脚本
 Sleep,200
 Hotkey,*^F12,09终止此脚本执行  ;按Ctrl+Alt+F10键此脚本立即停止执行并退出
}
;
立即锁定电脑桌面()
{
Run,C:WindowsSystem32Rundll32.Exe user32.dll LockWorkStation,,Hide
Run,C:WindowsSystem32Rundll32.Exe user32.dll LockWorkStation,,Hide
}
;
关闭显示器屏幕()
{
 SendMessage, 0x112, 0xF170, 2,, Program Manager
}
;
01激活或隐藏用EmEditor打开的log纯文本编辑窗口()
{
 FileCreateDir,D:电脑操作日志记录
 mylogtext :=%  “D:电脑操作日志记录电脑操作日志记录” . A_YYYY  . “年” . A_MM . “月” . A_DD  . “日.txt”
 Run,D:greenEmEditorEmEditor.exe %mylogtext%
}
;
01激活用WebDrive2019软件连接群晖的WebDAV共享文件夹窗口()
{
 ToolTip,正在激活WebDrive2019软件连接群晖的WebDAV共享文件夹窗口
 SetTimer,判断WebDrive2019软件是否已经安装,500
 SetTimer,运行WebDrive2019软件,500
 SetTimer,激活WebDrive2019软件窗口,500
 SetTimer,激活并移动单位办公文件夹窗口,500
}
;
判断WebDrive2019软件是否已经安装()
{
 IfNotExist,C:Program FilesWebDriveWebDrive.exe
 {
  ToolTip
  MsgBox,请安装WebDrive
  SetTimer,判断WebDrive2019软件是否已经安装,Delete
  SetTimer,运行WebDrive2019软件,Delete
  SetTimer,激活WebDrive2019软件窗口,Delete
  SetTimer,激活并移动单位办公文件夹窗口,Delete
 }
 else
 {
  SetTimer,判断WebDrive2019软件是否已经安装,Delete
 }
}
;
运行WebDrive2019软件()
{
 IfWinNotExist,WebDrive 2019 ahk_exe WebDrive.exe
 {
  Process,Close,WebDrive.exe
  Run,”C:Program FilesWebDriveWebDrive.exe”
 }
 else
  SetTimer,运行WebDrive2019软件,Delete
}
;
激活WebDrive2019软件窗口()
{
 ;~ 激活互斥锁定,防止在同一时间激活两个窗口
 IfWinNotActive,ahk_exe WebDrive.exe,Username
 {
  IfWinNotActive,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe
  {
   WinActivate,WebDrive 2019 ahk_exe WebDrive.exe
  }
 }
}
;
激活并移动单位办公文件夹窗口()
{
 IfExist,W:1-工作文件夹1-办公1-单位办公
  Run,W:1-工作文件夹1-办公1-单位办公
 WinShow,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe
 WinActivate,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe
 Sleep,100
 WinMove,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe,,A_ScreenWidth/2,20,A_ScreenWidth/2-20,A_ScreenHeight-70
 IfWinActive,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe
 {
  ;  WinGetPos [, X, Y, Width, Height, WinTitle, WinText, ExcludeTitle, ExcludeText]
  WinGetPos,MyX,MyY,MyWidth,MyHeight,01-单位办公 ahk_class CabinetWClass ahk_exe explorer.exe
  if(MyX=A_ScreenWidth/2)
  {
   if(MyWidth=A_ScreenWidth/2-20)
   {
    WinClose,WebDrive 2019 ahk_exe WebDrive.exe
    ToolTip
    SetTimer,判断WebDrive2019软件是否已经安装,Delete
    SetTimer,运行WebDrive2019软件,Delete
    SetTimer,激活WebDrive2019软件窗口,Delete
    SetTimer,激活并移动单位办公文件夹窗口,Delete
   }
 }
}
}
;
02激活或隐藏窗口EmEditor()
{
 ;~ SetTimer,Timer激活或隐藏窗口EmEditor,500
 根据窗口类名激活或者隐藏窗口()
}
;
03激活或隐藏窗口MasterSeeker()
{
 ;~ MsgBox,Everything热键函数被触发 ;不知道为什么,有时候Win+F热键会被操作系统夺回去
 SetTimer,Timer激活或隐藏窗口MasterSeeker,500
}
;
Timer激活或隐藏窗口MasterSeeker()
{
 WinGetActiveTitle,MSTitle
 IfInString,MSTitle,MasterSeeker
 {
  WinHide,ahk_exe MasterSeeker.exe
  SetTimer,Timer激活或隐藏窗口MasterSeeker,Delete
 }
 else
 {
  IfWinNotExist,ahk_exe MasterSeeker.exe
  {
   IfExist,D:greenMasterSeekerMasterSeeker.exe
   {
    Run,D:greenMasterSeekerMasterSeeker.exe
   }
  }
  ;
  loop,3
  {
   WinShow,MasterSeeker 1.5.1 by DxCK ahk_exe MasterSeeker.exe
   WinActivate,MasterSeeker 1.5.1 by DxCK ahk_exe MasterSeeker.exe
   WinWaitActive,MasterSeeker 1.5.1 by DxCK ahk_exe MasterSeeker.exe
   ControlFocus,Filename,MasterSeeker 1.5.1 by DxCK ahk_exe MasterSeeker.exe
   Sleep,10
  }
  Send,^a
  SetTimer,Timer激活或隐藏窗口MasterSeeker,Delete
 }

 ;~ 根据窗口类名激活或者隐藏窗口(“Everything”,”EVERYTHING”)
 ;—– 全选激活MasterSeeker窗口的搜索编辑框:
 ;~ WinGetActiveTitle,MTitle
 ;~ IfInString,MTitle,Everything
 ;~ if(MTitle==”Everything”)
 ;~ {
 ;~ SetTimer,Timer激活或隐藏窗口Everything,Delete
 ;~ WinWaitActive,ahk_class EVERYTHING
 ;~ Sleep,10
 ;~ loop,3
 ;~ {
 ;~ ControlFocus,Edit1,Everything ahk_class EVERYTHING
 ;~ Sleep,10
 ;~ ControlSend,Edit1,{End}{ShiftDown}{Home}{ShiftUp},Everything ahk_class EVERYTHING
 ;~ Sleep,10
 ;~ }
 ;~ }
}
;
04激活或隐藏窗口SogouExplorer()
{
 {
  ToolTip,正在启动搜狗高速浏览器_请稍候 . . .
  SetTimer, RemoveToolTip, 3000
 }
根据窗口类名激活或者隐藏窗口(“SogouExplorer”,”SE_SogouExplorerFrame”)
}
;
05激活或隐藏窗口TotalCommander()
{
 if (A_Is64bitOS=1)
  根据窗口类名激活或者隐藏窗口(“TotalCMD64″,”TTOTAL_CMD”)
 else
  根据窗口类名激活或者隐藏窗口(“TotalCMD”,”TTOTAL_CMD”)
}
;
06激活或隐藏窗口计算器Calc()
{
 Run,calc
}
;
07用SciTE4AutoHotkey编辑此脚本()
{
 IfExist,%ProgramDir%AutoHotkeySciTESciTE.exe
  Run,%ProgramDir%AutoHotkeySciTESciTE.exe %A_ScriptName%
 else
 {
  {
   ToolTip,找不到文件%ProgramDir%AutoHotkeySciTESciTE.exe ,% A_ScreenWidth/2-150,% A_ScreenHeight/2-150
   SetTimer, RemoveToolTip, 3000
  }
  Sleep,3000
}
}
;
08重启此脚本()
{
 Reload
}
;
09终止此脚本执行()
{
 {
  ToolTip,%A_ScriptName% (即此脚本)已经退出
  SetTimer, RemoveToolTip, 500
 }
Sleep,500
ExitApp
}
;
10设置此脚本的运行参数()
{
#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,
}
;
11设置此脚本用户自定义变量()
{
 ;~ global 移动硬盘盘符 ;带冒号:
}
;
12防止重复运行此脚本()
{
#SingleInstance,force
 loop,33
 {
  DetectHiddenWindows,On
  Sleep,33
  IfWinExist,QQ595076941_AutoRunAHK
   ExitApp
 }
 Gui, Show, Hide,QQ595076941_AutoRunAHK
}
;
; 请使用 窗口信息工具 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, 3000
 }
}
RemoveToolTip:
 SetTimer, RemoveToolTip, Off
 ToolTip
return
;

;  ;智能命令,双击ALT执行
;  Alt::
;   if winc_presses > 0 ; SetTimer 已经启动, 所以我们记录键击.
;   {
;    winc_presses += 1
;    return
;   }
;   ; 否则, 这是新开始系列中的首次按下. 把次数设为 1 并启动
;   ; 计时器:
;   winc_presses = 1
;   SetTimer, KeyWinC, -400 ; 在 400 毫秒内等待更多的键击.
;  return
;
;  ;双击执行跳转
;  KeyWinC:
;   if winc_presses = 2 ; 此键按下了两次.
;   {
;    Gui, Show
;
;   }
;   ; 不论触发了上面的哪个动作, 都对 count 进行重置
;   ; 为下一个系列的按下做准备:
;   winc_presses = 0
;  return

; 00打开随身U盘_办公专用盘()
; {
;  随身U盘的盘符:=搜索随身U盘并设置盘符()
;  if (随身U盘的盘符<>0)
;  { ToolTip
;   FileCreateDir, %随身U盘的盘符%:1_办公文件
;   DetectHiddenWindows,On
;   SetTitleMatchMode,2
;   ;~ 需要设置一下系统,工具->文件夹选项->查看->在标题栏显示完整路径
;   IfWinExist,9.22
;   {
;    WinShow,9.22
;    WinActivate,9.22
;    WinMaximize,9.22
;   }
;   else
;   {
;
;    IfExist,D:ProgramTotalCMDTotalCMD.exe
;    {
;     Run,D:ProgramTotalCMDTotalCMD.exe %随身U盘的盘符%:1_办公文件
;    }
;    else
;     MsgBox,找不到文件 D:ProgramTotalCMDTotalCMD.exe
;    ;~ Run,%随身U盘的盘符%:1_办公文件
;   }
;   loop,5
;   {
;    WinMove,01_办公文件 ahk_class CabinetWClass,,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight-35
;    Sleep,100
;   }
;  }
;  else
;   ToolTip,没有找到随身U盘
;       SetTimer, RemoveToolTip, 3000
; }
; ;
;  00打开随身办公专用U盘()
;  {
;   ; 检测操作是否成功的定时器周期应当大于操作定时器的周期(即500大于100)
;   SetTimer,AllMissionComplete,500
;   SetTimer,OpenWorkFolder,100
;   SetTimer,ActivateWorkFolder,100
;   SetTimer,ReSizeWorkFolder,100
;  }
;  ;
;  AllMissionComplete()
;  {
;   if(OpenCount >100)
;   {
;    SetTimer,AllMissionComplete,Delete
;    SetTimer,OpenWorkFolder,Delete
;    SetTimer,ActivateWorkFolder,Delete
;    SetTimer,ReSizeWorkFolder,Delete
;    ToolTip,没有找到随身U盘_请连接随身U盘到电脑
;    SetTimer, RemoveToolTip, 3000
;   }
;  IfWinActive,,01_办公文件
;  {
;   WinGetPos,X,Y,,,,01_办公文件
;   if(A_ScreenWidth/2-X=0)
;   {
;    SetTimer,AllMissionComplete,Delete
;    SetTimer,OpenWorkFolder,Delete
;    SetTimer,ActivateWorkFolder,Delete
;    SetTimer,ReSizeWorkFolder,Delete
;   }
;  }
;   Hotkey,“,00打开随身办公专用U盘
;  }
;  ;
;  OpenWorkFolder()
;  {
;   OpenCount++
;   IfWinNotExist,,01_办公文件
;   {
;    DriveGet,DriveList,List
;    loop,Parse,DriveList
;    {
;     DriveGet,USBDriveLabel,Label,%A_LoopField%:
;     IfInString,USBDriveLabel, 随身U盘
;     {
;      FileCreateDir,%A_LoopField%:1_办公文件
;      Run,%A_LoopField%:1_办公文件
;     }
;    }
;   }
;  }
;  ;
;  ActivateWorkFolder()
;  {
;   WinShow,,01_办公文件
;   WinActivate,,01_办公文件
;  }
;  ;
;  ReSizeWorkFolder()
;  {
;   WinMove,,01_办公文件,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight-35
;  }
;
; ===== 脚本结束 =====

 

////////////////////////////////////////////////////////////

 

;~ %A_ScriptDir%scripts无窗口全局热字串定义.ahk

; 用AutoHotkey的热字串功能启动常用电脑程序软件 Version 2 Build 20191214

; 电脑上的快捷键太多了,记都记不住,容易冲突和搞混,所以做了个热字串启动
; 用法:运行此脚本后在键盘上输入字符串  /np
; 此脚本的写作和调试完成日期:2019年12月12日
; 此脚本的作者:徐晓亮 (aahk)
; 此脚本作者的腾讯QQ电子邮箱地址:595076941@QQ.com

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance,force ;当此脚本已经运行时自动替换旧实例再次运行。
#Persistent  ;让脚本持久运行(即直到用户关闭或遇到 ExitApp)。
DetectHiddenWindows,On  ;设置脚本可以“看见”隐藏的窗口。
SetTitleMatchMode,2  ;窗口标题匹配模式改成某个位置必须包含WinTitle。
;
; 设置插入当前日期和时间的热字串WT ( What is the time now )
Sleep,500
::wt::
Sleep,500
 ClipSaved := ClipboardAll   ; 把剪贴板的所有内容保存到您选择的变量中
 NowTimeString =%A_YYYY%%A_MM%%A_DD%
 Clipboard :=NowTimeString
 Send ^v
 Sleep,500
 Clipboard := ClipSaved   ; 恢复剪贴板为原来的内容. 注意这里使用 Clipboard (不是 ClipboardAll).
 ClipSaved =   ; 在原来的剪贴板含大量内容时释放内存.
return
;
; 运行此脚本后在键盘上输入 `np 打开记事本程序 , `键位于Esc和Tab键之间(即波浪号~所在的键)
:*:“no::
:*:“np::
 IfExist,C:WindowsNotepad.exe
 {
  Run,C:WindowsNotepad.exe
 }
 else
 {
  MsgBox,没有找到记事本程序可执行文件C:WindowsNotepad.exe
 }
 ToolTip,正在启动记事本请稍后…
 SetTimer, RemoveToolTip, 3000
return
;
return
;
:*:“em::
:*:“ee::
 Hotstrings(“EmEditor”)
return
;
:*:“ma::
:*:“ms::
 Hotstrings(“MasterSeeker”)
return
;
:*:“so::
:*:“sg::
 Hotstrings(“SogouExplorer”)
return
;
:*:“to::
:*:“tc::
 Hotstrings(“TotalCMD”)
return
;
:*:“qq::
 Hotstrings2(“qq”)
return
;
Hotstrings(ExeName)
{

 IfExist,D:green%ExeName%%ExeName%.exe
 {
  Run,D:green%ExeName%%ExeName%.exe
 }
 else
 {
  MsgBox,没有找到可执行文件D:Program%ExeName%%ExeName%.exe
 }
 ToolTip,正在启动%ExeName%_请稍后…
 SetTimer, RemoveToolTip, 3000
}
;
Hotstrings2(ExeName2)
{
 IfExist,D:green%ExeName2%Bin%ExeName2%.exe
 {
  Run,D:green%ExeName2%Bin%ExeName2%.exe
 }
 else
 {
  MsgBox,没有找到可执行文件D:Program%ExeName2%Bin%ExeName2%.exe
 }
 ToolTip,正在启动%ExeName2%_请稍后…
 SetTimer, RemoveToolTip, 3000
}

; ===== 函数定义段 =====
打开随身U盘()
{
 随身U盘的盘符:=搜索随身U盘并设置盘符()
 if (随身U盘的盘符<>0)
 {
  SetTimer, RemoveToolTip, 5000
  FileCreateDir, %随身U盘的盘符%:1_办公文件
  DetectHiddenWindows,On
  SetTitleMatchMode,2
  ;~ 需要手动或用脚本语句设置一下系统,工具->文件夹选项->查看->在标题栏显示完整路径
  IfWinExist,,01_办公文件
  {
   WinShow,,01_办公文件
   WinActivate,,01_办公文件
  }
  else
  {
   Run,%随身U盘的盘符%:1_办公文件
  }
  loop,5
  {
   WinMove,,01_办公文件,A_ScreenWidth/2,0,A_ScreenWidth/2,A_ScreenHeight-35
   Sleep,100
  }
 }
 else
  ToolTip,没有找到随身U盘
 SetTimer, RemoveToolTip, 5000
}
;
; 根据磁盘卷标搜索到盘符后,可以再使用 IfExist 命令检查文件或文件夹是否存在。先检测,后执行。
搜索随身U盘并设置盘符()
{ 找到U盘:=false
 DriveGet,盘符清单,List
 loop,Parse,盘符清单
 { DriveGet,卷标,Label,%A_LoopField%:
  IfInString,卷标, 随身U盘
  { 找到U盘:=true
   return,%A_LoopField%
  }
 }
 if (not 找到U盘)
 { return,0
 }
}
;
;
RemoveToolTip:
 SetTimer, RemoveToolTip, Off
 ToolTip
return
; ===== 源代码备份网址 =====
; https://www.cnblogs.com/delphixx/p/12033306.html
; http://autohotkey.bokee.com/507502269.html
; ===== 脚本结束 =====

 

////////////////////////////////////////////////////////////

 

;~ %A_ScriptDir%scripts设置常驻内存的程序加快窗口显示的速度.ahk
;
global ProgramDir
;~ ProgramDir=%A_ScriptDir%……
ProgramDir=D:green
SetTimer,1设置此脚本的运行参数,-1000
;~ SetTimer,14设置此脚本用户自定义变量,-1000
SetTimer,2防止重复运行此脚本,-1000
SetTimer,3保持Everything窗口常驻内存从而提高显示速度,5000
return
;
1设置此脚本的运行参数()
{
#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,
}
;
2防止重复运行此脚本()
{
#SingleInstance,force
 loop,33
 {
  DetectHiddenWindows,On
  Sleep,33
  IfWinExist,QQ595076941_AutoRunAHK_ram
   ExitApp
 }
 Gui, Show, Hide,QQ595076941_AutoRunAHK_ram
}
;
3保持Everything窗口常驻内存从而提高显示速度()
{
 Process,Exist,Everything.exe
 if (%ErrorLevel%=0)
 {
  IfWinNotExist,Everything
  {
   IfWinNotExist,ahk_class EVERYTHING
   {
    IfWinNotExist,ahk_exe Everything.exe
    {
     IfExist,%ProgramDir%EverythingEverything.exe
      Run,%ProgramDir%EverythingEverything.exe
     WinWait,ahk_class EVERYTHING
     loop,3
     {
      WinHide,ahk_class EVERYTHING
      Sleep,50
     }
    }
   }
  }
 }
 ;~ Process,Exist,MasterSeeker.exe
 ;~ if (%ErrorLevel%=0)
 ;~ {
 ;~ IfWinNotExist,MasterSeeker 1.5.1 by DxCK
 ;~ {
 ;~ IfWinNotExist,ahk_exe MasterSeeker.exe
 ;~ {
 ;~ IfExist,%ProgramDir%MasterSeekerMasterSeeker.exe
 ;~ Run,%ProgramDir%MasterSeekerMasterSeeker.exe
 ;~ WinWait,ahk_class WindowsForms10.Window.8.app.0.218f99c
 ;~ loop,3
 ;~ {
 ;~ WinHide,ahk_class WindowsForms10.Window.8.app.0.218f99c
 ;~ Sleep,100
 ;~ }
 ;~ }
 ;~ }
 ;~ }
}
;
; #####################################################################
;
; 此脚本到此行结束

 

////////////////////////////////////////////////////////////

;~ 9键盘鼠标闲置无操作3分钟后关闭显示器闲置4分钟后锁定电脑桌面
;~ 系统设置:关闭显示器电源5分钟,屏幕保护6分钟
;当此脚本已经运行时自动替换旧实例再次运行。
#SingleInstance,force
;让脚本持久运行(即直到用户关闭或遇到 ExitApp)。
#Persistent
;
SetTimer,ScreenOff,1000
SetTimer,ScreenLock,1000
return
;
ScreenOff()
{
 ;超时毫秒数,4*60*1000=240000,1秒=1000毫秒
 if(A_TimeIdlePhysical>240000)
 {
  if(A_TimeIdle>240000)
  {
   ;~ 关闭显示器
   SendMessage, 0x112, 0xF170, 2,, Program Manager
  }
}
}
;
ScreenLock()
{
 ;超时毫秒数,6*60*1000=360000,1秒=1000毫秒
 if(A_TimeIdlePhysical>360000)
 {
  if(A_TimeIdle>360000)
  {
   ;~ 锁定电脑桌面
   Run,C:WindowsSystem32Rundll32.Exe user32.dll LockWorkStation
  }
}
}

 

////////////////////////////////////////////////////////////

;~ 桌面图标清理和恢复

;~ 清理桌面图标
;~ FileDelete,D:PersonalDesktop*.*

;~ 恢复默认的桌面图标
FileCopy,D:greenAHKManagerLnks*.*,D:PersonalDesktop,0

////////////////////////////////////////////////////////////

 

AHKManager-2021年2月19日

 

说明:本文的段落分割符号是一行连续的斜杠 ////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////

给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

使当前窗口向左延伸贴靠其他窗口

2021-2-19 11:04:24

其他教程

2021.10.03 BeautifulToolTip 高兼容 高性能 简单易用 自定义效果丰富的 ToolTip

2021-2-20 10:19:37

2 条回复 A文章作者 M管理员
  1. aahk

    ;
    ;~ 设置插入当前日期和时间的热字串WT ( What is the time now )
    ;~ 用搜狗拼音输入法输入”rq”再按数字2也可以方便快捷的输入当前日期
    ::wt::
    ClipSaved := ClipboardAll ; 把剪贴板的所有内容保存到您选择的变量中
    FormatTime,NowTimeStr,%A_YYYY%%A_MM%%A_DD%日,yyyy年M月d日
    Clipboard :=NowTimeStr
    Send ^v
    Clipboard := ClipSaved ; 恢复剪贴板为原来的内容. 注意这里使用 Clipboard (不是 ClipboardAll).
    ClipSaved = ; 在原来的剪贴板含大量内容时释放内存.
    return
    ;

  2. aahk

    ;
    ;~ 设置插入当前日期和时间的热字串 rq 空格
    ;~ 用搜狗拼音输入法输入”rq”再按数字2也可以方便快捷的输入当前日期
    ::rq::
    Sleep,100
    ClipSaved := ClipboardAll ; 把剪贴板的所有内容保存到您选择的变量中
    Sleep,100
    FormatTime,NowTimeStr,%A_YYYY%%A_MM%%A_DD%日,yyMMdd
    Sleep,100
    Clipboard :=NowTimeStr
    Sleep,200
    Send ^v
    Sleep,100
    Clipboard := ClipSaved ; 恢复剪贴板为原来的内容. 注意这里使用 Clipboard (不是 ClipboardAll).
    Sleep,100
    ClipSaved = ; 在原来的剪贴板含大量内容时释放内存.
    return
    ;

个人中心
购物车
优惠劵
有新私信 私信列表
搜索