HomeSoftwareScriptsNotesToolboxGallery
Computing
Thoughts on Coding Styleddrescue Recovery NotesDomain 301 Perma RedirectWin/Linux PuTTY File TransferOpenVPN Site-to-Site SetupParity Data CheckingRclone Quick ReferenceSnapRAID NotesSSH TunnelingTransfer E-Mails with IMAPUDK Third Person CameraVPN Protocol Ports

GNU/Linux
Apache Process Mem UsageApache and CA OpenSSLApache2 htpasswd NotesCentOS 7 GlusterFS NotesCracking WEP and WPADebian 7 on Hyper-VDebian 7 to 8 UpgradeDebian 8 to 9 UpgradeDebian 9 DRBD SetupDebian and VirtualboxDebian and LSBInitScriptsDebian and systemdDebian Apache LetsEncryptDebian Apt AutoremoveDebian Cron & AnacronDebian KVM HypervisorLinux Bash ColorsLinux Cron BackupLinux Dnsmasq Setup NotesIptables Chain ExampleIptables Firewall and GatewayLinux MD RAID BasicsLinux iproute2 RoutingLinux SFTP Network ShareAvoid Linux Shell LoggingChecking Storage UsageLinux I/O Disk PerformanceLinux ZFS NotesVi/Vim Basic Reference

Microsoft
Bypass Windows PasswordDaz and ToolkitMRTG Network Traffic ViewMS Outlook NotesDOS File Content SearchDOS Merging VCF filesROBOCOPY Batch ScriptingPowerShell Reference NotesThe runas CommandTeamViewer on HeadlessUpdateOrchestrator ModWorkgroup Failover ClusterDisable OneDrive in W10Windows 10 ServerWindows WiFi and netshWindows Boot Custom UIHyper-V NetworkingHyper-V ReplicationIIS10 and PHP7 SetupLet's Encrypt and IISPlex Media Server MigrationRebuilding Boot PartitionSecuring RDP ConnectionsServer 2012 R2 SetupWindows Shortcut CommandsWBAdmin Bare-Metal Backup

BSD/Unix
FreeBSD 10.0 Setup (NOR)

C#/.NET
C# Associative ArraysC# Asynchronized WebcallC# Base64 GZipped JSONC# Broadcast Registry ChangesChanging a project nameC# Code Execution TimerCode Signing With SigntoolC# Creating a WebserverC# Dealing with WhitespacesC# djDBI for SQL CEC# Form ReferencingC# Get Folder SizeC# Handling DisconnectsC# HTTP POST and GETC# Importing DLL FunctionsC# Installing ServicesC# Kill and Start ProcessesC# Lambda ExpressionsC# Local AppData HandlingC# Memory StreamReadingC# Minimize to System TrayC# PDFsharp and MigraDocC# Public Fields vs PropsC# Registry HandlingC# Regular ExpressionsC# Require AdministratorC# RichTextBox File StreamC# Application SettingsC# SqlCeConnection CodeC# Start with hidden formC# String EncryptionC# Cross Thread HandlingC# Updating A RuntimeC# Gmail as SMTPVSI Dependency ErrorC# Handle XML

C/C++
AOB Scan/InjectC Autodelete Old FilesC/C++ Multiline StringsC Socket ListeningC StringsGDI Double BufferWin32 Button ControlWin32 Edit ControlWin32 GetLastError()Win32 KeyloggingWin32 KeypostingWin32 Simple WindowWin32 Socket ProgrammingWin32 VERSIONINFO

PHP
Bitwise IP HandlingPHP ClassesContent Length HandlingDetecting Mobile BrowsersGoogle Captcha IntegrationHidden DownloadsHostname and Port RegexJSON Output HeadersMS Access Conn with COMProportional Image SizingRandom StringsRecursive FunctionsSending MailPHP SessionsSimple HTML-2-PDFPHP SimpleXMLTernary Operator and If/Else

SQL
MS Access Connection StringsMSSQL Case SensitivityMySQL Root Password ResetMySQL Check Slow QueriesColumn CountingQuick Note on CROSS JOINQuick Note on INNER JOINRandom Rows

HTML
HTML Raw Skeleton

JavaScript
AJAX Basicsevent.keyCode ReferenceIE7 Onclick EventsIE GIF Animation Problem

Java
Java Notater (NOR)

CSS
Border StylesFlyout MenusFont-Family Reference

Electrical
Betegnelser og SpenningsfallLovdata Elektrisk ArbeidResistors Series and ParallelSilicone and Circuit Boards

Win32 Keyposting


A small Win32 program I made to simulate the space key every 5 minutes to keep a program from idling out. It just inserts the key code into the keyboard stream and does not manipulate anything or touch the program itself. It was compiled in Visual C++ 2008 with the following settings:

Runtime library: /MT (makes it standalone).
Compile as C Code (/TC).

Main code:
#include <windows.h>
#include <time.h>
#include "resource.h"

/* Generic Win32 handler for close, destroy and other OS messages to the program. */
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
	switch(Msg) {
		case WM_CLOSE:
			DestroyWindow(hWnd);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		default:
			return DefWindowProc(hWnd, Msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

	/* Declarations. */
	WNDCLASSEX wc;
	HWND hWnd;
	MSG Msg;
	INPUT SpamKey = {0};
	KEYBDINPUT kb = {0};
	time_t timer_start, timer_stop;
	double timer_diff;

	/* Misc initializations. */
	ZeroMemory(&Msg, sizeof(MSG));
	timer_start = time(NULL);
	kb.wVk = VK_SPACE;

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = 0;
	wc.lpfnWndProc = (WNDPROC)WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "MainClass";

	/* Register window class. */
	if(!RegisterClassEx(&wc)) { 
		/* Silently exits if it fails. */
		return 0; 
	}

	/* Create the window. */
	if((hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,"MainClass","IdleGuard",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,250,100,NULL,NULL,hInstance,NULL)) == 0) { 
		return 0; 
	}

	/* Explicitly show the window. */
	ShowWindow(hWnd, SW_SHOW);

	/* Start message loop. */
	while(Msg.message != WM_QUIT) {

		/* Sleep 50 milliseconds to lower the CPU cycle stress */
		Sleep(50);

		/* Properly handle WM_CLOSE and WM_DESTROY messages. */
		if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) != 0) {
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}

		/* Only spam key every 5 minutes, should be ok for most MMO logouts. */
		timer_stop = time(NULL);
		if((timer_diff = difftime(timer_stop,timer_start)) >= 300) {
			/* Simulate the space key. */
			SpamKey.type = INPUT_KEYBOARD;
			kb.dwFlags = 0;
			SpamKey.ki = kb;
			SendInput(1,&SpamKey,sizeof(INPUT));
			Sleep(250);
			kb.dwFlags = KEYEVENTF_KEYUP;
			SpamKey.ki = kb;
			SendInput(1,&SpamKey,sizeof(INPUT));

			timer_start = time(NULL);
		}
	}

	return (int)Msg.wParam;
}