Help with a toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Raidiologist
Posts: 4
Joined: 30 Jun 2022, 09:36

Help with a toggle

Post by Raidiologist » 02 Jul 2022, 19:19

I am using this to remap a key for use in powerscribe, but my issue arises from muscle memory and wanting to hold down a key to dictate and release when done. The F4 button toggles the mic in powerscribe on and then again for off. I would like to try and set it up that when I hold the key it is on and when I release it, it turns it off. I would assume that it would be a send key then wait till release then send again. I am not sure. I did try to modify some examples of toggle that I found but it kept sending the key that was held down. Any help or advice is appreciated. TIA

Code: Select all

ToggleDictation() ; dictation ON/OFF switch
{
 WinActivate PowerScribe ; activate powerscribe window
 send {f4} ; start/stop dictation
}

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

Re: Help with a toggle

Post by mikeyww » 02 Jul 2022, 20:39

Welcome to this AutoHotkey forum! A demonstration is below.

Code: Select all

#IfWinExist ahk_exe notepad.exe
F4::
F4 Up::
WinActivate
Send {F4}
KeyWait, F4
Return
#IfWinExist

Raidiologist
Posts: 4
Joined: 30 Jun 2022, 09:36

Re: Help with a toggle

Post by Raidiologist » 04 Jul 2022, 19:45

Thank you, If I was looking to set the Ctrl::F4

is it as simple as this to change the key.

Code: Select all

Ctrl::F4
#IfWinExist Powerscribe
Ctrl::
Ctrl Up::
WinActivate
Send {Ctrl}
KeyWait, Ctrl
Return
#IfWinExist
[Mod edit: [code][/code] tags added.]

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

Re: Help with a toggle

Post by mikeyww » 04 Jul 2022, 19:51

When I want to find out if my script works, I run it, and I then have my answer. Try it! See if it works. Enjoy!

Raidiologist
Posts: 4
Joined: 30 Jun 2022, 09:36

Re: Help with a toggle

Post by Raidiologist » 06 Jul 2022, 16:23

I have made multiple attempts and have failed, with remapping ctrl to F4 and leaving the code as in or as below and a few other ways. Whatever I do it breaks and just cycles the key. The original method worked perfectly. Some assistance would be appreciated or direction.

Code: Select all

#IfWinExist Powerscribe
Ctrl::
Ctrl Up::
WinActivate
Send {F4}
KeyWait, F4
Return
#IfWinExist
[Mod edit: [code][/code] tags added. Please use them yourself, next time. Thank you!]

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

Re: Help with a toggle

Post by mikeyww » 06 Jul 2022, 20:06

I imagine that you want to KeyWait for the hotkey instead. Test in Notepad. Examine the KeyHistory. Remove the #If directive while you test.

Raidiologist
Posts: 4
Joined: 30 Jun 2022, 09:36

Re: Help with a toggle

Post by Raidiologist » 06 Jul 2022, 20:31

Fixed, thanks for the guidance.

Post Reply

Return to “Ask for Help (v1)”