Using Gobetwino to Control Windows through Arduino

A quick note on Gobetwino:

Gobetwino is a program that you can download for free online. It uses Arduino to control Windows programs. Using it can be kind of tricky, since it isn't going to make itself work with your computer; you have to comform to what it wants. Here's some stuff to keep in mind before you start using it.

-Both Arduino and Gobetwino have to be set use the same serial port. Arduino won't upload programs if something else is using its serial port, though, so you'll have to close the Gobetwino window so that the serial port will be free. After you've uploaded the program, open the Gobetwino window and hit your Arduino's reset button. This will make the program start and it'll work with Gobetwino.

-To make Gobetwino work, you'll have to write commands for it. It has some premade commands, and this lesson will basically run through those. To make a command, go to Command (which is next to File at the top row of commands) and then click New Command. Each command needs some input from you so it'll do exactly what you want. Everything we wrote that goes with .exe programs uses iTunes, but you can set it to work with any executable program (.exe). We just like iTunes.

TO LOG DATA (LGFIL)

Gobetwino Code:

The only parameter for this program is the .txt file. Create a .txt file somewhere and then enter its location into the correct parameter. We named our program LOGTEST. You'll have to create a notepad file, and put the path to it in your command. It'll send the data to that notepad file. In Arduino, you'll probably want to replace the varable with an analogRead command so that it'll record values. It should also put a time stamp next to the stuff it records, so you'll know exactly when changes happen.

Arduino Code:

int value = 877;

char buffer[5];

void setup()

{

Serial.begin(9600);

Serial.print("#S|LOGTEST|[");

Serial.print(itoa((value), buffer, 10));

Serial.println("]#");

}

void loop()

{

}

What This Does:

It takes the int value and saves it to the notepad file. The int value could be replaced with a sensor reading (use analogRead). It saves a time stamp too: it can record, for example, light or temperature changes and note when they happen.

TO START A PROGRAM (SPRID)

Gobetwino Code

The command must be a SPRID command. The program path should simply be the normal path to the program (like C:\Program Files\iTunes\iTunes.exe). It should be a .exe or a .txt—anything that can be opened by double-clicking its icon. We named our program OPENITUNES because we're the most creative people ever.

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.println("#S|OPENITUNES|[]#");

}

void loop()

{

}

What This Does

It basically clicks on the file named in the path. It will open it or run it if it is an executable (.exe) program (like iTunes).

TO START A PROGRAM AND SEND KEYSTROKES (SENDK)

Gobetwino Code

Can’t edit the parameters; just the SENDK command itself is enough. When you use a SENDK, you have to type it like this: SENDK|[0& then hit all the keys you want it to send in the order you want it to send them. Just follow the code in our example.

If you want to send a special key, here's a big list of ways to type those keys. The key itself comes first, followed by what you should type in SENDK.

Key Argument

BACKSPACE {BACKSPACE}, {BS}, or {BKSP}

BREAK {BREAK}

CAPS LOCK {CAPSLOCK}

DEL or DELETE {DELETE} or {DEL}

DOWN ARROW {DOWN}

END {END}

ENTER {ENTER} or ~

ESC {ESC}

HELP {HELP}

HOME {HOME}

INS or INSERT {INSERT} or {INS}

LEFT ARROW {LEFT}

NUM LOCK {NUMLOCK}

PAGE DOWN {PGDN}

PAGE UP {PGUP}

PRINT SCREEN {PRTSC}

RIGHT ARROW {RIGHT}

SCROLL LOCK {SCROLLLOCK}

TAB {TAB}

UP ARROW {UP}

F1 {F1}

F2 {F2}

F3 {F3}

F4 {F4}

F5 {F5}

F6 {F6}

F7 {F7}

F8 {F8}

F9 {F9}

F10 {F10}

F11 {F11}

F12 {F12}

F13 {F13}

F14 {F14}

F15 {F15}

F16 {F16}

To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or

ALT, create a compound string argument that represents the keystroke combination. You do this by preceding

the regular keystroke with one or more of the following special characters:

Key Special Character

SHIFT +

CTRL ^

ALT %

Note:

When used this way, these special characters are not enclosed within a set of braces.

To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are

pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For

example, to send the keystroke combination that specifies that the SHIFT key is held down while:

• e and c are pressed, send the string argument "+(ec)".

• e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.print("#S|OPENITUNES|["); //We have to start with a command we

//already made. This will make iTunes open

//and available to our keystrokes.

Serial.println("]#");

delay(10000);

Serial.println("#S|SENDK|[0&^a]#");

delay(1000);

Serial.println("#S|SENDK|[0&jet]#"); //Search for the artist Jet. iTunes looks

//for artists when you just type their names.

delay(1000);

Serial.println("#S|SENDK|[0&~]#"); // Start playing.

//A tilde is equal to a spacebar in Gobetwino's eyes, and

//hitting the spacebar makes iTunes start playing.

}

void loop()

{

}

What This Does

Arduino will open a program and then send keystrokes to it—effectively typing a predetermined without hitting the keys.

The SENDK|[0&^a]#" means that it will take the last thing it did—process ID zero—and sent it a CTRL-A (^ means ctrl). Next the ~ means the enter key, so it will send an enter to start playing music. iTunes will freak out if it doesn’t get the keystrokes in a certain order. Next, it looks for the artist “jet” and plays the first song on their list.

TO READ A LINE FROM A TEXT FILE (RLFIN)

Gobetwino Code

In “File” type the path to the file you want to read. Use the RLFIN preset. We named our command READLINE

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.println("#S|READLINE|[3]#");

}

void loop()

{

}

What This Does

This will take the line from the given document and display it in Gobetwino’s command output. For loops could possibly be used to show a group of sequential or subsequent lines.

I think this would be most useful if there were a file on the G-drive, where people might be changing information from time to time and you want to be able to look at it easily (maybe with Excel stuff).

TO SEND AN EMAIL (SMAIL)

Gobetwino Code

In the New Command menu, select SMAIL. The internal parameters are self-explanatory. Fill them out. We named our program MAILMAN.

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.println("#S|MAILMAN|[]#");

}

void loop()

{

}

What This Does

Sends an email.

TO PING A WEB PAGE (PING)

Gobetwino Code

Write a command with PING. Name it and select the specific URL you want to ping (for example, google.com). We named our program PINGALING, because we're awesome.

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.println("#S|PINGALING|[]#");

}

void loop()

{

}

What This Does

Put the name of something on your network as the thing you’re testing for (doing it on my laptop, which is named TIM_OCONNOR, I typed in TIM_OCONNOR). It will “ping” it and tell you if it is on the network.

TO SEND A TIME STAMP (T)

Gobetwino Code

Just use the “T” command. You can’t edit it in any way.

Arduino Code

void setup()

{

Serial.begin(9600);

Serial.println("#S|T|[]#");

}

void loop()

{

}

What This Does

Sends a time stamp. It will appear next to the standard time stamp that Gobetwino attaches to everything else it does. This is useful if you hook it up to a push-button, and you have to record the time a bunch of times over a period of time. Hit the button every time you want to know when something happened, and you’ll have a time stamp.

TO COPY A FILE (CPFIL)

Gobetwino Code

Simply select the file you would like to copy and where you would like it to save to.

Arduino Code

char buffer[5];

void setup()

{

Serial.begin(9600);

Serial.println("#S|COPYCAT|[]#");

}

void loop()

{

}

What This Does

Using this program you can copy a file to a new location. This could be useful if you needed to log something that is constantly updating. This program could create a copy of the old log file and save it to a different location before you updated it, so you could go back and check the older versions if you needed to.

TO DISPLAY THE DATE (D)

Gobetwino Code

No parameters to fill in for this.

Arduino Code

char buffer[5];

void setup()

{

Serial.begin(9600);

Serial.println("#S|D|[]#");

}

void loop()

{

}

What This Does

This program displays the date in the Gobetwino interface. So useful.