PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Request: for "Awake" tool, offer to set the "--pid" argument to be set to the current process

Open AndroidDeveloperLB opened this issue 3 years ago • 7 comments

Description of the new feature / enhancement

For this: https://docs.microsoft.com/en-us/windows/powertoys/awake#command-line-interface-cli

I've noticed there is an option of attaching it to a process, that as long as the process is alive, let the "Awake" be enabled (and then stop). I want to set it to the current process.

Scenario when this would be used?

Supposed I create a batch file that I want to run and let it keep working fine (without having the OS to turn off anything of the PC and breaking the execution), I want to be able to tell "Awake" to be attached to this execution process.

Supporting information

No response

AndroidDeveloperLB avatar Apr 29 '22 08:04 AndroidDeveloperLB

I would love to have an option where I can configure a process like ffmpeg.exe and awake is enabled as long as the process is running

greuelpirat avatar Jun 19 '22 07:06 greuelpirat

I'd love to understand the use case better here. What do you mean by "current process"? The way I am thinking your current steps should be:

  1. Start whatever process you have in mind.
  2. Acquire PID.
  3. Pass PID to Awake.

Is that not the case?

dend avatar Feb 16 '23 23:02 dend

I guess he just means the parent process. so that the PID must not be looked up.

here is a .bat-file that should keep system awake for 10 seconds

start "c:\Program Files\PowerToys\modules\Awake\PowerToys.Awake.exe" --parent
timeout 10

greuelpirat avatar Feb 17 '23 15:02 greuelpirat

@AndroidDeveloperLB @greuelpirat heads-up that this is coming in the next release of Awake.

localden avatar Aug 21 '24 17:08 localden

Released in the latest PowerToys.

dend avatar Sep 04 '24 21:09 dend

@dend I just tried it, but I could not get it to work:

test.bat:

PowerToys.Awake.exe --use-parent-id
echo %ERRORLEVEL%
timeout /t 5 /nobreak

output:

C:\Temp>test.bat

C:\Temp>PowerToys.Awake.exe --use-parent-id

C:\Temp>echo 1
1

C:\Temp>timeout /t 5 /nobreak

there is no active Awake-Process during the 5 seconds. Do you have any suggestions? It would be great! Thank you!

(File version of PowerToys.Awake.exe is 0.84.0.0)

greuelpirat avatar Sep 08 '24 16:09 greuelpirat

@greuelpirat - the problem is you have a typo - it should be --use-parent-pid (pid is the keyword). That being said, if you just use the exe file launch like that, it will hold up the rest of the script. Here is what I use for testing:

start "" "DISK:\SOURCE_FOLDER\PowerToys\x64\Debug\PowerToys.Awake.exe" --use-parent-pid
if %ERRORLEVEL% neq 0 (
    echo Error occurred while running the program.
    echo %ERRORLEVEL%
) else (
    echo Program executed successfully.
)
timeout /t 5 /nobreak

dend avatar Sep 08 '24 19:09 dend

@dend you are right! I am sorry, it works now. Thank you very much! 😄

greuelpirat avatar Sep 09 '24 03:09 greuelpirat