#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. FileInstall, background.png, background.png FileInstall, background2.png, background2.png #Persistent #SingleInstance force DetectHiddenWindows, On CoordMode, Mouse, Screen Gui, -Caption +LastFound +OwnDialogs +ToolWindow +AlwaysOnTop ;+Background ;+Disabled +AlwaysOnTop -SysMenu +Owner Gui, color, EBEBEB Gui, Add, Picture, x-4 y2 w300 h100 vPic1, background.png Gui, Add, Picture, x-4 y2 w300 h100 vPic2,background2.png ;WinSet, TransColor, EBEBEB ;R90-90 ;Gui, Show, x400 y170 h46 w250, AHK SwitchIME by Seapard Gui, Show, x30 y660 h110 w300 NA, AHK SwitchIME by Seapard WinSet, Region, 0-2 W292 H99 , AHK SwitchIME by Seapard OnMessage(0x201, "WM_RBUTTONDOWN") hwnd := WinExist() WinSet, Transparent, 230, ahk_id %Hwnd% ;ControlGet, StaticHwnd,hwnd , , Static1, ahk_id %hwnd% ;ControlGet, ControlHwnd,hwnd , , Edit1, ahk_id %hwnd% ;ControlGet, ComboBoxHwnd,hwnd , , ComboBox1, ahk_id %hwnd% Settimer,IME_WatchCursor,100 ;SetTimer,WatchExplorer,3000 SetTimer, WatchMem,6600 Return IME_WatchCursor: WinGet,hWnd,id,A ;ToolTip,%hWnd% ;HKL := DllCall("GetKeyboardLayout", "UInt", 0, "UInt") ; 获取脚本当前输入法 Result := DllCall("GetKeyboardLayout","UInt", DllCall("GetWindowThreadProcessId","UInt", hWnd, "UIntp", 0),UInt) SetFormat, integer, hex Result += 0 SetFormat, integer, D ;ToolTip,%Result% If (Result=0x8040804) { GuiControl, Hide,Pic2 GuiControl, Show,Pic1 IME_flag:=0 } Else { GuiControl, Hide,Pic1 GuiControl, Show,Pic2 IME_flag:=1 } CoordMode,Mouse,Screen MouseGetPos,,,IME_Win_Id, IME_Win_Ctl WinGetTitle,IME_Win_Title,ahk_id %IME_Win_Id% WinGetTitle,IME_Win_Title2,A IfWinActive, AHK SwitchIME by Seapard ahk_class AutoHotkeyGUI Hotkey,*LButton,Switch_IME,Off ;Hotkey, IfWinActive, AHK SwitchIME by Seapard ahk_class AutoHotkeyGUI ;Hotkey,*LButton,Switch_IME,On ;Hotkey, IfWinActive If (IME_Win_Title="AHK SwitchIME by Seapard" && IME_Win_Title2IME_Win_Title) { Hotkey,*LButton,Switch_IME,On ;ToolTip,%IME_Win_Title% } Else { Hotkey,*LButton,Switch_IME,Off } Return WatchMem: EmptyMem() Return EmptyMem(PID="AHK Rocks"){ pid:=(pid="AHK Rocks") ? DllCall("GetCurrentProcessId") : pid h:=DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", pid) DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1) DllCall("CloseHandle", "Int", h) } WM_RBUTTONDOWN() { PostMessage, 0xA1, 2 } Switch_IME: F8:: WinGet, active_id, ID, A WinGetTitle,active_Title,ahk_id %active_id% If (IME_flag=0) { Loop,3 { DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("ActivateKeyboardLayout", UInt, 1, UInt, 256)) Result:=DllCall("GetKeyboardLayout","int",0,UInt) SetFormat, integer, hex Result += 0 SetFormat, integer, D If (Result=0x4090409) Break } GuiControl, Hide,Pic1 GuiControl, Show,Pic2 IME_flag:=1 } Else { Loop,3 { DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("ActivateKeyboardLayout", UInt, 1, UInt, 256)) Result:=DllCall("GetKeyboardLayout","int",0,UInt) SetFormat, integer, hex Result += 0 SetFormat, integer, D If (Result=0xe0010804) Break } GuiControl, Hide,Pic2 GuiControl, Show,Pic1 IME_flag-- } ;WinActivate,ahk_id %active_id% return