Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I have been using AutoHotKey for quite some time and I have found it to be invaluable for enhancing Windows 7/10 functionality. I thought I'd post a couple of useful scripts here.

Windows 10 has a desktop feature that lets you hide/show your desktop icons. I prefer a clutter-free desktop but I also like to keep shortcuts there. The feature is manually available by either right-clicking on the desktop or by pressing SHIFT+F10 on the desktop, then selecting VIEW followed by SHOW DESKTOP ICONS from the context menu. The following code adds a hotkey (WIN+END) to toggle hide/show.

#END::
    winActivate, ahk_class Progman
    Send, +{f10}
    Send, v
    Send, d
    Return

I like being able to use either the mouse or the touchpad on my laptop but one thing that really annoys me is when, while I am typing, my wrist brushes against the touchpad and my cursor is repositioned somewhere else in the text area. The following AutoHotKey script disables the touchpad for a half second whenever a key is pressed.

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

#SingleInstance force
#Persistent
OnExit, Unhook

hHookKeybd := SetWindowsHookEx(WH_KEYBOARD_LL   := 13, RegisterCallback("Keyboard", "Fast"))
Return

ReenableTrackpad:
BlockInput, MouseMoveOff
Return

Unhook:
UnhookWindowsHookEx(hHookKeybd)
ExitApp

Keyboard(nCode, wParam, lParam)
{
   Critical
   If !nCode
   {
      BlockInput, MouseMove
      SetTimer, ReenableTrackpad, 500
   }
   Return CallNextHookEx(nCode, wParam, lParam)
}

SetWindowsHookEx(idHook, pfn)
{
   Return DllCall("SetWindowsHookEx", "int", idHook, "Uint", pfn, "Uint", DllCall("GetModuleHandle", "Uint", 0), "Uint", 0)
}

UnhookWindowsHookEx(hHook)
{
   Return DllCall("UnhookWindowsHookEx", "Uint", hHook)
}

CallNextHookEx(nCode, wParam, lParam, hHook = 0)
{
   Return DllCall("CallNextHookEx", "Uint", hHook, "int", nCode, "Uint", wParam, "Uint", lParam)
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.