Most of the users who come to our forums are on an Android device (though we do host a few forums dedicated to Windows 10 Mobile). However, the desktop operating system of choice among our users is split between Microsoft's Windows, Apple's macOS, and various Linux/GNU based distributions.
The available tools to integrate your phone with your PC differ widely based on your particular Android phone and desktop OS combination, but if you're using the most common Android phone + Windows setup, here's a tutorial to control your PC from your phone.
In short, we'll be creating a permanent notification on our phone that allows you to add buttons and actions to perform actions on your PC. The notification can be modified to add any number of menus and sub-menus to depending on how complex your needs are. The tutorial will come in 4 parts, but this is part 1 where we will mostly focus on the framework to make this work.
Now you might already be thinking "why not use Unified Remote?" That answer will become more and more clear as we go over this series, but if you're looking for more fine grained, customizable control of your PC through your Android device, this tutorial is for you.
This integration is done using Tasker and a plug-in known as AutoRemote end to create and send commands to our PC from a permanent notification created by AutoNotification. These commands are then interpreted and ran through an application on the PC known as EventGhost.
PC Control with Tasker + EventGhost
The project consists of two parts. One involves things you have to do on the PC, and another tells you how to use Tasker to achieve send commands. The general idea is to create a loop that will send information to the PC, and receive confirmation from the PC once the action has been performed. To do this, I will use the EventGhost to ping the information back and forth through the AutoRemote plugin. If you want to learn more about AutoRemote I recommend you read a guide I've written on this matter.
EventGhost
Let's start with EventGhost. If you never used it before, you can think of it as Tasker for Windows. It's far from perfect (especially from a UI standpoint), but once you understand how it works it can be a valuable addition to your Windows toolkit.
Best of all, with the AutoRemote plugin for EventGhost, you can get it working with the AutoRemote plugin for Tasker. This way, your Windows PC and your Android phone are able to communicate and send commands with one another.
You can download EventGhost here, Don't be put off but bare looking interface. Add the AutoRemote plugin and register the devices you own in the EventGhost as well. 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.
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 actions. Each one of them is available in the system menu of EventGhost actions. There will be an additional task performed on boot. This gives us a total of 5 actions.
You will notice that each action contains a few triggers and a message that is issued back to Tasker. While the messages can contain your own commands, you need to have a consistent format for them. The message sent back to Tasker is always in the format pc=:=yourmessage.
This is important as profiles in Tasker will rely on the prefixes to decrease the number of tasks needed to parse the command. The same goes for the messages sent to EventGhost. Each message ends with 'pc' eg. turnoffpc, sleeppc. This rule will apply to every single command issued via AutoRemote from your phone to EventGhost.
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 EventGhost to send a message, a wait time of 6 seconds is imposed.
Boot Task
An extra task is run at boot. It sends a message to our phone with a 10 second delay. Once EventGhost is loaded on the PC, it waits 10 seconds and then issues a notification that the computer is now online. I have added additional triggers to capture resume from sleep, lock, and restart. The screenshot from before should cover everything you need set in EventGhost. Make sure that the 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 with those icons or any from your icon pack of choice, 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.
- Buttonone Actions
- Buttontwo Actions
- Open Sub Menu
- Submenu Actions
- 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 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 are about to get to the actual meat of the setup here: the power menu. When a PC is offline, in sleep mode, or locked the menu will show you the correct status if AutoRemote had a chance to send 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 if its online. You can wake up your PC from the sleep option or perform the sleep, lock, restart, and turn off actions.
However, there are some 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 a LAN, you can try setting this up on a Raspberry Pi.
To create the notification itself 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 a 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, the upper row starts with 'open…' bottom row ends with '…pc' in each action.
- Colors – set a color for each button, copy and paste the same color, it will be easier to change it later.
Keep this notification as a template to copy and paste it in various tasks, it will save you some time.
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 prefix is important here). Lastly, assign the prefix as buttonone. When a button is pressed in the notification, the associated action will be triggered on your PC.
Once this is complete, create a new profile with an Event context using AutoNotification in Tasker. 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 an IF condition at the bottom. This notification should only open when %ancomm ~ openpower.
The 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 assigned instead. The second row has actions ending with ''…pc"
- Color – only the first color should be different.
- Prefix for actions – buttontwo
This will assure that if the 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.
Task 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) as well as set a Comm Params Prefix as buttontwo. This will respond only to the commands sent 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 an AR message). Add an AutoRemote Message action, and send the %ancomm as the message.
Add another template Notification and link it to the IF condition (does not match regex lockpc|sleeppc|rebootpc|turnoffpc ) These commands have custom notifications.
The 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
Task 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 is logged on. Then we will create 5 notification states based on what message has been sent by the 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 that the Send AR task and tier 1 buttons task apply to 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 a label if you want it to let you know how long it takes to reboot.
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
Task 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. 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
Task Description
Profile: Buttonone Actions Event: AutoNotification [ Configuration:Event Behaviour Filter: open*. (regex) ] 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 task as above. The only difference is the prefix in the AutoNotification Event which is butttontwo. It responds to the clicks from submenu and opens different sections.
Task Description
Profile: Buttontwo Actions Event: AutoNotification [ Configuration:Event Behaviour Filter: open*. (regex) ] 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 ]
This is the end of Part 1, settings up the button bar and showing you how to create some basic power menu buttons with it. Most of the things covered here should work on its own. We have some more work to be done for parts 2, 3, and 4, but we will show you how to have more advanced actions performed on your PC. The good news is, though, these subsequent parts will be much shorter as we have already done the legwork in setting things up here.
As always, I am providing a download link to the Tasker project file you can download and import. Download the below .prj.xml file and save it anywhere on your internal storage. Open Tasker and disable Beginner Mode in Preferences. Then, back at the main screen, long-press on the home icon in the bottom left corner. You should see a pop-up with an "import" option. Select that and look for the project file you just saved and select it to import. If successful, you should now see a new tab/icon at the bottom that contains all of the Profiles and Tasks that we mentioned in this article.
Download the PC Control Tasker Project from AndroidFileHostIn addition, you will need the Material Design Icons that I used in this project. Simply download the below zip file and unzip the folder to the root directory of your internal storage.
Download the Material Icons pack from AndroidFileHostFinally, here is the configuration file for EventGhost that you can import.
Download the EventGhost configuration filePlease note that I've removed my AutoRemote API key from the configuration file. You'll need to enter your own to make this work.
Thanks for being so patient, and I hope you found this tutorial useful.
from xda-developers http://ift.tt/2n2rlFs
via IFTTT
No comments:
Post a Comment