0

I wanted to make a scheduled task which would automatically mute my computer. I found that running this on the command line worked to mute my computer:

python -c "from SendKeys import playkeys; playkeys([(0xAD, True), (0xAD, False)] * 50)"

That emulates the volume key being pressed and released 50 times over ~2 seconds.

So I went into Task Scheduler and created a task. It's set to run as me, whether I'm logged in or not. It has my password. I've set it to run both with and without highest privileges, that makes no difference. It is enabled. It's not hidden.

The Action is Start a program. Program/script is C:\Python27\python.exe (the same thing that plain python on the command line starts.) In the arguments box, I have this:

-c "from SendKeys import playkeys; playkeys([(0xAE, True), (0xAE, False)] * 50)"

Start in is blank.

When I click on "Run", it shows that the action takes a few seconds to run, which is correct and suggests it is doing something, but my volume doesn't end up going down like it should.

Any ideas for why it works just fine from the Command Prompt, but doesn't seem to work from Task Scheduler? Any ideas how I could modify this to work?

fixer1234
  • 28,064

1 Answers1

0

The task doesn't have access to your desktop, so there's no place for it to send the key-presses to.

Perhaps try using Nircmd instead.

For a more general approach to your actual problem (vs. trying to figure how to solve it with Python specifically) perhaps check out this other existing SU question: