Introduction: EMAIL PHONE SECURITY SYSTEM - ON Windows, for Non Linux Users

About: I eat food, sometimes I'm funny.
First things first, big shout out to Action_Owl, and KipKay.    This is instructable was idealistically created by KipKay, and Bones by Action_Owl.  I adapted the code and concept for something a little easier to use on my windows PC.  You can find their instructables with the following links

https://www.instructables.com/id/Twittering-Laser-Tripwire-with-Webcam-Capture/

https://www.instructables.com/id/Protect-Your-Home-with-Laserbeams/

Thanks for your ideas and creativity.

Step 1: Things You Will Needs.

Here is a list of items you will need
  • Soldering Tools
  • A PC with USB ports, and internet connection
  • Email address.
  • Autoit Scripting language - Download here. - http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe
  • Adruino Uno rev 3
  • Laser pointer any color, - for this instructable i used red. (they are cheap)
  • 100k ohm 5% tolerance resistor.
  • 1 Photo resistor, any size
  • 24 gauge wire.
  • Some Thermal Shrink tube.
  • Mirror squares.

Step 2: Building Your Laser Sensor

Look at the picture below and follow the tool tips

Making a light hood for the Photo resistor is essential! Random light will keep your sensor from detecting a trips if you fail to construct yours correctly.

Step 3: Building Your Laser

Remove your laser from its housing.
Connect the two power leds, one to the positive, one to the negative, which on this laser was + housing, Negative, spring.

Once the laser is wired up,  Connect it to   Digital pins GND, and pin13

Then secure it, I used a piece of 2x4 and zip ties.

Congrats your laser tripwire is now completely assembled,  Now lets move to programming.

Step 4: Programming Your Laser Modual

Goto http://www.Adruino.CC and download to adruino software.  -- http://arduino.cc/en/Main/Software

You will need to install the adruino drivers for USB emulation. this will be located within the zip file you just downloaded, under the drivers folder. 

Now open the Adruino software,  copy and past this code, provided by Action_Owl, and write it to the Adruino.

/////////////////////////////////////////

int ledPin =  13;
int analogPin = 0;
int ldrVal = 0;
int threshold = 100;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
}

void loop()                    
{
  ldrVal = analogRead(analogPin);
 
  if ( ldrVal > threshold )
  {
     Serial.print("1");
     delay(200); 
  }
 
  //Serial.println(ldrVal);
 
}

////////////////////////////////////////////////
DO not forget to connect your board VIA USB cable.

Once you upload this, your code will be active and your micro Controller will turn on,  you can test  your sensor by shining a flashlight into your photo resistor.  Working,  the RX LED will flash,  Shine a flashlight into the photo resistor, it should stop flashing...

Congrats, next step.



Step 5: Installing PC Side Software - Processing

For this step you will need to download a program called Processing. - http://www.processing.org

Processing is what we will use to listen for inputs from our Adruino Micro-controller,  this interface is done with serial port emulation through a U.S.B controller.  Now to make sure this functions as expected you need to have your RX-TX interface software correctly installed.

The files 
RXTXParallel.dll
RXTXSerial.dll
Rxtxcomm.Jar

These three files THE SAME VERSION  need to be placed in your Windows root folderWindows System 32 folder, and Processing root folder, and Adruino root folder.    Failing to do this will give you a RXTX error with Processing and it will not read serial inputs from the Adruino

Stable Library    --  YOU SHOULD BE GETTING THIS MESSAGE IN PROCESSING
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
[0] "COM1"
[1] "COM3"


Once this done,  restart windows,  reupload your Adruino programming. 

I spent countless hours tying to make this happen in Ubuntu  :/

Step 6: Interfacing With the Adruino Through Processing.

Now that you have processing installed,  Copy and paste the following info into Processing. In order for processing to find your adruino, you may need to change your serial port address.  The location in the code to do this is listed in picture below.

import processing.serial.*;

Serial myPort;
char inBuffer;
int wait, now, timeout = 10000;
boolean hold = false;

void setup() {
  size(200,200);
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[1], 9600);
  fill(#36ff00);
}

void draw() {
 
  while (myPort.available() > 1)
  {
    inBuffer = myPort.readChar();  

    if(inBuffer=='1')
    {     
      if ( !hold )
      {
        fill(#ff0000);
        println("Tripped");
        open("emailscript.exe");
        wait = millis();
        hold = true;
      }
    }
  }
 
  now = millis();
   
  if (now > (wait + timeout))
  {
    hold = false;
    fill(#36ff00);
  }
   
  rect(0,0,200,200);
}

Once this code is uploaded,  activate your adruino, then launch your processing sketch.

You should be getting a alternating RED/GREEN box with a 4 second or so delay.
This will also launch a command line script to email you .



Step 7: Sending an Email With Autoit - Macros

OK this part is super easy,  just about anyone who has done any programming is familiar with macros.  A Macro is one command or keystroke, that set off a series of predetermined commands or keystrokes. 

Four simple commands are used in this macro


MouseClick  -  Choose Right or left mouse click   Syntax  "MouseClick("Left")  or MouseClick("Right")"
MouseMove -   Move to specified pixel location      Syntax  "MouseMove(X,Y)"
Send -  Send String or keystroke series                  Syntax  "Send("F10")  Or  Send("Have a nice day)"  - if text box is selected
Sleep  -  Have macro wait between actions            Syntax  "Sleep(2000)"   -  Random number  from 100 - 10000

To find pixel location on your screen you can use the embedded auto it tool Au3info or Au3info_X64.   Each of these tools will be located in the default location, provided you did not custom install.

C:\Program Files (x86)\AutoIt3

To find a pixel location CLICK and DRAG THE SMALL CROSSHAIR icon on the finder tool to the desired location, the coordinates will be displayed in the tools info window.

Once you have macro built, you can test each stage using the "GO" command under tools, or press "F5"

Once you are certain your macro is working,   Compile it into a EXE file Named "emailscript"  and place it into the root folder of processing.

I have a Custom made macro here,  but for it to work, you will need to set screen resolution to 1600 x 1050, While using the firefox browser place the shortcut Icon on pixel location  "267, 133" .  You will also have to use gmail.

MouseMove(267,133)

sleep(2000)

MouseClick("left")
MouseClick("left")

sleep(2000)

MouseMove(450,104)

MouseClick("left")

;click email feild
mousemove(1044,287)
Sleep(2000)
Mouseclick("left")
Sleep(2000)
Send("your email@gmail.com")

;Click password field
Mousemove(1044,360)
Mouseclick("Left")
Sleep(2000)
Send("your password")
sleep(2000)

;Click Signin
MouseMove(1061,410)
Mouseclick("left")
Sleep(4000)

;Click Compose Button
Mousemove(115,277)
MouseClick("left")
Sleep(2000)

;Click send to feild)

MouseMove(322,288)
Mouseclick("left")
Send("receiving email, can be any")
Sleep(2000)

;Subject feild

MouseMove(320,345)
sleep(2000)
MouseClick("left")
sleep(2000)
Send("Boundary Anomaly Detected")

;Click Body field

MouseMove(256,438)
Sleep(2000)
MouseClick("left")
sleep(500)
Send("Computer Generated automated email, Class:Boundary Anomaly -  Interior breach")
Sleep(2000)

;Send Email
MouseMove(261,219)
sleep(500)
MouseClick("left")
Sleep(2000)


;Close Window

MouseMove(1653,7)
Sleep(500)
MouseClick("left")