Всё разобрался . Забыл подставить "x" "y".
Вот готовый код.
#NoEnv
#Persistent
#Singleinstance, force
SetWorkingDir, %A_ScriptDir%/res
SetBatchLines,-1
CoordMode,Mouse,Screen
CoordMode,tooltip,Screen
CoordMode,Caret,Screen
SetKeyDelay, -1, -1
SetWinDelay,20
OCR_IBEAM := 32513, OCR_NORMAL := 32512, OCR_APPSTARTING := 32650,OCR_HAND := 32649,OCR_WAIT := 32514
SetTimer, LocaleWatch, 100
IniRead, xxxx, Position.ini, xdirectory, xxxx
IniRead, yyyy, Position.ini, ydirectory, yyyy
Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
Gui, Add, Picture, x0 y0 w20 h16 vStatic1, Ru1.png
Gui, Add, Picture, x0 y0 w20 h16 vStatic2, En1.png
Gui, Show, x%xxxx% y%yyyy% h16 w20 NA,lang053
Menu, Tray, NoStandard
Menu, Tray, Add, Выход, sub3
hGui:=WinExist()
loop
{
MouseGetPos,,,mwin
oldlang:=lang
lang:=InputLayout()
if (oldlang!=lang)
If (lang = "Russian")
{
Menu, Tray, Icon, Ru.ico, 1, 1
GuiControl, hide, static2
GuiControl, Show, static1
}
Else If (lang = "English")
{
Menu, Tray, Icon, En.ico, 1, 1
GuiControl, hide, static1
GuiControl, Show, static2
}
Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
sleep, 50
}
#if (mwin=hGui)
lbutton::
MoveWin(hGui)
return
#if
MoveWin(hwnd,key="lbutton")
{
MouseGetPos,oldmmx,oldmmy
while GetKeyState(key,"P")
{
sleep,10
MouseGetPos,mmx,mmy
WinGetPos,wx,wy,ww,wh,ahk_id %hwnd%
wx:=wx+mmx-oldmmx
wy:=wy+mmy-oldmmy
WinMove,ahk_id %hwnd%,,%wx%,%wy%
oldmmx:=mmx
oldmmy:=mmy
}
return
}
InputLayout()
{
WinGetClass, Class, % "ahk_id" hID := WinExist("A")
if !id := DllCall("GetWindow", Ptr, hid, UInt, GW_OWNER := 4, Ptr)
id:=hID
ThreadID := DllCall("GetWindowThreadProcessId", "Int", id, "Int", 0)
HKL := DllCall("GetKeyboardLayout", "uint", ThreadID, "UShort")
VarSetCapacity(sKbd, 260, 0)
DllCall("GetLocaleInfo", "uint", HKL
, "uint", 0x1001
, "str", sKbd
, "uint", 260)
Return sKbd
}
$sc1D::
If DllCall("GetKeyboardLayout", "Int", DllCall("GetWindowThreadProcessId", "Int", WinExist("A"), "Int", "0"))=0x4190419
{
ControlGetFocus, CtrlFocus, % "ahk_id" WinExist("A")
PostMessage, 0x50, 0, 0x4090409, %CtrlFocus% ;английский
}
else
{
ControlGetFocus, CtrlFocus, % "ahk_id" WinExist("A")
PostMessage, 0x50, 0, 0x4190419, %CtrlFocus% ;русский
}
return
LocaleWatch:
MouseGetPos,,, WinID
ThreadID := DllCall("GetWindowThreadProcessId", UInt, WinID, UInt, 0)
InputLocaleID := DllCall("GetKeyboardLayout", UInt, ThreadID)
if (InputLocaleID = Prev_InputLocaleID)
Return
bool := (InputLocaleID = 0x4090409)
hArrow := DllCall("LoadCursorFromFile", Str, (bool ? "EN" : "RU") . "_ARROW.ani")
hIbeam := DllCall("LoadCursorFromFile", Str, (bool ? "EN" : "RU") . "_IBEAM.ani")
hAPPSTARTING := DllCall("LoadCursorFromFile", Str, (bool ? "EN" : "RU") . "_APPSTARTING.ani")
hWAIT := DllCall("LoadCursorFromFile", Str, (bool ? "EN" : "RU") . "_WAIT.ani")
hHAND := DllCall("LoadCursorFromFile", Str, (bool ? "EN" : "RU") . "_HAND.ani")
DllCall("SetSystemCursor", UInt, hArrow, Int, OCR_NORMAL)
DllCall("SetSystemCursor", UInt, hIbeam, Int, OCR_IBEAM)
DllCall("SetSystemCursor", UInt, hAPPSTARTING, Int, OCR_APPSTARTING)
DllCall("SetSystemCursor", UInt, hWAIT, Int, OCR_WAIT)
DllCall("SetSystemCursor", UInt, hHAND, Int, OCR_HAND)
Prev_InputLocaleID := InputLocaleID
Return
hArrow := DllCall("LoadCursorFromFile", Str, "GR_ARROW.ani")
hIbeam := DllCall("LoadCursorFromFile", Str, "GR_IBEAM.ani")
hAPPSTARTING := DllCall("LoadCursorFromFile", Str, "GR_APPSTARTING.ani")
hWAIT := DllCall("LoadCursorFromFile", Str, "GR_WAIT.ani")
hHAND := DllCall("LoadCursorFromFile", Str, "GR_HAND.ani")
DllCall("SetSystemCursor", UInt, hArrow, Int, OCR_NORMAL)
DllCall("SetSystemCursor", UInt, hIbeam, Int, OCR_IBEAM)
DllCall("SetSystemCursor", UInt, hAPPSTARTING, Int, OCR_APPSTARTING)
DllCall("SetSystemCursor", UInt, hWAIT, Int, OCR_WAIT)
DllCall("SetSystemCursor", UInt, hHAND, Int, OCR_HAND)
Prev_InputLocaleID := 1
sub3:
DllCall("SystemParametersInfo", UInt, "0x57", UInt, 0, UInt, 0, UInt, 0)
IfWinExist, lang053
{
WinGetPos, xxxx, yyyy ; Использует окно, найденное выше.
}
IniWrite, %xxxx%, Position.ini, xdirectory, xxxx
IniWrite, %yyyy%, Position.ini, ydirectory, yyyy
sleep, 60
Exitapp
С флагами готовый скрипт здесь.