You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何追踪.exe文件运行时长及Unity关联工作时间统计方案问询

Hey there, let's tackle your two questions one by one with practical, actionable solutions:

如何追踪某些.exe文件的持续运行时长?

Here are reliable methods covering native tools, scripts, and lightweight third-party options:

  • PowerShell Script Monitoring
    You can write a simple script to track when the target .exe starts and stops, then calculate total runtime. Replace Target.exe with your program name:

    $processName = "Target.exe"
    $startTime = $null
    
    while ($true) {
        $process = Get-Process -Name $processName -ErrorAction SilentlyContinue
        if ($process -and !$startTime) {
            $startTime = Get-Date
            Write-Host "$processName started at $startTime"
        } elseif (!$process -and $startTime) {
            $endTime = Get-Date
            $duration = $endTime - $startTime
            Write-Host "$processName stopped. Total runtime: $($duration.Hours)h $($duration.Minutes)m $($duration.Seconds)s"
            $startTime = $null
        }
        Start-Sleep -Seconds 5
    }
    

    Run it in PowerShell, and it will automatically log the total runtime once the process exits.

  • Windows Event Viewer
    Windows' built-in event logs track process creation and termination. Open Event Viewer → navigate to Windows Logs > Security, then filter for event IDs 4688 (process creation) and 4689 (process exit). Add a filter for your target .exe name, find matching start/stop events, and calculate the time difference between them.

  • Lightweight Third-Party Tools

    • Process Monitor (Sysinternals) : Set a filter for Process Name is Target.exe, then track "Process Start" and "Process Exit" events. Export the log to calculate total runtime.
    • TimeSnapper : A tool that tracks process runtime and takes periodic screenshots. You can directly view cumulative runtime for your target .exe in its process list.
统计Unity相关总工作时长(含Chrome关联操作)的解决方案

I get your frustration—standard tools only count active window time, leaving out research time that's still part of your Unity workflow. Here's how to fix this:

  • Customize ManicTime Activity Groups
    ManicTime lets you group related activities, so you can merge Unity and Chrome's Unity-focused windows into one tracked category:

    1. Open ManicTime and go to the Activities tab.
    2. Click New Group and name it "Unity Work".
    3. Add two rules to the group:
      • Rule 1: Process is Unity.exe (matches the Unity editor)
      • Rule 2: Window title contains Unity (matches Chrome tabs with Unity in the title, like search results for "Unity character movement")
    4. Now ManicTime will automatically combine time spent in Unity and relevant Chrome tabs under the "Unity Work" group.
  • AutoHotkey Script for Automated Tracking
    For full customization, use AutoHotkey to build a script that tracks time when Unity is running and you're on Unity-related Chrome pages:

    global isUnityRunning := false
    global totalWorkTime := 0
    global activeStartTime := 0
    
    Loop {
        ; Check if Unity is running
        Process, Exist, Unity.exe
        if (ErrorLevel) {
            isUnityRunning := true
            WinGetTitle, activeTitle, A
            ; Track time if on Unity or Unity-related Chrome tab
            if (activeTitle contains "Unity" || activeTitle contains "unity") {
                if (activeStartTime = 0) {
                    activeStartTime := A_TickCount
                }
            } else {
                ; Stop and accumulate time when switching away
                if (activeStartTime != 0) {
                    totalWorkTime += A_TickCount - activeStartTime
                    activeStartTime := 0
                }
            }
        } else {
            ; Show total time when Unity closes
            if (isUnityRunning) {
                if (activeStartTime != 0) {
                    totalWorkTime += A_TickCount - activeStartTime
                    activeStartTime := 0
                }
                totalMinutes := Round(totalWorkTime / 1000 / 60, 2)
                MsgBox, Total Unity work time (including Chrome research): %totalMinutes% minutes
                ; Reset for next session
                totalWorkTime := 0
                isUnityRunning := false
            }
        }
        Sleep, 1000
    }
    

    Run this script, and it will automatically track eligible time while Unity is open, then show the total when you close Unity.

  • RescueTime Custom Categories
    RescueTime lets you categorize activities by process and website. Create a "Unity Development" category and add rules for:

    • The Unity.exe process
    • Unity-related websites like *.unity.com, stackoverflow.com/tagged/unity3d, and forum.unity.com
      It will then merge all these activities into one total for your Unity workflow.

内容的提问来源于stack exchange,提问作者serdar efe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:43:40