Автор: tavria2
Дата сообщения: 27.05.2010 15:30
lorents
Для твоего случая:
Код: sFileName = _SourceFolder.."\\AutoPlay\\Docs\\Setup.exe";
ID = File.GetAttributes(sFileName).WriteDateISO; -- создаем идентификатор приложения
instances_of_file = 0;
file_to_check_for = "setup.exe";
processes = Window.EnumerateProcesses();
for j, file_path in pairs(processes) do
file = String.SplitPath(file_path);
if (String.Lower(file.Filename..file.Extension) == file_to_check_for) and (File.GetAttributes(file_path).WriteDateISO == ID) then
instances_of_file = instances_of_file + 1;
hWnd = j;
break;
end
end
if instances_of_file > 0 then
local IsVisible = tonumber(DLL.CallFunction("user32.dll", "IsWindowVisible", hWnd, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
if IsVisible == 0 then
DLL.CallFunction("user32.dll", "SetParent", hWnd..",0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
DLL.CallFunction("user32.dll", "OpenIcon", hWnd, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
end
local isMinimize = tonumber(DLL.CallFunction("user32.dll", "IsIconic", hWnd, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
if isMinimize ~= 0 then -- если окно свернуто на панели задач
DLL.CallFunction("user32.dll", "ShowWindow", hWnd..",9", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
end
DLL.CallFunction("user32.dll", "SetForegroundWindow", hWnd, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
else
File.Run(sFileName, "", "", SW_SHOWNORMAL, false);
end
Window.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE);