Script keeps crashing

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Skipper
Posts: 1
Joined: 18 Oct 2021, 11:47

Script keeps crashing

18 Oct 2021, 11:53

I basically wrote a small script to use F keys for copy and paste, as well as mouse buttons for pasting but also copying an entire row from a notepad file. It worked great the first day, ever since then the script works for the first few copy/paste hotkeys, it then crashes AND the .ahk file disappears completely. I have to create a new .ahk file, and the same things happens again. Any suggestions? Here's the script:

Code: Select all

F1::Send, ^c
F2::Send, ^v
F3::Send, ^+v
F4::Send, ^a
XButton1::Send, ^v
XButton2::Send, {Shift}+{Down}^c
return
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Script keeps crashing

18 Oct 2021, 12:53

Code: Select all

#IfWinActive ahk_exe notepad.exe

F1::                ; F1       = Copy selected text
Clipboard =
ControlGet, Clipboard, Selected,, Edit1
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return

F2::                ; F2       = Paste clipboard
XButton1::Send ^v   ; XButton1 = Paste clipboard

F4::                ; F4       = Copy all text
Clipboard =
ControlGetText, Clipboard, Edit1
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return

XButton2::          ; XButton2 = Copy current line
Clipboard =
ControlGet, lineNum, CurrentLine,, Edit1
ControlGet, Clipboard, Line, %lineNum%, Edit1
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return

#IfWinActive
Test this script with no other code, and no other scripts running. The script itself should not crash. If so, try disabling your antivirus.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, filipemb, OrangeCat and 171 guests