Autohotkey to modularization hotkey

Get help with using AutoHotkey and its commands and hotkeys
WingDust
Posts: 1
Joined: 16 May 2020, 17:48
GitHub: WingDust

Autohotkey to modularization hotkey

Post by WingDust » 16 May 2020, 18:14

I write ahk for a while
I am look for modularization hotkey way
such as I will write a script for one Application ,or some hotkey only need in same situation
I want to have a main script to quote all libary scripts and control other all scripts's use , And I only need to start main script complite all script
But i meet problem
I don't how to archieve that
this is my code
i need a demo to understand

Code: Select all

; main.ahk
#SingleInstance Force
#Persistent
#NoEnv


SetTitleMatchMode,2

Menu, Tray, Icon, %A_ScriptDir%\2.ico

#Include %A_ScriptDir%\lib\VIME.ahk
#Include %A_ScriptDir%\lib\open.ahk

Code: Select all

;VIME.ahk
GroupAdd , Escheck ,ahk_exe nvim-qt.exe
GroupAdd , Escheck ,ahk_exe Code.exe
GroupAdd , Escheck ,ahk_exe emacs.exe


IME_GetKeyboardLayoutName()
{
    VarSetCapacity(Str, 16)
    DllCall("GetKeyboardLayoutName", "Str", Str)
    Return Str
}

/*
1. 将 Esc 重映射,阻止 Esc 键原来的功能
2. 检测是否正使用中文在输入,检测是否存在输入窗口
  - 存在
    - 表示正在中文输入,只需要 send escape
  - 不存在
    - 表示不知道现在是中英文,但是它是正被使用
      - 获取当前系统的 KeyboardLayoutName 
      - 禁用输入法
      - 重加载 Rime
      - send escape
*/

RemoveToolTip:
ToolTip
return

;ahk_class ATL:00112928
;ahk_class ATL:00007FFF76DD4A60
;ahk_class ATL:00007FFC6C084A60
;ahk_class ATL:70B4D8A8
;ahk_class ATL:00007FFC7FC74A60
#IfWinActive ahk_group Escheck 
    Esc::
        imewin := WinExist("ahk_class ATL:0414D8A8")
        imewin2 := WinExist("ahk_class ATL:00112928")
        CodeImewin := WinExist("ahk_class ATL:00007FFD916B4A60")
        CodeImewin2 := WinExist("ahk_class ATL:00007FFC7FC74A60")
        emacsImewin := WinExist("ahk_class ATL:00007FFF76DD4A60")
        emacsImewin2 := WinExist("ahk_class ATL:00007FFC6C084A60")
        NvimImewin := WinExist("ahk_class ATL:70B4D8A8")


        l := StrLen(imewin)
        l2 := StrLen(imewin2)
        Codel := StrLen(CodeImewin)
        emacsl := StrLen(emacsImewin)
        emacsl2 := StrLen(emacsImewin2)
        nl := StrLen(NvimImewin)
        cl := StrLen(CodeImewin2)
        sleep 100
        ;ToolTip %emacsl2%

        if(l > 3 || l2 > 3|| Codel > 3 || emacsl >3 || emacsl2 > 3 || nl >3 || cl >3)
        {
            Tooltip No Need ,1920,1080
            SetTimer ,RemoveToolTip , -5000
            Send {Escape}
        }
        else
        {
            Tooltip Need ,1920,1080
            SetTimer ,RemoveToolTip , -5000
            ;Tooltip 2 %imewin% %imewin2% %CodeImewin%
            Run,"H:\mult.lnk"
            Send {Escape}
        }

    Return
#IfWinActive

Code: Select all

;open.ahk
/*
GroupAdd , openfileWindow , 打开
GroupAdd , openfileWindow , ahk_class #32770

#IfWinActive ahk_group openfileWindow
m::ControlFocus , DirectUIHWND2
Return

t::ControlFocus , SysTreeView321
Return

o::ControlFocus , ComboBox2
Return

h::Send,!{up}
Return

j::Send,{Down}
Return

k::Send,{Up}
Return

l::Send,{Right}
Return
#IfWinActive
*/
;/*
Hotkey,IfWinActive, ahk_class #32770

Hotkey,h,ArrowLeft,UseErrorLevel
Hotkey,j,ArrowDown,UseErrorLevel
Hotkey,k,ArrowUp,UseErrorLevel
Hotkey,l,ArrowRight,UseErrorLevel

Hotkey,m,FocusDirectory,UseErrorLevel
Hotkey,o,FocusOption,UseErrorLevel
Hotkey,t,FocusTree,UseErrorLevel


*/

;/*

ArrowLeft:
Send,!{up}
Return

ArrowDown:
Send,{Down}
Return

ArrowUp:
Send,{up}
Return

ArrowRight:
Send,{Enter}
Return

FocusDirectory:
ControlFocus , DirectUIHWND2
Return

FocusTree:
ControlFocus , SysTreeView321
Return

FocusOption:
ControlFocus , ComboBox2
Return
*/


Return to “Ask For Help”