Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions localization/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "&Fenster"
Help = "&Hilfe"
UpdateSpeed = "&Aktualisierungsgeschwindigkeit"
CpuHistory = "&CPU-Verlauf"
NewTaskMenu = "&Ausführen..."
NewTaskButton = "&Ausführen..."
NewTaskMenu = "Neue &Aufgabe..."
NewTaskButton = "Neue &Aufgabe..."
NewTaskTitle = "Neue Aufgabe erstellen"
NewTaskAdmin = "Diese Aufgabe mit Administratorrechten erstellen"
NewTaskBrowse = "&Durchsuchen..."
NewTaskProgramFilter = "Programme"
NewTaskAllFilesFilter = "Alle Dateien"
NewTaskFailed = "Diese Aufgabe konnte nicht erstellt werden."
NewTaskEmpty = "Geben Sie den Namen eines Programms, Ordners, Dokuments oder einer Internetressource ein."
ExitTaskManager = "Task-Manager be&enden"
AlwaysOnTop = "&Immer im Vordergrund"
MinimizeOnUse = "Nach Verwendung &minimieren"
Expand Down Expand Up @@ -322,7 +329,7 @@ ServiceStateUnchanged = "Der Dienst hat den angeforderten Zustand nicht erreicht
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Öffnet das Dialogfeld „Neue Aufgabe“, um ein Programm auszuführen"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/en_us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ Windows = "&Windows"
Help = "&Help"
UpdateSpeed = "&Update Speed"
CpuHistory = "&CPU History"
NewTaskMenu = "&Run..."
NewTaskButton = "&Run..."
NewTaskMenu = "New &Task..."
NewTaskButton = "New &Task..."
NewTaskTitle = "Create New Task"
NewTaskAdmin = "Create this task with administrative privileges"
NewTaskBrowse = "&Browse..."
NewTaskProgramFilter = "Programs"
NewTaskAllFilesFilter = "All Files"
NewTaskFailed = "Unable to create this task."
NewTaskEmpty = "Type the name of a program, folder, document, or Internet resource."
ExitTaskManager = "E&xit Task Manager"
AlwaysOnTop = "&Always On Top"
MinimizeOnUse = "&Minimize On Use"
Expand Down Expand Up @@ -329,7 +336,7 @@ ServiceStateUnchanged = "The service did not enter the requested state."
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Opens the New Task dialog to run a program"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "&Ventanas"
Help = "Ay&uda"
UpdateSpeed = "&Velocidad de actualización"
CpuHistory = "&Historial de CPU"
NewTaskMenu = "&Ejecutar..."
NewTaskButton = "&Ejecutar..."
NewTaskMenu = "Nueva &tarea..."
NewTaskButton = "Nueva &tarea..."
NewTaskTitle = "Crear nueva tarea"
NewTaskAdmin = "Crear esta tarea con privilegios administrativos"
NewTaskBrowse = "&Examinar..."
NewTaskProgramFilter = "Programas"
NewTaskAllFilesFilter = "Todos los archivos"
NewTaskFailed = "No se puede crear esta tarea."
NewTaskEmpty = "Escriba el nombre de un programa, carpeta, documento o recurso de Internet."
ExitTaskManager = "&Salir del Administrador de tareas"
AlwaysOnTop = "&Siempre visible"
MinimizeOnUse = "&Minimizar al usar"
Expand Down Expand Up @@ -322,7 +329,7 @@ ServiceStateUnchanged = "El servicio no entró en el estado solicitado."
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Abre el cuadro de diálogo Nueva tarea para ejecutar un programa"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "&Fenêtres"
Help = "&Aide"
UpdateSpeed = "&Vitesse de mise à jour"
CpuHistory = "&Historique CPU"
NewTaskMenu = "&Exécuter..."
NewTaskButton = "&Exécuter..."
NewTaskMenu = "Nouvelle &tâche..."
NewTaskButton = "Nouvelle &tâche..."
NewTaskTitle = "Créer une nouvelle tâche"
NewTaskAdmin = "Créer cette tâche avec des privilèges d'administration"
NewTaskBrowse = "&Parcourir..."
NewTaskProgramFilter = "Programmes"
NewTaskAllFilesFilter = "Tous les fichiers"
NewTaskFailed = "Impossible de créer cette tâche."
NewTaskEmpty = "Tapez le nom d’un programme, d’un dossier, d’un document ou d’une ressource Internet."
ExitTaskManager = "&Quitter le Gestionnaire des tâches"
AlwaysOnTop = "&Toujours visible"
MinimizeOnUse = "&Réduire après utilisation"
Expand Down Expand Up @@ -322,7 +329,7 @@ ServiceStateUnchanged = "Le service n'a pas atteint l'état demandé."
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Ouvre la boîte de dialogue Nouvelle tâche pour exécuter un programme"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/pt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "&Janelas"
Help = "A&juda"
UpdateSpeed = "&Velocidade de atualização"
CpuHistory = "&Histórico da CPU"
NewTaskMenu = "&Executar..."
NewTaskButton = "&Executar..."
NewTaskMenu = "Nova &tarefa..."
NewTaskButton = "Nova &tarefa..."
NewTaskTitle = "Criar nova tarefa"
NewTaskAdmin = "Criar esta tarefa com privilégios administrativos"
NewTaskBrowse = "&Procurar..."
NewTaskProgramFilter = "Programas"
NewTaskAllFilesFilter = "Todos os arquivos"
NewTaskFailed = "Não foi possível criar esta tarefa."
NewTaskEmpty = "Digite o nome de um programa, pasta, documento ou recurso da Internet."
ExitTaskManager = "Sai&r do Gerenciador de Tarefas"
AlwaysOnTop = "&Sempre visível"
MinimizeOnUse = "&Minimizar ao usar"
Expand Down Expand Up @@ -322,7 +329,7 @@ ServiceStateUnchanged = "O serviço não entrou no estado solicitado."
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Abre a caixa de diálogo Nova tarefa para executar um programa"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "&Окна"
Help = "&Справка"
UpdateSpeed = "&Скорость обновления"
CpuHistory = "&Журнал CPU"
NewTaskMenu = "&Выполнить..."
NewTaskButton = "&Выполнить..."
NewTaskMenu = "Новая &задача..."
NewTaskButton = "Новая &задача..."
NewTaskTitle = "Создать задачу"
NewTaskAdmin = "Создать эту задачу с правами администратора"
NewTaskBrowse = "&Обзор..."
NewTaskProgramFilter = "Программы"
NewTaskAllFilesFilter = "Все файлы"
NewTaskFailed = "Не удалось создать задачу."
NewTaskEmpty = "Введите имя программы, папки, документа или интернет-ресурса."
ExitTaskManager = "&Выход из диспетчера задач"
AlwaysOnTop = "&Поверх всех окон"
MinimizeOnUse = "&Сворачивать после использования"
Expand Down Expand Up @@ -322,7 +329,7 @@ ServiceStateUnchanged = "Служба не перешла в запрошенн
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "Открывает диалог «Новая задача» для запуска программы"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/zh_cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "窗口(&W)"
Help = "帮助(&H)"
UpdateSpeed = "更新速度(&U)"
CpuHistory = "CPU 历史记录(&C)"
NewTaskMenu = "运行(&R)..."
NewTaskButton = "运行(&R)..."
NewTaskMenu = "新建任务(&T)..."
NewTaskButton = "新建任务(&T)..."
NewTaskTitle = "创建新任务"
NewTaskAdmin = "以管理权限创建此任务"
NewTaskBrowse = "浏览(&B)..."
NewTaskProgramFilter = "程序"
NewTaskAllFilesFilter = "所有文件"
NewTaskFailed = "无法创建此任务。"
NewTaskEmpty = "请输入程序、文件夹、文档或 Internet 资源的名称。"
ExitTaskManager = "退出任务管理器(&X)"
AlwaysOnTop = "总在最前(&A)"
MinimizeOnUse = "使用后最小化(&M)"
Expand Down Expand Up @@ -319,7 +326,7 @@ ServiceStateUnchanged = "该服务没有进入请求的状态。"
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "打开“新建任务”对话框以运行程序"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
13 changes: 10 additions & 3 deletions localization/zh_tw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ Windows = "視窗(&W)"
Help = "說明(&H)"
UpdateSpeed = "更新速度(&U)"
CpuHistory = "CPU 歷程記錄(&C)"
NewTaskMenu = "執行(&R)..."
NewTaskButton = "執行(&R)..."
NewTaskMenu = "新增工作(&T)..."
NewTaskButton = "新增工作(&T)..."
NewTaskTitle = "建立新工作"
NewTaskAdmin = "以系統管理權限建立此工作"
NewTaskBrowse = "瀏覽(&B)..."
NewTaskProgramFilter = "程式"
NewTaskAllFilesFilter = "所有檔案"
NewTaskFailed = "無法建立此工作。"
NewTaskEmpty = "請輸入程式、資料夾、文件或 Internet 資源的名稱。"
ExitTaskManager = "結束工作管理員(&X)"
AlwaysOnTop = "永遠在最上層(&A)"
MinimizeOnUse = "使用後最小化(&M)"
Expand Down Expand Up @@ -319,7 +326,7 @@ ServiceStateUnchanged = "服務沒有進入要求的狀態。"
ServiceProcessPid = "PID"

[menu_status_help]
IDM_RUN = "Runs a new program"
IDM_RUN = "開啟「新增工作」對話方塊以執行程式"
IDM_EXIT = "Exits the Task Manager application"
IDM_ALWAYSONTOP = "Task Manager remains in front of all other windows unless minimized"
IDM_MINIMIZEONUSE = "Task Manager is minimized when a SwitchTo operation is performed"
Expand Down
35 changes: 17 additions & 18 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

pub(crate) mod controllers;
mod diagnostics_dialog;
mod new_task;
pub(crate) mod page_host;
pub(crate) mod page_registry;
mod single_instance;
Expand All @@ -23,10 +24,7 @@ use std::mem::{size_of, zeroed};
use std::ptr::{NonNull, null, null_mut};
use std::sync::OnceLock;

use windows::Win32::System::Com::{
CLSCTX_ALL, COINIT_APARTMENTTHREADED, CoCreateInstance, CoInitializeEx, CoUninitialize,
};
use windows::Win32::UI::Shell::{IShellDispatch, Shell};
use windows::Win32::System::Com::{COINIT_APARTMENTTHREADED, CoInitializeEx, CoUninitialize};
use windows_sys::Win32::Foundation::{
CloseHandle, ERROR_ALREADY_EXISTS, ERROR_GEN_FAILURE, ERROR_INVALID_PARAMETER, ERROR_TIMEOUT,
GetLastError, HANDLE, HINSTANCE, HWND, LPARAM, POINT, RECT, SetLastError, TRUE, WAIT_TIMEOUT,
Expand Down Expand Up @@ -89,9 +87,9 @@ use crate::config::options::{Options, update_speed_timer_interval};
use crate::infrastructure::diagnostics::{self, Field, Level};
use crate::infrastructure::native::{
OwnedIcon, call_window_proc, enable_debug_privilege, format_resource_string, height, hiword,
loword, process_is_elevated, record_hresult_error, record_startup_timing, record_win32_error,
sanitize_task_manager_menu, set_dialog_msg_result, set_style, set_window_userdata_ptr,
to_wide_null, width, window_userdata_non_null,
loword, new_task_allowed, process_is_elevated, record_hresult_error, record_startup_timing,
record_win32_error, sanitize_task_manager_menu, set_dialog_msg_result, set_style,
set_window_userdata_ptr, to_wide_null, width, window_userdata_non_null,
};
use crate::system::cpu_topology::CpuTopologyError;
use crate::system::process_identity::{ProcIdentity, find_proc_identity};
Expand Down Expand Up @@ -1131,6 +1129,8 @@ impl App {
}

sanitize_task_manager_menu(menu, self.stats.processor_count);
// New Task stays enabled on every page unless the shell Run policy removed the item.
self.enable_menu_item(menu, IDM_RUN, true);

// 安全性: all calls mutate only the menu handle retrieved from this main window.
unsafe {
Expand Down Expand Up @@ -2053,14 +2053,6 @@ impl App {
}
}

fn show_run_dialog(&self) -> Result<(), i32> {
let _apartment = ComApartment::initialize()?;
let shell: IShellDispatch = unsafe { CoCreateInstance(&Shell, None, CLSCTX_ALL) }
.map_err(|error| error.code().0)?;
// IShellDispatch::FileRun is the documented Shell automation API for the system dialog.
unsafe { shell.FileRun() }.map_err(|error| error.code().0)
}

fn show_hresult_failure(&self, title: &str, error: i32) {
let title = to_wide_null(title);
let body = to_wide_null(&format!("HRESULT: 0x{:08X}", error as u32));
Expand Down Expand Up @@ -2308,9 +2300,16 @@ impl App {
}
}
IDM_RUN => {
if let Err(error) = self.show_run_dialog() {
record_hresult_error("system Run dialog", error);
self.show_hresult_failure(text(TextKey::RunTitle), error);
if !new_task_allowed() {
MessageBeep(0);
} else if let Err(error) = new_task::show(self.hinstance, hwnd) {
record_win32_error("new task dialog", error);
let title = to_wide_null(text(TextKey::NewTaskTitle));
let message = to_wide_null(&format!(
"{} ({error:#010X})",
text(TextKey::NewTaskFailed)
));
MessageBoxW(hwnd, message.as_ptr(), title.as_ptr(), MB_OK | MB_ICONSTOP);
}
}
IDM_HELP => {
Expand Down
Loading