├── res
├── stop.bmp
├── avoid.gif
├── finger.cur
├── shake.gif
└── mouse_stop.gif
├── src
├── mouse_button_swap.nim
├── mouse_trap.nim
├── mouse_trails.nim
├── rotate.nim
├── dripper.nim
├── highcontrast.nim
├── start_disable.nim
├── start_popup.nim
├── random_capslock.nim
├── shake.nim
├── time_local.nim
├── random_close.nim
├── bsod.nim
├── mouse_invert.nim
├── stop_shutdown.nim
├── avoid.nim
├── mouse_stop.nim
├── mouse_cursor.nim
└── intercept_space.nim
└── README.md
/res/stop.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adeemm/WinAPI-Fun/HEAD/res/stop.bmp
--------------------------------------------------------------------------------
/res/avoid.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adeemm/WinAPI-Fun/HEAD/res/avoid.gif
--------------------------------------------------------------------------------
/res/finger.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adeemm/WinAPI-Fun/HEAD/res/finger.cur
--------------------------------------------------------------------------------
/res/shake.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adeemm/WinAPI-Fun/HEAD/res/shake.gif
--------------------------------------------------------------------------------
/res/mouse_stop.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adeemm/WinAPI-Fun/HEAD/res/mouse_stop.gif
--------------------------------------------------------------------------------
/src/mouse_button_swap.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 | # If buttons were already swapped, return back to normal
4 | if (SwapMouseButton(TRUE)):
5 | SwapMouseButton(FALSE)
6 |
--------------------------------------------------------------------------------
/src/mouse_trap.nim:
--------------------------------------------------------------------------------
1 | import std/os
2 | import winim
3 |
4 |
5 | var rect: RECT
6 | SetRect(&rect, 0, 0, 100, 100);
7 |
8 | ClipCursor(&rect);
9 | sleep(60000)
10 | ClipCursor(NULL);
--------------------------------------------------------------------------------
/src/mouse_trails.nim:
--------------------------------------------------------------------------------
1 | import std/random
2 | import winim
3 |
4 |
5 | var trails: int32
6 | SystemParametersInfoA(SPI_GETMOUSETRAILS, 0, &trails, 0)
7 |
8 | if (trails < 2):
9 | trails = (int32)rand(2..9)
10 | else:
11 | trails = 0
12 |
13 | SystemParametersInfoA(SPI_SETMOUSETRAILS, trails, NULL, 0)
--------------------------------------------------------------------------------
/src/rotate.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | var dm: DEVMODE
5 | EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)
6 |
7 | if (dm.dmDisplayOrientation == DMDO_DEFAULT):
8 | dm.dmDisplayOrientation = DMDO_180
9 | else:
10 | dm.dmDisplayOrientation = DMDO_DEFAULT
11 |
12 | ChangeDisplaySettings(&dm, 0)
--------------------------------------------------------------------------------
/src/dripper.nim:
--------------------------------------------------------------------------------
1 | import os
2 | import winim
3 |
4 |
5 | var windowCoords: RECT
6 |
7 | while true:
8 | var hWnd = GetForegroundWindow()
9 | GetWindowRect(hWnd, &windowCoords)
10 |
11 | SetWindowPos(hWnd, 0x0, windowCoords.left, windowCoords.top + 2, 0, 0, (SWP_NOSIZE or SWP_NOZORDER))
12 | sleep(10000)
--------------------------------------------------------------------------------
/src/highcontrast.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | var contrast: HIGHCONTRASTA
5 | contrast.cbSize = (int32)sizeof(HIGHCONTRASTA)
6 |
7 | SystemParametersInfoA(SPI_GETHIGHCONTRAST, (int32)sizeof(HIGHCONTRASTA), &contrast, 0)
8 |
9 | contrast.dwFlags = contrast.dwFlags xor HCF_HIGHCONTRASTON
10 |
11 | SystemParametersInfoA(SPI_SETHIGHCONTRAST, (int32)sizeof(HIGHCONTRASTA), &contrast, 0)
--------------------------------------------------------------------------------
/src/start_disable.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | let hWndTaskBar = FindWindow("Shell_TrayWnd", NULL);
5 | let hWndStart = FindWindowEx(hWndTaskBar, 0x0, "Start", "Start");
6 |
7 | # If the windows are already disabled, re-enable them
8 | if (EnableWindow(hWndStart, FALSE) or EnableWindow(hWndTaskBar, FALSE)):
9 | EnableWindow(hWndStart, TRUE)
10 | EnableWindow(hWndTaskBar, TRUE)
--------------------------------------------------------------------------------
/src/start_popup.nim:
--------------------------------------------------------------------------------
1 | import std/os
2 | import winim
3 |
4 |
5 | type
6 | SendKeys = array[2, INPUT]
7 |
8 | var inputs: SendKeys
9 |
10 | # Key Down event
11 | inputs[0].type = INPUT_KEYBOARD
12 | inputs[0].ki.wVk = VK_LWIN
13 |
14 | # Key Up event
15 | inputs[1].type = INPUT_KEYBOARD
16 | inputs[1].ki.wVk = VK_LWIN
17 | inputs[1].ki.dwFlags = KEYEVENTF_KEYUP
18 |
19 | # Send input every 60 seconds
20 | while true:
21 | SendInput((UINT)len(inputs), &inputs[0], (int32)sizeof(INPUT));
22 | sleep(60000)
--------------------------------------------------------------------------------
/src/random_capslock.nim:
--------------------------------------------------------------------------------
1 | import std/os
2 | import std/random
3 | import winim
4 |
5 |
6 | type
7 | SendKeys = array[2, INPUT]
8 |
9 | var inputs: SendKeys
10 |
11 | # Key Down event
12 | inputs[0].type = INPUT_KEYBOARD
13 | inputs[0].ki.wVk = VK_CAPITAL
14 |
15 | # Key Up event
16 | inputs[1].type = INPUT_KEYBOARD
17 | inputs[1].ki.wVk = VK_CAPITAL
18 | inputs[1].ki.dwFlags = KEYEVENTF_KEYUP
19 |
20 | # Send keypress randomly
21 | while true:
22 | SendInput((UINT)len(inputs), &inputs[0], (int32)sizeof(INPUT));
23 | sleep(rand(30000))
--------------------------------------------------------------------------------
/src/shake.nim:
--------------------------------------------------------------------------------
1 | import os
2 | import std/random
3 | import winim
4 |
5 |
6 | var hWndOrig = GetForegroundWindow()
7 | var windowCoords: RECT
8 | GetWindowRect(hWndOrig, &windowCoords)
9 |
10 | while true:
11 | var hWndNew = GetForegroundWindow()
12 |
13 | if (hWndNew != hWndOrig):
14 | hWndOrig = hWndNew
15 | GetWindowRect(hWndOrig, &windowCoords)
16 |
17 | var
18 | newX = rand(windowCoords.left - 3 .. windowCoords.left + 3)
19 | newY = rand(windowCoords.top - 3 .. windowCoords.top + 3)
20 |
21 | SetWindowPos(hWndOrig, 0x0, (int32)newX, (int32)newY, 0, 0, (SWP_NOSIZE or SWP_NOZORDER))
22 | sleep(10)
--------------------------------------------------------------------------------
/src/time_local.nim:
--------------------------------------------------------------------------------
1 | import std/registry
2 |
3 |
4 | var
5 | hkcuHandle = registry.HKEY_CURRENT_USER
6 | amLocal = getUnicodeValue("Control Panel\\International", "s1159", hkcuHandle)
7 | pmLocal = getUnicodeValue("Control Panel\\International", "s2359", hkcuHandle)
8 |
9 |
10 | if (amLocal == "AM" and pmLocal == "PM"):
11 | setUnicodeValue("Control Panel\\International", "s1159", "AM HI", hkcuHandle)
12 | setUnicodeValue("Control Panel\\International", "s2359", "PM HI", hkcuHandle)
13 | else:
14 | setUnicodeValue("Control Panel\\International", "s1159", "AM", hkcuHandle)
15 | setUnicodeValue("Control Panel\\International", "s2359", "PM", hkcuHandle)
--------------------------------------------------------------------------------
/src/random_close.nim:
--------------------------------------------------------------------------------
1 | import std/os
2 | import std/random
3 | import winim
4 |
5 |
6 | type
7 | SendKeys = array[4, INPUT]
8 |
9 | var inputs: SendKeys
10 |
11 | inputs[0].type = INPUT_KEYBOARD
12 | inputs[0].ki.wVk = VK_MENU
13 |
14 | inputs[1].type = INPUT_KEYBOARD
15 | inputs[1].ki.wVk = VK_F4
16 |
17 | inputs[2].type = INPUT_KEYBOARD
18 | inputs[2].ki.wVk = VK_F4
19 | inputs[2].ki.dwFlags = KEYEVENTF_KEYUP
20 |
21 | inputs[3].type = INPUT_KEYBOARD
22 | inputs[3].ki.wVk = VK_MENU
23 | inputs[3].ki.dwFlags = KEYEVENTF_KEYUP
24 |
25 | # Send keypress randomly
26 | while true:
27 | SendInput((UINT)len(inputs), &inputs[0], (int32)sizeof(INPUT));
28 | sleep(rand(30000))
--------------------------------------------------------------------------------
/src/bsod.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | proc RtlAdjustPrivilege*(privilege: ULONG, bEnablePrivilege: BOOLEAN, isThreadPrivilege: BOOLEAN, previousValue: PBOOLEAN): NTSTATUS
5 | {.discardable, stdcall, dynlib: "ntdll", importc: "RtlAdjustPrivilege".}
6 |
7 | proc NtRaiseHardError*(errorStatus: NTSTATUS, numberOfParameters: ULONG, unicodeStringParameterMask: ULONG, parameters: PULONG_PTR, validResponseOption: ULONG, response: PULONG): NTSTATUS
8 | {.discardable, stdcall, dynlib: "ntdll", importc: "NtRaiseHardError".}
9 |
10 | var
11 | prev: BOOLEAN
12 | response: ULONG
13 |
14 | # SE_SHUTDOWN_PRIVILEGE = 19
15 | RtlAdjustPrivilege(19, TRUE, FALSE, &prev)
16 |
17 | NtRaiseHardError(STATUS_ASSERTION_FAILURE, 0, 0, NULL, 6, &response);
--------------------------------------------------------------------------------
/src/mouse_invert.nim:
--------------------------------------------------------------------------------
1 | import os
2 | import winim
3 |
4 |
5 | # Get screen bounds
6 | var dm: DEVMODE
7 | EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)
8 |
9 | var oldPoint: POINT
10 | GetCursorPos(&oldPoint)
11 |
12 | while true:
13 | var newPoint: POINT
14 | GetCursorPos(&newPoint)
15 |
16 | var
17 | dx = newPoint.x - oldPoint.x
18 | dy = newPoint.y - oldPoint.y
19 | newX = oldPoint.x - dx
20 | newY = oldPoint.y - dy
21 |
22 | # Dont move mouse past screen bounds
23 | newX = clamp(newX, int32(0), dm.dmPelsWidth)
24 | newY = clamp(newY, int32(0), dm.dmPelsHeight)
25 |
26 | SetCursorPos(newX, newY)
27 |
28 | newPoint.x = newX
29 | newPoint.y = newY
30 | oldPoint = newPoint
31 |
32 | sleep(2)
--------------------------------------------------------------------------------
/src/stop_shutdown.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | var
5 | hInstance = GetModuleHandle(nil)
6 | hwnd: HWND
7 | msg: MSG
8 | wndclass: WNDCLASS
9 |
10 |
11 | # Handle Message Pump
12 | proc WindowProc(hwnd: HWND, message: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
13 | case message
14 | of WM_DESTROY:
15 | PostQuitMessage(0)
16 | return 0
17 |
18 | of WM_CLOSE, WM_QUERYENDSESSION:
19 | return 0
20 |
21 | else:
22 | return DefWindowProc(hwnd, message, wParam, lParam)
23 |
24 |
25 | # Boilerplate to create window
26 | wndclass.style = CS_HREDRAW or CS_VREDRAW
27 | wndclass.lpfnWndProc = WindowProc
28 | wndclass.cbClsExtra = 0
29 | wndclass.cbWndExtra = 0
30 | wndclass.hInstance = hInstance
31 | wndclass.hIcon = LoadIcon(0, IDI_APPLICATION)
32 | wndclass.hCursor = LoadCursor(0, IDC_ARROW)
33 | wndclass.hbrBackground = GetStockObject(WHITE_BRUSH)
34 | wndclass.lpszMenuName = nil
35 | wndclass.lpszClassName = "StopShutdown"
36 | RegisterClass(wndclass)
37 |
38 | hwnd = CreateWindow("StopShutdown", "Stop Shutdown", WS_MINIMIZE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hInstance, nil)
39 |
40 | ShutdownBlockReasonCreate(hwnd, "Nice Try")
41 |
42 | while GetMessage(msg, 0, 0, 0) != 0:
43 | TranslateMessage(msg)
44 | DispatchMessage(msg)
--------------------------------------------------------------------------------
/src/avoid.nim:
--------------------------------------------------------------------------------
1 | import std/random
2 | import winim
3 |
4 |
5 | let hWndTaskBar = FindWindow("Shell_TrayWnd", NULL);
6 | let hWndStart = FindWindowEx(hWndTaskBar, 0x0, "Start", "Start");
7 |
8 | var cursor: POINT
9 | GetCursorPos(&cursor)
10 |
11 | var rectTaskBar: RECT
12 | GetWindowRect(hWndTaskBar, &rectTaskBar)
13 |
14 | var rectStart: RECT
15 | GetWindowRect(hWndStart, &rectStart)
16 |
17 | # Reset Start Button Position
18 | SetWindowPos(hWndStart, 0x0, 0, 0, 0, 0, (SWP_NOSIZE or SWP_NOZORDER))
19 |
20 | var upperBound = rectTaskBar.right - rectStart.right;
21 |
22 |
23 | # Run callback everytime mouse is moved
24 | proc HookCallback(nCode: int32, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
25 | GetCursorPos(&cursor)
26 |
27 | if cursor.x >= rectStart.left and cursor.x <= rectStart.right and cursor.y >= rectStart.top:
28 | var newX = rand(upperBound)
29 | SetWindowPos(hWndStart, 0x0, (int32)newX, 0, 0, 0, (SWP_NOSIZE or SWP_NOZORDER))
30 | GetWindowRect(hWndStart, &rectStart)
31 |
32 | return CallNextHookEx(0, nCode, wParam, lParam)
33 |
34 |
35 | # Hook LowLevelMouseProc
36 | var hook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC) HookCallback, 0, 0)
37 | if bool(hook):
38 | try:
39 | PostMessage(0, 0, 0, 0)
40 | var msg: MSG
41 | while GetMessage(msg.addr, 0, 0, 0):
42 | discard
43 |
44 | finally:
45 | UnhookWindowsHookEx(hook)
46 |
--------------------------------------------------------------------------------
/src/mouse_stop.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | const stopImage = slurp("../res/stop.bmp")
5 | var pixelArrayOffset = ord(stopImage[10..13][0])
6 |
7 | # Window Stuff
8 | var
9 | hInstance = GetModuleHandle(nil)
10 | hwnd: HWND
11 | msg: MSG
12 | wndclass: WNDCLASS
13 | bmpBackground = CreateBitmap(75, 75, 1, 32, &stopImage[pixelArrayOffset..^1])
14 | timerID = 1337
15 |
16 |
17 | # Handle Message Pump
18 | proc WindowProc(hwnd: HWND, message: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
19 | case message
20 | of WM_DESTROY:
21 | KillTimer(hwnd, timerID)
22 | PostQuitMessage(0)
23 | return 0
24 |
25 | of WM_TIMER:
26 | var point: POINT
27 | GetCursorPos(&point)
28 | SetWindowPos(hwnd, HWND_TOPMOST, (point.x - 37), (point.y - 37), 0, 0, (SWP_NOSIZE or SWP_NOZORDER))
29 | return 0
30 |
31 | else:
32 | return DefWindowProc(hwnd, message, wParam, lParam)
33 |
34 |
35 | # Boilerplate to create window
36 | wndclass.style = CS_HREDRAW or CS_VREDRAW
37 | wndclass.lpfnWndProc = WindowProc
38 | wndclass.hInstance = hInstance
39 | wndclass.hbrBackground = CreatePatternBrush(bmpBackground)
40 | wndclass.lpszClassName = "MouseStopSign"
41 | RegisterClass(wndclass)
42 |
43 | hwnd = CreateWindowExW(WS_EX_TOPMOST or WS_EX_LAYERED, "MouseStopSign", "Mouse Stop Sign", WS_POPUP or WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, hInstance, NULL)
44 | SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_ALPHA or LWA_COLORKEY)
45 |
46 | ShowWindow(hwnd, SW_SHOW)
47 | UpdateWindow(hwnd)
48 | SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 75, 75, SWP_SHOWWINDOW)
49 |
50 | # Run timer to repeatedly set window position
51 | SetTimer(hwnd, timerID, 50, NULL)
52 |
53 | while GetMessage(msg, 0, 0, 0) != 0:
54 | TranslateMessage(msg)
55 | DispatchMessage(msg)
--------------------------------------------------------------------------------
/src/mouse_cursor.nim:
--------------------------------------------------------------------------------
1 | import os
2 | import system/io
3 | import winim
4 |
5 |
6 | const CURSOR = slurp("../res/finger.cur")
7 | var TEMP = getEnv("TEMP") & DirSep & "cursor.cur"
8 |
9 | # Extract embedded cursor to temp dir
10 | let f = open(TEMP, fmWrite)
11 | write(f, CURSOR)
12 | f.close()
13 |
14 | var hCursor = LoadCursorFromFileA(TEMP)
15 | SetCursor(hCursor)
16 |
17 |
18 | # Window Stuff
19 | var
20 | hInstance = GetModuleHandle(nil)
21 | hwnd: HWND
22 | msg: MSG
23 | wndclass: WNDCLASS
24 |
25 |
26 | # Get display size
27 | var dm: DEVMODE
28 | EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)
29 |
30 |
31 | # Handle Message Pump
32 | proc WindowProc(hwnd: HWND, message: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
33 | case message
34 | of WM_DESTROY:
35 | DestroyCursor(hCursor)
36 | PostQuitMessage(0)
37 | return 0
38 |
39 | of WM_SETCURSOR:
40 | SetCursor(hCursor)
41 |
42 | of WM_MOVING:
43 | SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, dm.dmPelsWidth, dm.dmPelsHeight, SWP_SHOWWINDOW)
44 | return 1
45 |
46 | of WM_MOVE:
47 | SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, dm.dmPelsWidth, dm.dmPelsHeight, SWP_SHOWWINDOW)
48 | return 0
49 |
50 | else:
51 | return DefWindowProc(hwnd, message, wParam, lParam)
52 |
53 |
54 | # Boilerplate to create window
55 | wndclass.style = CS_HREDRAW or CS_VREDRAW
56 | wndclass.lpfnWndProc = WindowProc
57 | wndclass.hInstance = hInstance
58 | wndclass.hCursor = hCursor
59 | wndclass.hbrBackground = GetStockObject(WHITE_BRUSH)
60 | wndclass.lpszClassName = "CustomCursor"
61 | RegisterClass(wndclass)
62 |
63 | hwnd = CreateWindowExW(WS_EX_TOPMOST or WS_EX_LAYERED, "CustomCursor", "Custom Cursor", WS_POPUP or WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, hInstance, NULL)
64 | SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 1, LWA_ALPHA or LWA_COLORKEY)
65 |
66 | ShowWindow(hwnd, SW_SHOW)
67 | UpdateWindow(hwnd)
68 |
69 | # Cover everything
70 | SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, dm.dmPelsWidth, dm.dmPelsHeight, SWP_SHOWWINDOW)
71 |
72 | while GetMessage(msg, 0, 0, 0) != 0:
73 | TranslateMessage(msg)
74 | DispatchMessage(msg)
--------------------------------------------------------------------------------
/src/intercept_space.nim:
--------------------------------------------------------------------------------
1 | import winim
2 |
3 |
4 | type
5 | SendKeys = array[12, INPUT]
6 |
7 | proc SendSpace() =
8 | var inputs: SendKeys
9 |
10 | # Hold shift for caps
11 | inputs[0].type = INPUT_KEYBOARD
12 | inputs[0].ki.wVk = VK_SHIFT
13 |
14 | # S key
15 | inputs[1].type = INPUT_KEYBOARD
16 | inputs[1].ki.wVk = 0x53
17 | inputs[2].type = INPUT_KEYBOARD
18 | inputs[2].ki.wVk = 0x53
19 | inputs[2].ki.dwFlags = KEYEVENTF_KEYUP
20 |
21 | # P key
22 | inputs[3].type = INPUT_KEYBOARD
23 | inputs[3].ki.wVk = 0x50
24 | inputs[4].type = INPUT_KEYBOARD
25 | inputs[4].ki.wVk = 0x50
26 | inputs[4].ki.dwFlags = KEYEVENTF_KEYUP
27 |
28 | # A key
29 | inputs[5].type = INPUT_KEYBOARD
30 | inputs[5].ki.wVk = 0x41
31 | inputs[6].type = INPUT_KEYBOARD
32 | inputs[6].ki.wVk = 0x41
33 | inputs[6].ki.dwFlags = KEYEVENTF_KEYUP
34 |
35 | # C key
36 | inputs[7].type = INPUT_KEYBOARD
37 | inputs[7].ki.wVk = 0x43
38 | inputs[8].type = INPUT_KEYBOARD
39 | inputs[8].ki.wVk = 0x43
40 | inputs[8].ki.dwFlags = KEYEVENTF_KEYUP
41 |
42 | # E key
43 | inputs[9].type = INPUT_KEYBOARD
44 | inputs[9].ki.wVk = 0x45
45 | inputs[10].type = INPUT_KEYBOARD
46 | inputs[10].ki.wVk = 0x43
47 | inputs[10].ki.dwFlags = KEYEVENTF_KEYUP
48 |
49 | # Release shift key
50 | inputs[11].type = INPUT_KEYBOARD
51 | inputs[11].ki.wVk = VK_SHIFT
52 | inputs[11].ki.dwFlags = KEYEVENTF_KEYUP
53 |
54 | SendInput((UINT)len(inputs), &inputs[0], (int32)sizeof(INPUT));
55 |
56 |
57 | # Run callback everytime key is pressed
58 | proc HookCallback(nCode: int32, wParam: WPARAM, lParam: LPARAM): LRESULT {.stdcall.} =
59 |
60 | if (bool(lParam)):
61 | var kbd: PKBDLLHOOKSTRUCT = cast[ptr KBDLLHOOKSTRUCT](lparam)
62 |
63 | if (kbd.vkCode == VK_SPACE):
64 | if (wParam == WM_KEYDOWN):
65 | SendSpace()
66 | return 1
67 | elif (wParam == WM_KEYUP):
68 | return 1
69 |
70 | return CallNextHookEx(0, nCode, wParam, lParam)
71 |
72 |
73 | # Hook LowLevelKeyboardProc
74 | var hook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC) HookCallback, 0, 0)
75 | if bool(hook):
76 | try:
77 | PostMessage(0, 0, 0, 0)
78 | var msg: MSG
79 | while GetMessage(msg.addr, 0, 0, 0):
80 | discard
81 |
82 | finally:
83 | UnhookWindowsHookEx(hook)
84 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WinAPI-Fun
2 | > A collection of (relatively) harmless prank / virus examples using the Windows API
3 |
4 |
5 |
6 | Pre-built binaries can be found in the [Releases](../../releases) section
7 |
8 | To reset most examples, re-launch and kill the program again
9 |
10 |
11 |
12 | | File | Description |
13 | | -------------------------------------------------- | --------------------------------------------------------------------- |
14 | | [avoid.nim](src/avoid.nim) | The start button avoids mouse clicks by jumping around on the taskbar |
15 | | [bsod.nim](src/bsod.nim) | Triggers a Blue Screen of Death |
16 | | [dripper.nim](src/dripper.nim) | Moves the current window down slightly every 10 seconds |
17 | | [highcontrast.nim](src/highcontrast.nim) | Enable high contrast mode system-wide |
18 | | [intercept_space.nim](src/intercept_space.nim) | Replaces space bar keypress with the word "space" |
19 | | [mouse_button_swap.nim](src/mouse_button_swap.nim) | Swaps the left and right mouse buttons |
20 | | [mouse_cursor.nim](src/mouse_cursor.nim) | Changes the mouse cursor to a finger via a full transparent window |
21 | | [mouse_invert.nim](src/mouse_invert.nim) | Inverts mouse movement on the x and y axes |
22 | | [mouse_trails.nim](src/mouse_trails.nim) | Creates a trail of mouse icons behind the cursor as it moves |
23 | | [mouse_stop.nim](src/mouse_stop.nim) | Creates a stop sign that follows the mouse cursor and blocks clicks |
24 | | [mouse_trap.nim](src/mouse_trap.nim) | Traps the mouse cursor in the top right corner for 60 seconds |
25 | | [random_capslock.nim](src/random_capslock.nim) | Randomly toggle the Caps Lock every 0-30 seconds |
26 | | [random_close.nim](src/random_close.nim) | Randomly closes the current focussed window every 0-30 seconds |
27 | | [rotate.nim](src/rotate.nim) | Rotates the display 180 degrees |
28 | | [shake.nim](src/shake.nim) | Rapidly shakes the current focussed window |
29 | | [start_disable.nim](src/start_disable.nim) | Disables clicking the start button or taskbar |
30 | | [start_popup.nim](src/start_popup.nim) | Opens the start menu popup randomly every 0-60 seconds |
31 | | [stop_shutdown.nim](src/stop_shutdown.nim) | Temporarily prevents a shutdown with a custom message |
32 | | [time_local.nim](src/time_local.nim) | Adds the message "HI" to the AM/PM localization string system-wide |
33 |
34 |
35 |
36 | ## Compilation
37 | [Install Nim](https://nim-lang.org/install_unix.html) and the [Winim](https://github.com/khchen/winim) library, then compile with the `--app:gui` flag
38 |
39 | Note: if cross-compiling from Linux or macOS, also install the [mingw](https://www.mingw-w64.org/) toolchain and use the `-d:mingw` flag
40 |
41 | ```sh
42 | nim c -d:mingw --app:gui src/avoid.nim
43 | ```
44 |
45 |
46 |
47 | ## Media
48 |
49 | #### Shake
50 |
51 |
52 |
53 |
54 |
55 | #### Mouse Stop
56 |
57 |
58 |
59 |
60 |
61 | #### Avoid
62 |
63 |
64 |
65 |
66 |
67 | ### USE AT YOUR OWN RISK
68 |
--------------------------------------------------------------------------------