How to use Javascript and Robotjs package to auto set up your desktop ?

This article shows the method to set up your desktop using automation with the help of Robotjs package and JavaScript.The below steps have to be followed.
Step 1: Install the latest Node.js runtime from here .
Step 2: Install the robotjs package. We are going to install this package locally i.e. it will be accessed only in the working folder. This can be done by opening terminal/command prompt in the same directory where the node is installed and running the below command.
npm install robotjs
Step 3: Create a JavaScript file in the same directory as the credentials file. This file would contain the code for controlling the operating system and automate the desired tasks. The steps below are followed to do the same. This is written in this main JavaScript file.
- Get to the search bar.
- Type “openboard” and press enter to open it, then minimize it.
- Get to the search bar again.
- Type “sublime text” and press enter to open it, then minimize it.
- Get to the search bar again.
- Type “chrome” and press enter to open it. Open “whatsapp web” and “gfg practice” tabs in it, then minimize it.
- Get to the search bar again.
- Type “one note” and press enter to open it, then minimize it.
- Get to the search bar again.
- Type “notepad” and press enter to open it, then write a “done” message
Step 4: Start the JavaScript file containing the script using the below command.
node automate.js
Complete Code:
Javascript
| // Include the robotjs package varrobot = require("robotjs"); // Timeout to wait if system is slow setTimeout(startOpenBoard, 1000);//Opening the openboard//Can learn more about these//properties from the robotjs sitefunctionstartOpenBoard(){    robot.moveMouseSmooth(98,844);    robot.mouseClick();    robot.typeString(" openboard ");    robot.keyTap("enter");        //Minimize openboard    robot.moveMouseSmooth(1433,28);    robot.mouseClick();        //Start sublime text after 1s    setTimeout(startSublimeText, 1000);}functionstartSublimeText(){    robot.moveMouseSmooth(98,844);    robot.mouseClick();    robot.typeString(" sublime text ");    robot.keyTap("enter");      //Minimize sublime    robot.moveMouseSmooth(1418,8);    robot.mouseClick();        //Start chrome after 1s    setTimeout(startChrome, 1000);}functionstartChrome(){    robot.moveMouseSmooth(98,844);    robot.mouseClick();    robot.typeString(" chrome ");    robot.keyTap("enter");         //Open whatsapp web    robot.moveMouseSmooth(506,516);    robot.mouseClick();    robot.typeString("whatsapp web");    robot.keyTap("enter");     robot.moveMouseSmooth(349,389);    robot.mouseClick();        //Open a new tab    robot.keyToggle("control","down");    robot.keyTap("t");    robot.keyToggle("control","up");        //Open gfg practice    robot.moveMouseSmooth(506,516);    robot.mouseClick();    robot.typeString("gfg practice");    robot.keyTap("enter");     robot.moveMouseSmooth(362,788);    robot.mouseClick();    //Open a new tab    robot.keyToggle("control","down");    robot.keyTap("t");    robot.keyToggle("control","up");    //Minimize chrome    robot.moveMouseSmooth(1398,23);    robot.mouseClick();        //Start one note after 1s    setTimeout(startOneNote, 1000); } functionstartOneNote(){    robot.moveMouseSmooth(98,844);    robot.mouseClick();    robot.typeString(" oneNote ");    robot.keyTap("enter");         //Minimize one note    robot.moveMouseSmooth(1443,10);    robot.mouseClick();        //Start notepad after 1s    setTimeout(startNotePad, 1000);}functionstartNotePad(){    robot.moveMouseSmooth(98,844);    robot.mouseClick();    robot.typeString(" notepad ");    robot.keyTap("enter");    robot.moveMouseSmooth(600,500);    robot.mouseClick();     //Type a "Set up done" message    robot.typeString(" Your System is ready to use, Sir.");} | 
Output: 
 
NOTE: Here, I have used the coordinates according to my screen size. One can find their screen coordinates by running the following code and pointing their mouse to the location for which to find coordinates.
Run below command:
node screenPosition.js
Code:
Javascript
| //Include robotjs packagevarrobot = require("robotjs");//Show mouse location wherever it is pointing  varid = setInterval(showMouseLocation,1000);//function thatfunctionshowMouseLocation(){varmousePosition = robot.getMousePos();console.log(mousePosition);//Terminate the program //whenever mouse points//at top left corner//or press ctrl+c to terminateif(mousePosition.x == 0 && mousePosition.y == 0){    clearInterval(id);  }} | 
 
				 
					


