发表回复 
Habit-2015 V1.1511
2015-03-12, 11 : 33 (这个帖子最后修改于: 2015-06-04 11 : 59 by 设计员_小猛.)
Habit-2015 V1.1511
脚本功能:
一、根据程序配置输入法 配置程序活动后自动切换到配置输入法
二、根据程序配置老板键 按下老板键后启动程序或激活程序或最小化程序
三、窗口功能热键自定义配置 添加“临时老板键”
四、脚本支持自动检测更新 并提示更新内容
下载地址
代码: (全选)
主脚本
;--------------------------------------Habit-2015 V1.1511
;~ 界面修改
;~ 支持定义老板键
;~ 支持大回车小回车切换
;--------------------------------------脚本头设置
#Persistent
#SingleInstance force
#ErrorStdOut
Process, priority, , High
DetectHiddenWindows,on
Hotkey, Enter ,Ente
Hotkey, NumpadEnter ,Ente
Hotkey, Enter ,off
Hotkey, NumpadEnter ,off
FileInstall,d:\desk\Habit-2015\Habit-更新.exe,%A_ScriptDir%\Habit-更新.exe,1
;--------------------------------------书写版本信息
IfExist ,%A_ScriptDir%\Habit-2015.exe
{
filepath = %A_ScriptDir%\Habit-2015.exe
SplitPath, filepath , FileName, DirPath,
objShell := ComObjCreate("Shell.Application")
objFolder := objShell.NameSpace(DirPath)
objFolderItem := objFolder.ParseName(FileName)
Loop,300
{
   propertyitem := objFolder.GetDetailsOf(objFolderItem, A_Index)
   properties := objFolder.GetDetailsOf(objFolder.Items, A_Index)
   if properties = 文件版本
   {
      StringLeft, propertyitem, propertyitem, 4
      break
   }
}
版本 = %propertyitem%
}
else
{
版本 = AHK版本
}
;--------------------------------------启用已设置热键
shuru = zuidaa`nzuixiaoo`nlinshii`njuzhongg`n
Loop,Parse,shuru,`n
{
    IniRead, winre, %A_ScriptDir%\窗口热键配置.ini,窗口配置,%A_Index%,%A_Space%
    if not winre
        continue
    Hotkey,%winre%,%A_LoopField%
}
;--------------------------------------获取输入法
Menu, MyContextMenu, Add,<<为程序配置老板键,laoban
HKLnum:=DllCall("GetKeyboardLayoutList","uint",0,"uint",0)
VarSetCapacity( HKLlist, HKLnum*4, 0 )
DllCall("GetKeyboardLayoutList","uint",HKLnum,"uint",&HKLlist)
Loop,%HKLnum%
{
    SetFormat, integer, hex
    HKL:=NumGet( HKLlist,(A_Index-1)*4 )
    StringTrimLeft,Layout,HKL,2
    Layout:= Layout=8040804 ? "00000804" : Layout
    Layout:= Layout=4090409 ? "00000409" : Layout
    RegRead,IMEName,HKEY_LOCAL_MACHINE,SYSTEM\CurrentControlSet\Control\Keyboar​d Layouts\%Layout%,Layout Text
    RegRead,Tubiao,HKEY_LOCAL_MACHINE,SYSTEM\CurrentControlSet\Control\Keyboard​ Layouts\%Layout%,Ime File
    SetFormat, integer, D
    if IMEName
    {
        Menu, %IMEName%, Add, 中文, SubMenu
        Menu, %IMEName%, Add, 英文, SubMenu
        Menu, MyContextMenu, Add, %IMEName%, :%IMEName%
        IniWrite,%Layout%, %A_ScriptDir%\窗口热键配置.ini,%IMEName%,key
    }
}
Menu, MyContextMenu, Add,<<保存并刷新列表,bao
Menu, MyContextMenu, Add,<<窗口操作配置,chuang
;--------------------------------------Gui界面
Gui,Add,ListView, Checked -Hdr Multi Report AltSubmit xm ym h143 w370 vMyListView,进程ID|输入状态|中英|热键|编号|路径
Gui,Add, StatusBar,,
SB_SetText("脚本信息:版本V1." . 版本 . "       系统:Win7 64位      AHK:L版1.1.15 ")
GuiControl, Focus,MyListView
Gui +HwndMyGuiHwnd
Gui,Add, Text,ym x+5  vwenzi Section,最大化`n`n`n最小化`n`n`n临时老板键`n`n`n缩小剧中
Gui,Add,Hotkey,xs y20 vzuida
Gui,Add,Hotkey,xs y+16 vzuixiao
Gui,Add,Hotkey,xs y+16 vlinshi
Gui,Add,Hotkey,xs y+16 vjuzhong w94 Section
Gui,Add,Button,ys x+5 h20 vqueque gqueque Default,确定
Gui,Add,Hotkey,xm y+5 h23 Section Limit1 vChosenHotkey
Gui,Add,Button,ys x+5 gChosenHotkey vsenHot Default,确定
Gui,Add,Button,ys x+5 gquxiao vquxiao,取消
Gui,Show,AutoSize,Habit-2015
Guiwen()
Guique()
Gui,Cancel
;--------------------------------------Menu界面
Menu,Tray,Click, 1
Menu,Tray,Tip, 版本:V1.%版本%`n脚本:AutoHotkey1.15`n系统:Win7 64位
Menu,Tray,Add, By,小死猛, Menu_显示窗口
Menu,Tray,Add, 联系作者, Menu_联系作者
Menu,Tray,Add, 支持作者, Menu_支持作者
Menu,Tray,Add,
Menu,Tray,Add, 开启脚本
Menu,Tray,Add, 回车切换
Menu,Tray,Add, 开机启动
Menu,Tray,Add,
Menu,Tray,Add, 停用热键
Menu,Tray,Add, 重启脚本, Menu_重启脚本
Menu,Tray,Add, 退出脚本, Menu_退出脚本
Menu,Tray,Default, By,小死猛
Menu,Tray,NoStandard
GuiStart()
;--------------------------------------检查是否自动开启脚本
Run,%A_ScriptDir%\Habit-更新.exe
IniRead,huiche, %A_ScriptDir%\窗口热键配置.ini,回车切换,Key
if huiche
{
    Menu, Tray,Check, 回车切换
    Hotkey, Enter ,On
    Hotkey, NumpadEnter ,On
}
IfExist ,%A_Startup%\输入法.lnk
{
    TrayTip,,脚本已最小化至托盘, 10, 1
    Menu, Tray, ToggleCheck, 开机启动
    gosub,开启脚本
}
else
{
    Gui,Show,AutoSize,Habit-2015
}
return
;--------------------------------------Menu命令一
Menu_显示窗口:
    DetectHiddenWindows,off
    IfWinExist, ahk_id %MyGuiHwnd%
    {
        Gui,Cancel
        return
    }
    Gui,Show,AutoSize
return
Menu_联系作者:
    Run tencent://message/?uin=4845514
return
Menu_支持作者:
    SetTimer,ChangeButtonNames,50
    MsgBox,4,感谢支持本功能,感谢支持本功能
    IfMsgBox Yes
        MsgBox 支付宝帐号:skc2015@163.com`n户名:刘猛
return
ChangeButtonNames:
    IfWinNotExist,感谢支持本功能
        return
    SetTimer,ChangeButtonNames,off
    WinActivate
    ControlSetText,Button1,RMB支持
    ControlSetText,Button2,精神支持
return
;--------------------------------------Menu命令二段
开启脚本:
    Menu, Tray, ToggleCheck, 开启脚本
    winuu = 5
    if winoo = 6
    {
        winoo = 4
    }
    else
    {
        winoo = 6
    }
    gosub,kik
return
回车切换:
    if huiche
    {
        IniWrite,%A_Space%, %A_ScriptDir%\窗口热键配置.ini,回车切换,Key
    }
    else
    {
        IniWrite,1, %A_ScriptDir%\窗口热键配置.ini,回车切换,Key
    }
    Menu, Tray,ToggleCheck, 回车切换
    Hotkey, Enter,Toggle
    Hotkey, NumpadEnter,Toggle
    IniRead,huiche, %A_ScriptDir%\窗口热键配置.ini,回车切换,Key,%A_Space%
return
开机启动:
    Menu, Tray, ToggleCheck, 开机启动
    IfExist ,%A_Startup%\输入法.lnk
    {
        FileDelete,%A_Startup%\输入法.lnk
    }
    else
    {
        FileCreateShortcut,%A_ScriptDir%\%A_ScriptName%,%A_Startup%\输入法.lnk
    }
return
;--------------------------------------Menu命令三段
停用热键:
    if NewName <> 启用热键
    {
        OldName = 停用热键
        NewName = 启用热键
        winrj =
    }
    else
    {
        OldName = 启用热键
        NewName = 停用热键
        winrj = 1
    }
    Menu, tray, rename, %OldName%, %NewName%
    Loop % LV_GetCount()
    {
        RowNumbe := LV_GetNext(RowNumbe,"Checked")
        if not RowNumbe
            continue
        LV_GetText(热键, RowNumbe,4)
        if not 热键
            continue
        if not winrj
        {
            Hotkey,%热键%,Off
        }
        else
        {
            Hotkey,%热键%,On
            Hotkey,%热键%,MyLabel
        }
    }
return
Menu_重启脚本:
    Reload
Menu_退出脚本:
    ExitApp
    ;--------------------------------------主要功能
kik:
    while winoo>winuu
    {
        WinGet, win_pc,ID,A ;避免QQ聊天窗口与界面窗口同在问题
        WinWaitNotActive,ahk_id %win_pc% ;只在出现新窗口时执行优化效率 同样也避免了与保存的冲突
        WinGet, win_pp,ProcessName,A
        StringReplace, win_pp, win_pp,.exe
        IniRead, Layout, %A_ScriptDir%\输入法设定.ini,%win_pp%,编号,%A_Space%
        if Layout
            SwitchIME(Layout)
            IniRead, Layout, %A_ScriptDir%\输入法设定.ini,%win_pp%,中英,%A_Space%
        if Layout = 英文
            DllCall("SendMessage", UInt,DllCall("imm32\ImmGetDefaultIMEWnd", Uint,WinExist("A")), UInt,0x0283, Int,0x002,Int,0x00)
        else
            DllCall("SendMessage", UInt,DllCall("imm32\ImmGetDefaultIMEWnd", Uint,WinExist("A")), UInt,0x0283 ,Int,0x002,Int,0x401)
    }
Ente:
    Hotkey,%A_ThisHotkey%,Off
    Send {%A_ThisHotkey%}
    Hotkey,%A_ThisHotkey%,On
    WinGet, win_cl, ProcessName, A
    StringReplace, win_cl, win_cl,.exe
    IniRead, Layout, %A_ScriptDir%\输入法设定.ini,%win_cl%,编号,%A_Space%
    if Layout
        SwitchIME(Layout)
        IniRead, Layout, %A_ScriptDir%\输入法设定.ini,%win_cl%,中英,%A_Space%
    if Layout = 英文
        DllCall("SendMessage", UInt,DllCall("imm32\ImmGetDefaultIMEWnd", Uint,WinExist("A")), UInt,0x0283, Int,0x002,Int,0x00)
    else
        DllCall("SendMessage", UInt,DllCall("imm32\ImmGetDefaultIMEWnd", Uint,WinExist("A")), UInt,0x0283 ,Int,0x002,Int,0x401)
return
MyLabel:
    Loop % LV_GetCount()
    {
        RowNumbe := LV_GetNext(RowNumbe,"Checked")
        if not RowNumbe
            continue
        LV_GetText(热键, RowNumbe,4)
        if 热键 = %A_ThisHotkey%
        {
            LV_GetText(winexe, RowNumbe,1)
            LV_GetText(winlj, RowNumbe,6)
        }
    }
    DetectHiddenWindows,off
    IfWinActive ,ahk_exe %winexe%.exe
    {
        WinMinimize
        return
    }
    IfWinExist ,ahk_exe %winexe%.exe
    {
        WinActivate
    }
    else
    {
        Run,%winlj%
    }
return
;--------------------------------------右键菜单
GuiContextMenu:            ;只在MyListView中显示右键菜单
    win_xz := A_EventInfo
    if not win_xz
        return
    if A_GuiControl <> MyListView
        return
    Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
return
laoban:                    ;为程序配置老板键
    热键列表 =
    Loop
    { ;添加配置文件中项目
        IniRead, win_dq, %A_ScriptDir%\输入法设定.ini, 选定项目,%A_Index%,%A_Space%
        if not win_dq
        {
            break
        }
        IniRead, 热键, %A_ScriptDir%\输入法设定.ini, %win_dq%, 热键,%A_Space%
        热键列表 = %热键%-%热键列表%
    }
    LV_GetText(winlj, win_xz,6)
    IfInString,winlj,WINDOWS
    {
        SB_SetText("系统目录程序不允许设置热键")
        return
    }
    Guique()
    GuiControl,,ChosenHotkey
    Gui,Show,AutoSize
    GuiControl,Focus,ChosenHotkey
    gosub,停用热键
    SB_SetText("已经停用所有热键请设置")
return
ChosenHotkey:
    Gui,Submit,NoHide
    IfInString,热键列表,%ChosenHotkey%
    {
        if not ChosenHotkey
        {
            LV_GetText(有无状态, win_xz,2)
            if not 有无状态
            {
                LV_Modify(win_xz,"-Check")
                SB_SetText("此次未配置任何选项 已取消选中")
            }
            else
            {
                LV_Modify(win_xz,,,,ChosenHotkey)
                SB_SetText("已停用此程序热键")
            }
        }
        else
        {
            SB_SetText("已经存在此热键  请制空此热键后重新设置")
        }
        Guique()
        Gui,Show,AutoSize
        gosub,停用热键
        gosub,bao
        return
    }
    LV_Modify(win_xz,,,,ChosenHotkey)
    Hotkey,%ChosenHotkey%, MyLabel
    热键列表 = %ChosenHotkey%`n%热键列表%
    LV_Modify(win_xz,"Check")
    GuiControl,Hide ,ChosenHotkey
    GuiControl,Hide ,senHot
    GuiControl,Hide,quxiao
    Gui,Show,AutoSize
    gosub,停用热键
    gosub,bao
    SB_SetText("所有热键以重新启用 此次设置成功")
return
quxiao:
    Guique()
    Gui,Show,AutoSize
    gosub,停用热键
    SB_SetText("所有热键以重新启用 取消本次设置")
return
SubMenu:
IniRead, OutputVar,%A_ScriptDir%\窗口热键配置.ini,%A_ThisMenu%,key
LV_Modify(win_xz,,,A_ThisMenu)
LV_Modify(win_xz,,,,A_ThisMenuItem)
LV_Modify(win_xz,,,,,,OutputVar)
LV_Modify(win_xz,"Check")
GuiControl, Focus,MyListView
SB_SetText("保存成功,如未刷新出隐藏至托盘的程序,请换出窗口刷新。")
return
;--------------------------------------窗口操作设置
chuang:
    Guiwen()
    Gui,Show,AutoSize
    shur = zuida`nzuixiao`nlinshi`njuzhong`n
    Loop,Parse,shur,`n
    {
        IniRead, winre, %A_ScriptDir%\窗口热键配置.ini,窗口配置,%A_Index%,%A_Space%
        if not winre
            continue
        GuiControl,,%A_LoopField%,%winre%
        Hotkey,%winre%,Off
    }
return
queque:
    Gui, Submit,NoHide
    IniWrite, %zuida%, %A_ScriptDir%\窗口热键配置.ini,窗口配置,1
    IniWrite, %zuixiao%, %A_ScriptDir%\窗口热键配置.ini,窗口配置,2
    IniWrite, %linshi%, %A_ScriptDir%\窗口热键配置.ini,窗口配置,3
    IniWrite, %juzhong%, %A_ScriptDir%\窗口热键配置.ini,窗口配置,4
    Loop,Parse,shuru,`n
    {
        IniRead, winer, %A_ScriptDir%\窗口热键配置.ini,窗口配置,%A_Index%,%A_Space%
        if not winer
            continue
        Hotkey,%winer%,%A_LoopField%
        Hotkey,%winer%,On
    }
    Guiwen()
    Gui,Show,AutoSize
return
;--------------------------------------窗口操作的一些标签
zuixiaoo:             ;窗口最小化
    WinMinimize A
return
zuidaa:               ;窗口最大化N
    WinMaximize A
return
linshii:
    if win_cs > 0
    {  ;记录次数
        win_cs += 1
        return
    }
    win_cs = 1
    SetTimer, KeyAlt, 300 ;300毫秒内等待更多键击
return
KeyAlt:
    SetTimer, KeyAlt, off
    if win_cs = 1
    {  ;一次则激活或最小化
        IfWinActive ,ahk_id %win_id%
        {
            WinMinimize
            win_cs = 0
            return
        }
        else
        {
            WinActivate ,ahk_id %win_id%
            win_cs = 0
            return
        }
    }
    if win_cs = 2
    {  ;两次则新定义
        WinGet,win_id,id,A
        WinMinimize A
    }
    else if win_cs > 2
    {  ;超次则清空
        WinClose,ahk_id %win_id%
        win_id =
    }
    win_cs = 0
return
juzhongg: ;把当前窗口还原后移到屏幕正中间!
    WinRestore,A
    WinGetPos,,, Width, Height, A
    WinMove, A,, (A_ScreenWidth/2)-430, (A_ScreenHeight/2)-300, 863, 569
return
GuiClose:
    Gui,Cancel
return
;--------------------------------------加载与保存
bao:
    FileSetAttrib, -R, %A_ScriptDir%\输入法设定.ini ;取消配置文件只读选项
    FileDelete,%A_ScriptDir%\输入法设定.ini
    Loop % LV_GetCount()
    {
        RowNumber := LV_GetNext(RowNumber,"Checked")
        if not RowNumber
            break
        LV_GetText(进程, RowNumber, 1)
        LV_GetText(状态, RowNumber, 2)
        LV_GetText(中英, RowNumber, 3)
        LV_GetText(热键, RowNumber, 4)
        LV_GetText(编号, RowNumber, 5)
        LV_GetText(路径, RowNumber, 6)
        IniWrite, %进程%, %A_ScriptDir%\输入法设定.ini, 选定项目,%A_Index%
        IniWrite, %进程%, %A_ScriptDir%\输入法设定.ini, %进程%, 进程
        IniWrite, %状态%, %A_ScriptDir%\输入法设定.ini, %进程%, 状态
        IniWrite, %中英%, %A_ScriptDir%\输入法设定.ini, %进程%, 中英
        IniWrite, %热键%, %A_ScriptDir%\输入法设定.ini, %进程%, 热键
        IniWrite, %编号%, %A_ScriptDir%\输入法设定.ini, %进程%, 编号
        IniWrite, %路径%, %A_ScriptDir%\输入法设定.ini, %进程%, 路径
    }
    GuiStart()
    LV_ModifyCol(2,"SortDesc")
return
Guiwen(){
GuiControlGet, OutputVar, Visible,wenzi
if OutputVar
{
GuiControl,Hide,wenzi
GuiControl,Hide,zuida
GuiControl,Hide,zuixiao
GuiControl,Hide,linshi
GuiControl,Hide,juzhong
GuiControl,Hide,queque
}
else
{
GuiControl,Show,wenzi
GuiControl,Show,zuida
GuiControl,Show,zuixiao
GuiControl,Show,linshi
GuiControl,Show,juzhong
GuiControl,Show,queque
}
}
Guique(){
GuiControlGet, OutputVar, Visible,quxiao
if OutputVar
{
GuiControl,Hide,quxiao
GuiControl,Hide,ChosenHotkey
GuiControl,Hide,senHot
}
else
{
GuiControl,Show,quxiao
GuiControl,Show,ChosenHotkey
GuiControl,Show,senHot
}
}
GuiStart() {
    热键列表 =
    LV_Delete()
    WinGet,WinList,List
    WinAll:= Object()
    ImageListID := IL_Create(WinAll)
    LV_SetImageList(ImageListID)
    WinListPN:=
    Loop,%WinList% {
        id:=WinList%A_Index%
        WinGet,win_ll,ProcessName,ahk_id %id%
        StringReplace, win_ll, win_ll,.exe
        WinListPN:=WinListPN win_ll "`n"
    }
    Sort,WinListPN,U ;排除类似IE 或文本文件编辑
    Loop
    { ;排除配置文件中的项目
        IniRead, 排除, %A_ScriptDir%\输入法设定.ini, 选定项目,%A_Index%,%A_Space%
        if not 排除
        {
            break
        }
        StringReplace, WinListPN, WinListPN, %排除% ,UseErrorLevel ,
    }
    Sort,WinListPN,U ;继续避免重复
    WinList_Array:=StrSplit(RTrim(WinListPN,"`n"),"`n")
    win_A_Index = 1
    For index, 进程 in WinList_Array {
        WinGet,路径,ProcessPath,ahk_exe %进程%.exe
    IfNotExist ,%路径%
    { ;路径不存在则不添加
        continue
    }
    if (GetIconCount(路径)>0)
        IL_Add(ImageListID, 路径,1)
    else ;图标为空则不添加
        continue
    LV_Add("Icon" . win_A_Index,进程,,,,路径)
    win_A_Index++
}
RowNumber := LV_GetCount()
Loop
{ ;添加配置文件中项目
    IniRead, win_dq, %A_ScriptDir%\输入法设定.ini, 选定项目,%A_Index%,%A_Space%
    if not win_dq
    {
        break
    }
    IniRead, 进程, %A_ScriptDir%\输入法设定.ini, %win_dq%, 进程,%A_Space%
    IniRead, 状态, %A_ScriptDir%\输入法设定.ini, %win_dq%, 状态,%A_Space%
    IniRead, 中英, %A_ScriptDir%\输入法设定.ini, %win_dq%, 中英,%A_Space%
    IniRead, 热键, %A_ScriptDir%\输入法设定.ini, %win_dq%, 热键,%A_Space%
    IniRead, 编号, %A_ScriptDir%\输入法设定.ini, %win_dq%, 编号,%A_Space%
    IniRead, 路径, %A_ScriptDir%\输入法设定.ini, %win_dq%, 路径,%A_Space%%A_Space%
    IfNotExist ,%路径%
    {
        continue
    }
    RowNumber++
    if 热键
    {
        Hotkey,%热键%, MyLabel
    }
    IL_Add(ImageListID, 路径,1)
    LV_Add("Icon" . RowNumber,进程,状态,中英,热键,编号,路径)
    LV_Modify(RowNumber,"Check")
}
LV_ModifyCol(1,110)
LV_ModifyCol(2,140)
LV_ModifyCol(3,50)
LV_ModifyCol(4,50)
LV_ModifyCol(3,"SortDesc")
LV_ModifyCol(5,0)
LV_ModifyCol(6,0)
}
;--------------------------------------调用与获取
GetIconCount(file){ ;排除没有图标的程序
    Menu, test, add, test, handle
    Loop
    {
        try {
            id++
        Menu, test, Icon, test, % file, % id
    } catch error {
    break
}
}
return id-1
}
handle:
return
SwitchIME(dwLayout){ ;修改当前窗口输入法
    HKL:=DllCall("LoadKeyboardLayout", Str, dwLayout, UInt, 1)
    ControlGetFocus,ctl,A
    SendMessage,0x50,0,HKL,%ctl%,A
}
;--------------------------------------脚本结束
代码: (全选)
更新脚本
;---------------------------------------------检查网络连接是否正常
#NoTrayIcon
pinginfo := Object()
ping(pinginfo){
site := pinginfo["site"] ;赋值
RunWait, %ComSpec% /c ping -n 1 %site% >%A_Temp%\ahk_ping.tmp, , Hide ;有cmd ping网址并保存到临时文件夹
FileRead, content, %A_Temp%\ahk_ping.tmp ;读取整个文件到变量
StringReplace, content, content, `r, , All ;去除回车符
StringSplit, var, content, `n ;按换行分割
If content Contains 请求超时,Request timed out
{
pinginfo["msg"] = "请求超时" ;返回msg
MsgBox,检测更新请求超时
    ExitApp
Return pinginfo ;返回数组
}
If content Contains 找不到主机,could not find host
{
pinginfo["msg"] = "找不到主机"
MsgBox,检测更新找不到主机
    ExitApp
Return pinginfo ;返回数组
}
Else
{
pinginfo["msg"] := "正常"
Return pinginfo ;返回数组
}
}
site = habit-2015.54fe89771abc8.d01.nanoyun.com
if site <>
{
pinginfo["site"] := site
pinginfo := ping(pinginfo)
msg := pinginfo["msg"]
}
else
{
    MsgBox,%Msg%
    Return
}
;---------------------------------------------检查网络上最新版本号
win = http://habit-2015.54fe89771abc8.d01.nanoyun.com/Habit/update.txt?fakeParam=%A_Now%
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET",win)
whr.Send()
version := whr.ResponseText
;---------------------------------------------检查本地脚本版本号
filepath = %A_ScriptDir%\Habit-2015.exe
SplitPath, filepath , FileName, DirPath,
objShell := ComObjCreate("Shell.Application")
objFolder := objShell.NameSpace(DirPath)
objFolderItem := objFolder.ParseName(FileName)
Loop,300
{
   propertyitem := objFolder.GetDetailsOf(objFolderItem, A_Index)
   properties := objFolder.GetDetailsOf(objFolder.Items, A_Index)
   if properties = 文件版本
   {
      StringLeft, propertyitem, propertyitem, 4
      break
   }
}
;---------------------------------------------判断是否存在更新
if (version > propertyitem)
{
URLDownloadToFile,http://habit-2015.54fe89771abc8.d01.nanoyun.com/Habit/Information.txt?fakeParam=%A_Now%,%A_ScriptDir%\Information.txt
FileRead, OutputVar, %A_ScriptDir%\Information.txt
FileRecycle,%A_ScriptDir%\Information.txt
    MsgBox, 4,是否更新 Habit-2015,%OutputVar%
IfMsgBox Yes
    gosub,Labe2
else
    ExitApp
}
else
{
    ExitApp
}
return
;---------------------------------------------开始更新
Labe2:
windo := InternetFileGetSize("http://habit-2015.54fe89771abc8.d01.nanoyun.com/Habit/Habit.exe")
InternetFileGetSize(URL:=""){
Static LIB="WININET\", CL="00000000000000", N=""
QRL := 16
If ! DllCall( "GetModuleHandle", Str,"wininet.dll" )
      DllCall( "LoadLibrary", Str,"wininet.dll" )
If ! hIO:=DllCall( LIB "InternetOpenA", Str,N, UInt,4, Str,N, Str,N, UInt,0 )
   Return -1
If ! (( hIU:=DllCall( LIB "InternetOpenUrlA", UInt,hIO, Str,URL, Str,N, Int,0, UInt,F
                                                            , UInt,0 ) ) || ErrorLevel )
   Return "",0 - ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) ) - 2
If ! ( RB  )
If ( SubStr(URL,1,4) = "ftp:" )
    CL := DllCall( LIB "FtpGetFileSize", UInt,hIU, UIntP,0 )
Else If ! DllCall( LIB "HttpQueryInfoA", UInt,hIU, Int,5, Str,CL, UIntP,QRL, UInt,0 )
   Return "",0 - ( !DllCall( LIB "InternetCloseHandle", UInt,hIU ) )
            - ( !DllCall( LIB "InternetCloseHandle", UInt,hIO ) ) - 4
return CL
}
Process,Close,Habit-2015.exe
Progress,1,,正在更新..., Habit-2015
SetTimer ,Label,500
URLDownloadToFile,http://habit-2015.54fe89771abc8.d01.nanoyun.com/Habit/Habit.exe?fakeParam=%A_Now%,%A_ScriptDir%\Habit.exe
if ErrorLevel = 1
{
    TrayTip,更新失败,原因不明`n请联系QQ:4845514, 10, 1
    Sleep,10000
}
else
{
    FileMove, %A_ScriptDir%\Habit.exe,%A_ScriptDir%\Habit-2015.exe,1
    Run,%A_ScriptDir%\Habit-2015.exe
}
return
Label:
FileGetSize, OutputVar ,%A_ScriptDir%\Habit.exe
wix := OutputVar/windo
wix := wix*100
Progress, %wix%,,正在更新..., Habit-2015
return

我的GitHub地址
访问这个用户的网站 查找这个用户的全部帖子
表示感谢 引用并回复 移动视图置页面顶端
[+] 3用户表示感谢设计员_小猛
2015-03-13, 08 : 46 (这个帖子最后修改于: 2015-03-13 10 : 50 by MarkRobinson.)
RE: Habit-2015 V1.1511
感谢楼主,能否支持程序不活动后,返回先前的输入法
查找这个用户的全部帖子
表示感谢 引用并回复 移动视图置页面顶端
2015-03-13, 20 : 10
RE: Habit-2015 V1.1511
建议用 SHELLHOOK 来检测窗口的激活、创建。

参考帖子:
[How to] Hook on to Shell to receive its messages?
http://www.autohotkey.com/board/topic/80...-messages/
查找这个用户的全部帖子
表示感谢 引用并回复 移动视图置页面顶端
2015-03-16, 16 : 14
RE: Habit-2015 V1.1511
@tmplinshi 谢谢意见

我的GitHub地址
访问这个用户的网站 查找这个用户的全部帖子
表示感谢 引用并回复 移动视图置页面顶端
2017-09-09, 13 : 11
RE: Habit-2015 V1.1511
感觉不是根据程序设置输入法而是老板键
查找这个用户的全部帖子
表示感谢 引用并回复 移动视图置页面顶端
发表回复 


论坛跳转:


联系我们 | Autohotkey 中文站 | 回到顶部 | 回到正文区 | 精简(归档)模式 | RSS 聚合