Code: Select all
;====================================================>>主程序
; 将文件嵌入到脚本中
FileInstall, 01.AutoHotkey_1.1.37.01安装程序.exe, %A_Temp%\01.AutoHotkey_1.1.37.01安装程序.exe
FileInstall, 02.SciTE4AHK_v3.1.0_简体中文版.exe, %A_Temp%\02.SciTE4AHK_v3.1.0_简体中文版.exe
FileInstall, 03.AutoHotkey_v1.1.33.10_中文帮助文档.chm, %A_Temp%\03.AutoHotkey_v1.1.33.10_中文帮助文档.chm
FileInstall, 04.SciTE简体中文帮助.chm, %A_Temp%\04.SciTE简体中文帮助.chm
AutoHotKeyfile:= A_Temp . "\01.AutoHotkey_1.1.37.01安装程序.exe"
Scite4AHKfile:= A_Temp . "\02.SciTE4AHK_v3.1.0_简体中文版.exe"
AutoHotKeyCHM:= A_Temp . "\03.AutoHotkey_v1.1.33.10_中文帮助文档.chm"
Scite4AHKCHM:= A_Temp . "\04.SciTE简体中文帮助.chm"
; 运行AutoHotKey安装程序(如果未安装才安装)
AutoHotKeyInstalledMainFile := "C:\Program Files\AutoHotkey\AutoHotkey.exe"
if (!FileExist(AutoHotKeyInstalledMainFile)) { ;如果AutoHotkey主文件存在说明已安装过就不安装了
;AutoHotkeyInstallName :=A_Temp . "\01.AutoHotkey_1.1.37.01安装程序.exe"
if (FileExists(AutoHotKeyfile))
{
RunWait, %AutoHotKeyfile% /S
}
else
{
MsgBox, AutoHotkey安装程序%AutoHotkeyInstallName%不存在
return
}
}
else{
msg := "AutoHotkey已安装"
提示(msg,2000)
}
Scite4AHKInstalledMainFile := "C:\Program Files\AutoHotkey\SciTE\SciTE.exe"
if (!FileExist(Scite4AHKInstalledMainFile)) { ;如果Scite4AHK主文件存在说明已安装过就不安装了
if (FileExists(Scite4AHKfile))
{
InstallScite4AHK(Scite4AHKfile)
}
else
{
MsgBox, AutoHotkey安装程序%Scite4AHKfile%不存在
return
}
}
else{
msg := "Scite4AHK已安装"
提示(msg,2000)
}
AutoHotKeyHelp := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
SciTEHelp :="C:\Program Files\AutoHotkey\SciTE\SciTE.chm"
FileCopy, %AutoHotKeyCHM%, %AutoHotKeyHelp%,1
FileCopy, %Scite4AHKCHM%, %SciTEHelp%,1
Sleep 500
FileDelete, AutoHotKeyfile
FileDelete, Scite4AHKfile
FileDelete, AutoHotKeyCHM
FileDelete, Scite4AHKCHM
return
; 01.===============================函数:查找指定标题的窗口并获取其ID,然后激活该窗口
FindAndActivateWindow(Title)
{
; 使得标题匹配更灵活
SetTitleMatchMode, 2
; 查找窗口并获取其ID
WinGet, WindowID, ID, %Title%
; 检查是否找到了窗口
if (WindowID)
{
; 如果找到了窗口,则激活它
WinActivate, ahk_id %WindowID%
return true ; 返回true表示成功找到并激活窗口
}
else
{
; 如果未找到窗口,则返回false
return false
}
}
; 02.===============================函数:判断指定路径的文件是否存在
FileExists(FilePath)
{
; 检查文件是否存在
if (FileExist(FilePath))
{
return true ; 如果文件存在,返回true
}
else
{
return false ; 如果文件不存在,返回false
}
}
;03.===============================函数:运行Scite4AHK安装程序
InstallScite4AHK(SciTE4AHKInstallName)
{
; 运行Scite4AHK安装程序
if (FileExists(SciTE4AHKInstallName))
{
Run, %SciTE4AHKInstallName%
}
else
{
MsgBox, SciTE4AH安装程序%SciTE4AHKInstallName%不存在
return
}
WinWait, SciTE4AutoHotkey Setup, , 3
if ErrorLevel
{
MsgBox, 窗口等待超时.
return
}
WinActivate ; 激活找到的窗口.
BlockInput, On ; 锁定鼠标和键盘输入
sleep 500
send {Tab}
send {Enter}
sleep 500
send {Tab 6}
send {Enter}
sleep 500
send {Enter}
sleep 500
send {Enter}
sleep 500
send {Enter}
sleep 500
send {Enter}
;========================>>进入设置窗口
send {Down 8} ;选择中文
send {Tab 2}
sleep 500
send {Down 2} ;选择控制台中文
send {Tab 7}
sleep 500
send {Enter} ;点击确认按钮
Sleep 500
FindAndActivateWindow("SciTE properties editor")
Send {Enter}
Sleep 500
Send !{F4}
Sleep 500
WindowTitle := "SciTE4AutoHotkey"
if (FindAndActivateWindow(WindowTitle))
{
Send {Tab}{Enter}
}
;~ ; 解除锁定鼠标和键盘输入
BlockInput, Off
}
;04.===============================函数:提示信息
提示(msgtxt,time){
ToolTip, %msgtxt%
Sleep, %time% ; 等待3秒钟
ToolTip ; 清除提示信息
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
[Mod action: Moved topic from the main section which is for English only.]