Assigned hotkey won't work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
jlleva
Posts: 20
Joined: 01 Jan 2022, 07:48

Assigned hotkey won't work

Post by jlleva » 09 Dec 2022, 14:40

Hi! First I want to thank to whoever i got these codes from but yeah I'm having issues.

1. How can I make the new assigned hotkey for Copy work even if in Paste and Cut is blank/empty? i get an error " " is not a valid key name.
2. The assigned hotkeys won't work if the checkbox is unchecked.

I'm really new and i don't know where to go to fix the error. This code giving me a hard time :roll: thanks in advance!

Code: Select all

#SingleInstance, Force

Gui, Add, Text,,Assign hotkey for Copy
Gui, Add, Hotkey, vKey1,
Gui, Add, Text,,Assign hotkey for Paste
Gui, Add, Hotkey, vKey2,
Gui, Add, Text,,Assign hotkey for Cut
Gui, Add, Hotkey, vKey3,

Gui, Add, CheckBox, x10 y150 vVClipHistory gGClipHistory, Use app's Clipboard History shortcut

Gui, Add, Button, gStoreKey, Save Settings
Gui, Show

OnClipboardChange("clipchanged")
return
clipchanged()
{
 SoundBeep, 1500, 70
}

Return

GuiClose:
ExitApp


Copy:
Send ^c
return

Paste:
Send ^v
return

Cut:
Send ^x
return


StoreKey:
Gui, Submit, NoHide
Hotkey, %Key1%, Copy
Hotkey, %Key2%, Paste
Hotkey, %Key3%, Cut
return


GClipHistory:
Gui, Submit, NoHide
return



#If VClipHistory
~LButton & RButton::
Send, #v
return




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

Re: Assigned hotkey won't work

Post by mikeyww » 09 Dec 2022, 15:19

Instead of issuing the Hotkey command definitively, you can just :arrow: Try it. ;) This will prevent the error (message).

User avatar
jlleva
Posts: 20
Joined: 01 Jan 2022, 07:48

Re: Assigned hotkey won't work

Post by jlleva » 10 Dec 2022, 06:05

Hi thank you for noticing :D I always see you helping newbies :salute: I just checked that Try statement but those samples are too complex. If maybe can give me simple Try/Catch sample? TYVM This would take me days or weeks to figure out :lol: or maybe just remove the checkbox thing and put the shortcut by default

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

Re: Assigned hotkey won't work  Topic is solved

Post by mikeyww » 10 Dec 2022, 06:40

Code: Select all

Try Hotkey, %Key1%, Copy

User avatar
jlleva
Posts: 20
Joined: 01 Jan 2022, 07:48

Re: Assigned hotkey won't work

Post by jlleva » 11 Dec 2022, 10:50

Code: Select all

StoreKey:
Gui, Submit, NoHide
Try
{
Hotkey, %Key1%, Copy
Hotkey, %Key2%, Paste
Hotkey, %Key3%, Cut
return
}
return


 ~LButton & RButton::

GuiControlGet, status,,VClipHistory



If status = 1

{

Send #v

}

return

Hi :D It's all working now without errors thank you very much! until next gui problems! :lol:

Post Reply

Return to “Ask for Help (v1)”