I have this code I want to run with a Command in the shortcut section:, the shortcut to run this is Ctrl+f, for some reason it runs once, then it doesnt after that. if I put this script inside ahk file, and do a run command, everything works prefect. What is the problem?
Code below:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
#SingleInstance, Force
; Add a short delay before sending Ctrl+F at the beginning
Send, ^f
; Loop to check for the ENTER key press
startTime := A_TickCount
while (A_TickCount - startTime) <= 10000 {
if GetKeyState("Enter", "P") {
Sleep, 200 ; Add a short delay to ensure the ENTER key press is processed
Send, ^f
Sleep, 50 ; Wait 50 milliseconds (optional, adjust as needed)
Send, {Esc}
ExitApp
}
Sleep, 50 ; Sleep to avoid high CPU usage
}
; If no key is pressed within 10 seconds, exit the script
ExitApp
Problem with shortcut excecuting only once
-
- Posts: 16
- Joined: Apr 25th, ’23, 17:20
Avoid ExitApp command in FastKeys scripts, replace it with Return.