HomeTaskerTasker PC control - #Tutorial1 (Power Menu)

Tasker PC control – #Tutorial1 (Power Menu)

Control PC like a pro

I rewrote the profile several times, therefore I’m slightly afraid that this tutorial is directed at more experienced Tasker users. If you want to know what it does – please watch the demo on YouTube. In short. this is a permanent notification that allows you to add buttons and actions to do stuff on your PC. The tutorial will come in 4 parts and this is part 1, in which we will mostly focus on the framework. Please also bear in mind, that I will be updating these write-ups, as I still play with this project, adding more functions or simplifying things. This is the longest and the most important part of this tutorial. The following tutorials will build on this, and will be much, much shorter. Oh and for you guys who wonder why not to use Unified Remote? It’s a Tasker blog and I don’t think you would get impressed by that, plus the framework below can be used for anything, from controling the lights to toggling your Tasker profiles.

Tasker PC control – tutorial

The project consists of two parts. One is things you have to do on the PC, and another tells you how to use Tasker to achieve this. The general idea is to create a loop that will send information to the PC, and receive the confirmation from the PC once the action has been performed.  To do this, I will get the EventGhost to ping the information back and forth using the AutoRemote plugin.  If you want to learn more about AutoRemote use this guide.

EventGhost

Let’s start with an EventGhost. If you never used it before, you can think of it as some sort of Tasker/macro tool for PC. It’s far from perfect but you can get it to work with Tasker. If you never connected this to the Tasker here is few things that you need to know. You can download it here, Don’t be put off but bare looking interface. This can be a very powerful program with a lot of other integrations.  You will need to add the AutoRemote plugin to make it work and register the devices you own in the EventGhost as well. You can see the instructions here.  You will have to add the device you want to connect to in the plugin settings and then you are ready to send and receive information via AutoRemote.

Power Menu

The first menu in my project is the power menu. There are 4 main actions assigned to that menu: sleep, lock, restart, and power off. This means that we have to tell EventGhost to perform these for actions. Each one of them is available in the system menu of the EventGhost actions. There will be an additional task performed on the boot. This gives us 5 actions as follows:

You will notice that each action contains few triggers and a message that is issued back to the Tasker. While the messages can contain your own commands, there is some consistency to keep here. The message sent back to the Tasker is always in this format pc=:=yourmessage.  This is important and profiles in tasker will rely on the prefixes to decrease the number of tasks needed. The same goes for the messages sent to the EventGhost. Each message ends with ‘pc’. Ie:  turnoffpc, sleeppc. This rule will apply to every single command issued via AutoRemote.

Each macro also has additional triggers and will try to capture the events (lock, sleep, restart, power off) triggered by the system. To give a chance for the EventGhost to send the message – an additional wait of 6 seconds is imposed.

Boot Task

An extra task is run at boot. It sends a message to our phone with a 10 sec delay. Once the EG is loaded, it waits 10 sec and issues the notification that computer is online. I have added the additional triggers to capture resume from sleep, lock and restart. This picture should cover everything you need set in EventGhost. Make sure that AutoRemote plugin is loaded and configured correctly.

Tasker

I used icons from the Material Design Icon app and I can’t wait for Tasker to incorporate this in the new version. Feel free to experiment but if you are using AutoNotification Buttons, you will only need the icons in a single color. You can change the color using a tint option in the plugin. I understand that not all options are available on every Android version, so be creative if you are using Android 5.0. The notification created by AutoNotification is persistent and updated each time an action is performed.

The Tasker PC control project has 5 profiles. You will need all of them to get a single button working. In exchange, adding more actions won’t add more tasks and profiles as long as you stick to the same formula. This means that the project is fairly lightweight.

  1. Buttonone Actions
  2. Buttontwo Actions
  3. Open Sub Menu
  4. Submenu Actions
  5. PC Feedback

Profile 1 and 2

These two profiles handle the AutoNotifications commands issued by buttons located in row one (buttonone) and row two (buttontwo).

Open Sub-Menu

This profile opens the correct submenu for each button in row one. The command is issued by the AutoNotification as well

Sub-Menu Actions

A very simple profile that sends the selected action via AutoRemote to your target.

PC Feedback

A profile that updates the notification based on the information received from the PC.

The Power Menu

I hope that all is understandable by now. We about to start the actual work here. The power menu has several functions. When a PC is offline, sleeps or locked the menu will show you correct status. If AutoRemote had the chance to send in the message (more on that later). In addition to that, the Sleep and Online icons have text that tells you when the computer went to sleep, or online. Not sure if this is any use to you. You can wake up your PC from the sleep option, or perform the sleep, lock, restart and turn off actions.  Limitations:

  • Turn Off – it is not possible to wake the device again (no remedy to this one)
  • Lock – it is not possible to log back through the icon, you can, however, do this via Remote Desktop (for now)
  • Wake on LAN –  requires LAN connection most of the time (some WIFI cards support it) if you not hooked up to LAN – check this article out

To create the notification I’m using the AutoNotification Button action. The notification is permanent, therefore an ID has to be assigned to it. I strongly suggest to create the notification that will consist the following:

  • Buttons – create 2 rows of buttons, 4 columns each – see the column setting, the buttons won’t show up until actions are assigned. Assign all 8 buttons.
  • Actions – assign all 8 actions, upper row starts with ‘open…’ bottom row ends with ‘…pc’ in each action.
  • Colors – set color for each button, copy and paste the same color, it will be easier to change it later

Keep this notification as a template and copy and paste it in various tasks, it will save you some time. Here is also a visual representation of how the notification is constructed.

WHITE: AN action prefix ORANGE: AN action

Tier 1 Buttons Task

The default notification contains 4 icons (submenus are closed), this should be the first notification to be created. Arrange all 4 icons, and assign actions: openpower, openvolume,openbookmark,openscreen (the open… part is important one). Lastly, assign the prefix as buttonone. When a button is pressed, the action will be triggered. Once this is complete, create an Event AutoNotification. This will be the Open Sub-Menu profile.

Open Sub-Menu Profile/Submenu task

The open submenu will respond to regex (open.*) and in advanced settings set a Comm Params Prefix as buttonone, as the command is issued by the button from row one. In the task linked to this profile, paste the notification template, and assign IF condition. This notification should only open when %ancomm ~ openpower.

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 power menu icon should have openclose action assign instead. The second row has actions ending with ‘‘…pc
  • Color, only first color should be different.
  • Prefix for actions: buttontwo

This will assure that, if power icon is pressed again – the default notification will return. If other buttons from row one are pressed, the corresponding menus will open (in later tutorials) and if an icon from row two is pressed, an Autoremote command will be issued.

Profile Description
Profile: Open Sub Menu
	Event: AutoNotification [ Configuration:Event Behaviour
	Filter: open*. (regex) ]
Enter: Submenu Open
	
	A1: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png,/storage/emulated/0/Tasker/Material Icons/green/ic_sleep.png,/storage/emulated/0/Tasker/Material Icons/green/ic_key.png,/storage/emulated/0/Tasker/Material Icons/green/ic_reload.png,/storage/emulated/0/Tasker/Material Icons/green/ic_power.png
		Actions: openclose,openvolume,openbookmark,openscreen,sleeppc,lockpc,rebootpc,turnoffpc
		Action Prefix: buttontwo
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Align: Center
		Column Count: 4,4
		Button Size: 50
		Button Tint: #F7FFB74D,#FFFFFFFF,#FFFFFFFF,#FFFFFFFF,#FFFFFFFF,#FFFFFFFF,#FFFFFFFF,#FFFFFFFF
		Button Padding: 10
		Enabled: 1,1,1,1,1,1,1,1
		Background Color: #212121 Timeout (Seconds):20 ] If [ %ancomm ~ openpower ]

Sub-Menu Actions Profile/ Send AR task

Create a new Event AutoNotification, and set the trigger to regex (.*pc), set a Comm Params Prefix as buttontwo. This will respond only to the commands send by the row two of your notification. Link this to Send AR task which will contain a STOP action IF %ancomm ~ close. (prevents closing action from issuing a AR message). Add an AutoRemote Message action. And send the %ancomm as the message.

Add another template Notification and link it to IF condition (does not match RegEx lockpc|sleeppc|rebootpc|turnoffpc ) These commands have custom notifications.

Notification is configured as follows:

  • Buttons – only 4 main buttons, this is your default notification
  • Actions: the first row starts with open (see template)
  • Color, each one should have the same color. As this message is displayed when your PC is online, feel free to color the Power menu one.
  • Prefix for actions: buttonone
Profile Description
Profile: Submenu Actions 
	Event: AutoNotification [ Configuration:Event Behaviour
	Filter: pc (regex) ]
Enter: Send AR 
	A1: [X] Stop [ With Error:Off Task: ] If [ %ancomm !Set | %ancomm ~ close ]
	A2: AutoRemote Message [ Configuration:Recipient: HomeGhost
		Message: %ancomm Timeout (Seconds):200 ] 
	A3: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png
		Actions: openpower,openvolume,openbookmark,openscreen
		Action Prefix: buttonone
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FF43A047,#FFFFFFFF
		Button Padding: 1
		Enabled: 1,1,1,1
		Background Color: #212121
		Texts: %PcPowerontime,%PcVolume,,%PcScreen
		Text Color: #FFFFFFFF
		Text Size: 12 Timeout (Seconds):20 ] If [ %ancomm !~R lockpc|sleeppc|rebootpc|turnoffpc ]

PC- Feedback Profile/Notification task

I’m using an AutoRemote Event that accepts any message. In advanced, the Comm Params Prefix is set to pc, so it would interact with messages sent from the previously configured EventGhost profiles. The task contains several actions that will be triggered based on the message received. Set a variable %PcPowerontime to %TIME, and apply IF %arcomm ~ online. This will tell you when the PC logged on online. Then we will create 5 notification states based on what message has been sent by computer:

IF %arcomm ~ online

Notification is configured as follows:

  • Buttons – only 4 main buttons, this is your default notification
  • Actions: the first row starts with open (see template)
  • Color, each one should have the same color. As this message is displayed when your PC is online, feel free to color the Power menu one.
  • Prefix for actions: buttonone
  • Add the text label in the 1st position  – use %PcPowerontime (you will need this in each default step – so check the Send AR task and tier 1 buttons task apply this as well)

IF %arcomm ~ turnoff

Notification is configured as follows:

  • Buttons – only one button, to show pc offline
  • Actions: you have to assign one to make the button visible, so make up a fake one
  • Color, red is good
  • Prefix for actions: n/a

IF %arcomm ~ sleep

Notification is configured as follows:

  • Buttons – only one button
  • Actions: openwakeup
  • Color – anything you like
  • Prefix for actions: buttonone
  • Assign the %artime – this will provide you with exact time of the computer going to sleep

IF %arcomm ~ reboot

Notification is configured as follows:

  • Buttons – only one button
  • Actions: you have to assign one to make the button visible, so make up a fake one
  • Color, yellow is good
  • Prefix for actions: n/a
  • You can create label if you want letting you know how long it takes

IF %arcomm ~ lock

Notification is configured as follows:

  • Buttons – only one button
  • Actions: you have to assign one to make the button visible, so make up a fake one
  • Color, yellow is also good
  • Prefix for actions: n/a
  • Create the label if you want
Profile Description
Profile: Pc Feedback
	Event: AutoRemote [ Configuration:All Messages ]
	Enter: Notification 
	A1: Variable Set [ Name:%PcPowerontime To:%TIME Recurse Variables:Off Do Maths:Off Append:Off ] If [ %arcomm ~ online ]
	
	A2: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png
		Actions: openpower,openvolume,openbookmark,openscreen
		Action Prefix: buttonone
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FF43A047,#FFFFFFFF
		Button Padding: 1
		Enabled: 1,1,1,1
		Background Color: #212121
		Texts: %PcPowerontime,%PcVolume,,%PcScreen
		Text Color: #FFFFFFFF
		Text Size: 12 Timeout (Seconds):20 ] If [ %arcomm ~ online ]
		
	A3: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png
		Actions: action
		Action Prefix: buttonone,
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FFE53935
		Button Padding: 1
		Enabled: 1,0,0,0
		Background Color: #212121
		Texts: Offline
		Text Color: #FFF44336
		Text Size: 14 Timeout (Seconds):20 ] If [ %arcomm ~ turnoff ]
	
	A4: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png
		Actions: openwakeup
		Action Prefix: buttonone,
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FFE53935
		Button Padding: 1
		Enabled: 1,0,0,0
		Background Color: #212121
		Texts: %artime
		Text Color: #FFF44336
		Text Size: 14 Timeout (Seconds):20 ] If [ %arcomm ~ sleep ]
	
	A5: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_reload.png
		Actions: restarting
		Action Prefix: buttonone,
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FFF9A825
		Button Padding: 1
		Enabled: 1,0,0,0
		Background Color: #212121
		Texts: restarting
		Text Color: #FFF9A825
		Text Size: 14 Timeout (Seconds):20 ] If [ %arcomm ~ reboot ]
	
	A6: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_key.png
		Actions: locked
		Action Prefix: buttontwo
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Align: Center
		Column Count: 4,4
		Button Size: 50
		Button Tint: #FFF9A825
		Button Padding: 10
		Enabled: 1,1,1,1,1,1,1,1
		Background Color: #212121
		Texts: locked
		Text Color: #FFF9A825
		Text Size: 14 Timeout (Seconds):20 ] If [ %arcomm ~ lock ]

Buttonone Actions Profile/Tier 1 Buttons task

Create a profile with the AutoNotification Event. The message filter is set to regex (open*.) and the prefix in advanced settings is set to buttonone. This will link to the task we have created at the beginning of this tutorial. The task has to be modified as well. The first action will be a configured plugin Wake on LAN which will launch  IF %arcomm ~R wakeup. Also Joao fome the AutoApps mentioned that beta of the AutoTools does the WOL too. So there you have it! The second action will simply close the notification’s sub-menu and restore the default view.

Notification is configured as follows IF :%arcomm ~R close:

  • Buttons – only 4 main buttons, this is your default notification
  • Actions: all start with ”open…”
  • Color, each one should have the same color. As this message is displayed when your PC is online, feel free to color the Power menu one.
  • Prefix for actions: buttonone
  • Text %PcPowerontime
Profile Description
Profile: Buttonone Actions
	Event: AutoNotification [ Configuration:Event Behaviour
	Filter: open*. (regex) ] Prefix: buttonone
Enter: Tier 1 Buttons 
	A1: Wake Device [ Configuration:Device|1|PAJOPC Timeout (Seconds):0 ] If [ %ancomm ~R wakeup ]
	A2: AutoNotification Buttons Notification [ Configuration:Id: default
		Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png
		Actions: openpower,openvolume,openbookmark,openscreen
		Action Prefix: buttonone
		Status Bar Icon: hardware_dock
		Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png
		Status Bar Text Size: 16
		Priority: 2
		Persistent: true
		Vibration: 0,421,385,64,86,40
		Align: Center
		Column Count: 4,4
		Button Size: 80
		Button Tint: #FF43A047,#FFFFFFFF
		Button Padding: 1
		Enabled: 1,1,1,1
		Background Color: #212121
		Texts: %PcPowerontime,%PcVolume,,%PcScreen
		Text Color: #FFFFFFFF
		Text Size: 12 Timeout (Seconds):20 ] If [ %ancomm ~R close ]

Buttontwo Actions Profile/Tier 1 buttons

This profile links to, the same as above, task. The only difference is the prefix in the AutoNotification Event which is butttontwo. It responds to the clicks from submenu and opens different sections.

Profile Description
Profile: Buttontwo Actions
	Event: AutoNotification [ Configuration:Event Behaviour
	Filter: open*. (regex) ]Prefix: buttontwo
Enter: Tier 1 Buttons A1: Wake Device [ Configuration:Device|1|PAJOPC Timeout (Seconds):0 ] If [ %ancomm ~R wakeup ] A2: AutoNotification Buttons Notification [ Configuration:Id: default Images: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png,/storage/emulated/0/Tasker/Material Icons/green/ic_volume_medium.png,/storage/emulated/0/Tasker/Material Icons/green/ic_book_variant.png,/storage/emulated/0/Tasker/Material Icons/green/ic_desktop_mac.png Actions: openpower,openvolume,openbookmark,openscreen Action Prefix: buttonone Status Bar Icon: hardware_dock Status Bar Icon Manual: /storage/emulated/0/Tasker/Material Icons/green/ic_power_settings.png Status Bar Text Size: 16 Priority: 2 Persistent: true Vibration: 0,421,385,64,86,40 Align: Center Column Count: 4,4 Button Size: 80 Button Tint: #FF43A047,#FFFFFFFF Button Padding: 1 Enabled: 1,1,1,1 Background Color: #212121 Texts: %PcPowerontime,%PcVolume,,%PcScreen Text Color: #FFFFFFFF Text Size: 12 Timeout (Seconds):20 ] If [ %ancomm ~R close ]

Continues…

This is the end of Part 1. Click here for part 2. Most of the things covered here should work on its own. We have some more work to be done in part 2,3 and 4. The good news is, these parts will be much shorter. This is the entire framework. Thanks for being patient. Subscribe to the email, YouTube channel, and social media. It helps me grow and in return, I can keep helping you.

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)?