HomeTaskerTasker PC control – #Tutorial 4 (Screen and lights menu)

Tasker PC control – #Tutorial 4 (Screen and lights menu)

Control PC screen and other actions. Last part of the series.

This is the last part of this series. Please make sure you have seen at least part one. Part two and three are similar and worth checking too!

This sub-menu will control the screen timeout on a PC. I have added it, as I want to have an easy control over the timeout when I’m using a remote desktop. At the end of the tutorial, I will also show you how to set up other actions. The profile files are available at the end of this part.

EventGhost

The set up is very similar to the volume menu. An AutoRemote action is issued, the EventGhost changes the screen timeout options then reports back. Repeat this for each timeout option you want to have. For the sake of the consistency, I have four.

You know how to set up a trigger and issue the response already so here is the screen action:

powercfg -Change -monitor-timeout-ac 5

Use Windows Command option in EventGhost actions. Change the value to any number you wish.

Tasker

Open Sub-Menu Profile/ SubMenu Open

Create a new notification and link it to the IF %ancomm ~ openscreen If the screen icon from the first row is pressed  – this action will be called.

Notification is configured as follows:

  • Buttons – as per your liking, make sure the first row is consistent.
  • Actions: the first row starts with open (see template) but the screen menu icon should have openclose action assigned instead. The second row has actions ending with ‘‘…pc”. I used screen1pc,screen5pc,screen30pc,screen120pc.
  • Color, only a second color should be different.
  • Prefix for actions: buttontwo

Submenu Actions/Send AR

Since the framework is already done, we don’t need to add anything else. All that hard work from the part one finally paid off.

PC Feedback/Notification

The EventGhost will issue a reply when the screen timeout is changed through our screen menu. The to simplify the process (you can go nuts) the AutoRemote message is sent in this form pc=:=screen(value). This means that we have to intercept all the messages starting with (regex)screen.*

In a similar way to power menu, I’m creating a variable %PcScreen and simply setting the value of it to the %arcomm. The value will get assigned to the default notification. At this stage go and update the default notifications (the ones that have only 4 icons) with this variable. Each notification should have %PcPowerontime,%PcVolume and %PcScreen in the text field.

And that was all!

Bonus:

Lights Menu

Open Sub-Menu Profile/ SubMenu Open

Create a new notification and link it to the IF %ancomm ~ openlight If the lights icon from the first row is pressed  – this action will be called. (update the default notification and change the column count to 5 (see part one)
You will  have to change the following in each notification created so far:

  • Column count (5:4) to reflect number of your menus
  • Actions – add new action everywhere (one for menu, one for submenu)
  • Enabled: 1,1,1,1,1 (equal to number of icons)

Notification is configured as follows:

  • Buttons – as per your liking, make sure the first row is consistent.
  • Actions: the first row starts with open (see template) but the lights menu icon should have openclose action assigned instead. The second row has actions ending with ‘‘…tsk”. I used lighttsk as I only have one smart light.
  • Color, only a second color should be different.
  • Prefix for actions: buttontwo

Submenu Actions/Send AR

Our profile can intercept only actions ending with …pc, therefore we have to modify it. The profile context will respond to regex pc|tsk and the task will contain IF statement when sending the previously made AR action: IF %ancomm =R pc.

Add another action – Perform Task and create condition IC %ancomm =R tsk. The action to perform is %ancomm. It’s easier to rename a task to fit the bill than create a name matching profile.

Light tsk

I only control one light at this time. The controller is simplistic as I made the WIFI module myself and I’m currently working on it. Here is how you create a toggle switch.

Create the variable %lightStatus and set it to 0. I’m using the HTTP Get request to turn on/off the light. When the %lightStatus = 0 the light is off and when it’s 1 the light is on. Create the IF condition that checks the value of the variable, updates the value respectively, and sets the correct action then stops:

Profile Description
lighttsk (26)
	A1: If [ %lightState ~ 0 ]
	A2: HTTP Get [ Server:Port:192.168.1.163/?pin=ON1 Path: Attributes: Cookies: User Agent:
            Timeout:10 Mime Type: Output File: Trust Any Certificate:Off Continue Task After Error:On ] 
	A3: Variable Set [ Name:%lightState To:1 Recurse Variables:Off Do Maths:Off Append:Off ] 
	A4: Stop [ With Error:Off Task: ] 
	A5: Else 
	A6: HTTP Get [ Server:Port:192.168.1.163/?pin=OFF1 Path: Attributes: Cookies: User Agent:
            Timeout:10 Mime Type: Output File: Trust Any Certificate:Off Continue Task After Error:On ] 
	A7: Variable Set [ Name:%lightState To:0 Recurse Variables:Off Do Maths:Off Append:Off ] 

For any other setups simply run the task that is named in the same way as the %anconn message issued by the sub-menu. If you need more than one menu, rinse and repeat the steps.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?