Shortkeys app not converting what AHK sends

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Shortkeys app not converting what AHK sends

Post by jameskhalil » 19 Jul 2021, 10:59

Hi,

I am using both the ShortKeys app (https://www.shortkeys.com) and AHK, but when I send the ShortKey code (via AHK) it is not interpreted by the ShortKeys app. I tried the different send methodes but without success.
Edit: I have to use the ShortKeys app due to office restrictions (its complicated).

Code: Select all

#z::
Send //-
return
Thank you.
Last edited by jameskhalil on 19 Jul 2021, 16:18, edited 1 time in total.
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

Re: Shortkeys app not converting what AHK sends

Post by flyingDman » 19 Jul 2021, 13:52

You may want to explain why you are using both AHK and Shortkeys...
14.3 & 1.3.7
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 19 Jul 2021, 15:19

Cant replace ShortKeys app due to office restrictions.
User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: Shortkeys app not converting what AHK sends

Post by boiler » 19 Jul 2021, 17:56

But apparently you can use AHK. Can't you just ignore Shortkeys and implement everything you need in AHK? Instead of sending something intended to trigger a Shortkeys shortcut, just have AHK send the ultimate text or perform whatever would have been executed by Shortkeys.
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 21 Jul 2021, 08:06

Thank you for your suggestions, but unfortunately it's not an option to replace the ShortKeys app.
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Shortkeys app not converting what AHK sends

Post by joedf » 21 Jul 2021, 08:24

Perhaps, there's a way to extract macros saved for shortkeys, and then have AHK send the text...? :geek:
Or try another send mode?
https://www.autohotkey.com/docs/commands/SendMode.htm
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 22 Jul 2021, 16:58

Here is what I tried:

Code: Select all

#z::
	{
	SendRaw //pk Raw (1){enter}
	Send {Blind}//pk Blind (2){enter}
	Send {Text}//pk Text (3){enter}
	Send //pk usual (4){enter}
	SendInput //pk Input (5){enter}
	SendEvent //pk Event (6){enter}
	Send {NumpadDiv}{NumpadDiv}pk buttons (7){enter}
	return
	}
Gives:

//pk Raw (1){enter}//pk Blind (2)
//pk Text (3){enter}//pk usual (4)
//pk Input (5)
//pk Event (6)
//pk buttons (7)

With the ShortKeys app "//pk" is supposed to give "PK 22/7/21"

What did I not try?
Thanks
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Shortkeys app not converting what AHK sends

Post by joedf » 22 Jul 2021, 21:49

Do you have an "shk" file? Maybe it can be read through AHK?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 23 Jul 2021, 10:26

Here's an example. Please rename extention to .shk
Thank you!
Attachments
example ShortKeys app.txt
(2.08 KiB) Downloaded 18 times
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Shortkeys app not converting what AHK sends

Post by joedf » 23 Jul 2021, 15:15

So unfortunately, the SHK files does not seem to be a in simple text-based format... :/
I can see some text but, not sure about the shortcut information:

Code: Select all

<CONTROL>a<IMSD:10><CONTROL><ARROW RIGHT><CONTROL><ARROW RIGHT><CONTROL><ARROW RIGHT><IMSD:15><ARROW DOWN><INSERT>c<IMSD:500>P-Validation Rx<IMSD:500><TAB> 
<TAB><TAB><TAB><TAB><TAB><TAB> ordonnance vérifiée par PK le <YYYY-MM-DD{YF000}><IMSD:500><CONTROL>s<ALT>cr<IMSD:500>n<IMSD:2000> <DD/MM/YYYY{NF000}> etc
En toute collaboration, Merci et bonne journée.
But based on that, these are all things AHK can do. I guessing you want to continue using shortkeys because there are saved entries you need?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 23 Jul 2021, 17:43

It will be complicated (head office very tough restrictions) to exchange ShortKeys by AHK but I will try.

So I found this script that I can use to fetch data from an excel file containing the definitions of the ShortKeys. But I need AHK to fire every time //(Key) is typed. In other words pressing "//abc" translates to "Send the sentence (or actions) with abc as its Key" (whatever is in the excel sheet next to abc).

In this script I see that I can use "LookUp[content]" to fetch the definition of the Key, but my coding skills aren't good enough, can anyone help me?

Thank you in advance!



Script to read excel file (reads in the file "read.xlsx"):

Code: Select all

Path := "C:\Users\Desktop\read.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Visible := False
XL_Workbook := XL.Workbooks.Open(Path)
XL_WorkSheet := XL_Workbook.Worksheets(1) ; I'm assuming worksheet 1 here because of the test file

LookUp := {} ; Object to hold lookups

Loop
{
	IF (XL_WorkSheet.Range("A" . A_Index).Value)
		LookUp[XL_WorkSheet.Range("A" . A_Index).Text] := XL_WorkSheet.Range("B" . A_Index).Text
	Else
		Break
}

XL.Quit()

Gui, Add, Edit, w100 vcontent,
Gui, Add, Button, gsubmit Default, Submit
#x::Gui, Show, autosize

submit:
Gui, submit,
msgbox, % "the meaning of " . content . " is " . LookUp[content]
Return
Attachments

[The extension xlsx has been deactivated and can no longer be displayed.]

User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

Re: Shortkeys app not converting what AHK sends

Post by flyingDman » 23 Jul 2021, 19:45

Try something like this:

Code: Select all

Path := a_scriptdir "\read.xlsx"
XL := ComObjCreate("Excel.Application")
XL_Workbook := XL.Workbooks.Open(Path)
sarr := xl.activesheet.usedrange.value
cnt := xl.activesheet.usedrange.rows.count - 1      ; -1 because of the header
XL_Workbook.close()
xl.quit()

loop, %cnt%
	Hotstring(":://" sarr[a_index + 1,1], sarr[a_index + 1,2])

msgbox,,,Hotstrings activated!,3
14.3 & 1.3.7
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Shortkeys app not converting what AHK sends

Post by joedf » 24 Jul 2021, 21:27

@jameskhalil
I'm glad that you have the entries available in an excel sheet, but do you have to update this yourself? Is that why you need to convince to use ahk instead of shortkeys? Either, I would definitely try out what flyingDman suggested. :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 26 Jul 2021, 11:55

Thanks for your help. What did I do wrong? Nothing happens when I type "//one"

Code: Select all

Path := a_scriptdir "\read.xlsx"
XL := ComObjCreate("Excel.Application")
XL_Workbook := XL.Workbooks.Open(Path)
sarr := xl.activesheet.usedrange.value
cnt := xl.activesheet.usedrange.rows.count - 1      ; -1 because of the header
XL_Workbook.close()
xl.quit()

loop, %cnt%
	Hotstring(":://" sarr[a_index + 1,1], sarr[a_index + 1,2])

msgbox,,,Hotstrings activated!,3


Loop
{
	IF (XL_WorkSheet.Range("A" . A_Index).Value)
		LookUp[XL_WorkSheet.Range("A" . A_Index).Text] := XL_WorkSheet.Range("B" . A_Index).Text
	Else
		Break
}

XL.Quit()

Gui, Add, Edit, w100 vcontent,
Gui, Add, Button, gsubmit Default, Submit
#x::Gui, Show, autosize

submit:
Gui, submit,
msgbox, % "the meaning of " . content . " is " . LookUp[content]
Return
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Shortkeys app not converting what AHK sends

Post by joedf » 26 Jul 2021, 12:46

Please ensure you press an "end" key such as Enter, Space or . to trigger it.
The script worked flawlessly for me.

If you want them to trigger without an "end" key, this can be done with the asterisk option:
https://www.autohotkey.com/docs/Hotstrings.htm#Options

That is, you can replace

Code: Select all

Hotstring(":://" sarr[a_index + 1,1], sarr[a_index + 1,2])
with this in the script

Code: Select all

Hotstring(":*://" sarr[a_index + 1,1], sarr[a_index + 1,2])
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
flyingDman
Posts: 2776
Joined: 29 Sep 2013, 19:01

Re: Shortkeys app not converting what AHK sends

Post by flyingDman » 26 Jul 2021, 13:33

The script I provided is intended to create the hotstrings you are looking for. The part you added (from second loop down), is unnecessary. Make sure the path is OK (I put the spreadsheet in my scripts directory), launch the script and wait for the "Hotstrings activated!" message. As Joe mentioned, use :*: or ::
14.3 & 1.3.7
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 26 Jul 2021, 14:46

Is it normal that it works without an end key? (I only typed "//one" and it worked. Its perfect but I wanted to make sure)
User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: Shortkeys app not converting what AHK sends

Post by boiler » 26 Jul 2021, 15:01

It’s normal if you include the * option in your hotstring definition as joedf and flyingDman said. That’s exactly what it’s for. If you don’t want to take what they are saying at face value for some reason, see hotstring options (same link joedf gave).
jameskhalil
Posts: 20
Joined: 07 Jun 2020, 13:56

Re: Shortkeys app not converting what AHK sends

Post by jameskhalil » 26 Jul 2021, 15:47

Thank you every body!!
Post Reply

Return to “Ask for Help (v1)”