Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
588 views
in Technique[技术] by (71.8m points)

autohotkey - Sending the key combination within its remap not working AHK

I made an AHK script that compiles my keyboard layout in AHK, moves it to the Windows 10 startup folder, and then runs it. When I run the script and press the key combo it does run, and everything functions except the initial send of Ctrl + F7, which is supposed to compiles the script in my editor. I've tried a few things, but it hasn't worked so far. Thanks for your help, and I've attached the code below.

#IfWinActive, ahk_class SciTEWindow ;if script editor is open
    $<^F7:: ;if ctrl+F7 is pressed
    Sleep, 200 ;wait a 0.2 seconds
    Send {^F7} ;send ctrl+F7 to compile script (this line isn't working)
    Sleep, 2000 ;wait 2 seconds for the script to compile
    FileCopy, C:UsersjacknTypingKey MappingsStartup Folder Layoutskeymap.exe, C:UsersjacknAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup, 1 ;Copies the file to the startup folder
    Sleep, 100;waits 0.1 seconds
    run, C:UsersjacknTypingKey MappingsStartup Folder Layoutskeymap.exe ;runs the program
    return
return

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of

Send {^F7}

Use

Send ^{F7}

Full Script:

#IfWinActive, ahk_class SciTEWindow ;if script editor is open
    $<^F7:: ;if ctrl+F7 is pressed
    Sleep, 200 ;wait a 0.2 seconds
    Send ^{F7} ;send ctrl+F7 to compile script (this line has been changed)
    Sleep, 2000 ;wait 2 seconds for the script to compile
    FileCopy, C:UsersjacknTypingKey MappingsStartup Folder Layoutskeymap.exe, C:UsersjacknAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup, 1 ;Copies the file to the startup folder
    Sleep, 100;waits 0.1 seconds
    run, C:UsersjacknTypingKey MappingsStartup Folder Layoutskeymap.exe ;runs the program
    return
return

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...