Just send Keystroke with No Hotkey or Gui

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mboyd
Posts: 1
Joined: 03 Oct 2022, 10:30

Just send Keystroke with No Hotkey or Gui

Post by mboyd » 03 Oct 2022, 10:37

Hi,
Can I just send keystrokes to current application when I press on a Desktop Icon.
Don't want keyboard shortcut assigned or AHK GUI.

Thank you

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Just send Keystroke with No Hotkey or Gui

Post by mikeyww » 03 Oct 2022, 13:31

Welcome to this AutoHotkey forum!

Yes. Your script does not need to provide any hotkey or GUI. :arrow: Send

If you click on a Windows desktop icon, then the desktop is the current application. You can WinActivate any other window before your Send command.

Code: Select all

SplitPath, A_ScriptName,,,, fnBare
If !FileExist(lnk := A_Desktop "\" fnBare ".lnk") {
 FileCreateShortcut, % target := A_ScriptFullPath, %lnk%
 MsgBox, 64, Shortcut, Shortcut was created.`n`nLink file: %lnk%`n`nTarget: %target%
 ExitApp
}
WinGet, win, List
Loop, %win% {
 WinExist("ahk_id" win%A_Index%)
 WinGet, winStyle, Style
 WinGetTitle, ttitle
 If (winStyle & 0x10000000 && ttitle)
  If ttitle not in MainWindow,Program Manager,Start,Windows Task Manager
  { WinActivate
    Send abc
    SoundBeep, 1500
    Return
  }
}

Post Reply

Return to “Ask for Help (v1)”