Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run AHK code in QM, can you add a function?
#1
In QM, it is very convenient to run vbs scripts. Like the code below, I hope that developers can add a function, such as Ahkexec,  I can use to run ahk scripts, like the code behind. Smile thank you very much

Macro vbs 

Code:
Copy      Help
lpstr code=
;Set app=CreateObject("Word.Application")
;app.Visible=True
VbsExec code

Macro ahk 

Code:
Copy      Help
lpstr code=
;MsgBox, 4, , Would you like to continue?
;IfMsgBox, No
;;;;;return
;MsgBox You pressed YES.
AhkExec code

I am looking forward to anyone to propose some methods, thanks in advance.
#2
don't need ahk for that


Code:
Copy      Help
sel mes("Would You Like to continue?" "QM message Box" "YN?")
,case 'Y'
,mes "You Pressed Yes"
,case 'N'
,ret
#3
@kevin  Thank you very much,  the above code is my example, I found a lot of ahk code, I want to run them with QM, I don't want to re-write code with QM I want AHK and QM to work together to do some work more efficiently.
#4
i understand not sure that will happen unless ahk has a com component then maybe can use in qm

personally there isn't much i haven't been able to do in qm so i don't use ahk
#5
I don't know whether AHK script engine can be embedded in other programs, like for example python or C#. If not, can run .ahk script file.

Function AhkExec
Code:
Copy      Help
;/
function $ahkScriptFile

;Executes an Autohotkey script file (.ahk).
;Waits until it ends.

;EXAMPLE
;AhkExec "$documents$\test4.ahk"


str ahk="C:\Program Files\AutoHotkey\AutoHotkey.exe"
str script.expandpath(ahkScriptFile)
int exitCode=RunConsole2(F"{ahk} /ErrorStdOut ''{script}''" _s)
if(exitCode) end F"{ERR_FAILED}. AHK exit code: {exitCode}. Message: {_s}"
#6
Thank you very much, the code test runs successfully.  Smile

I searched for some information about python using ahk. (Please see the attached picture)

https://autohotkey.com/board/topic/49656...th-python/
https://autohotkey.com/board/topic/39588-autohotkeydll/

VC code:

#include <windows.h>
#include <stdio.h>

typedef int (*ahkdll)(wchar_t *, wchar_t *, wchar_t *) ;
typedef int (*ahkReady)();
int main()
{
   
   // Load DLL file
   HINSTANCE hinstLib = LoadLibrary("AutoHotkey.dll");
   if (hinstLib == NULL)
   {
      printf("ERROR: unable to load DLL/n");
      return 1;
   }
   
   // Get function pointer
   ahkdll ahkdll_ = (ahkdll)GetProcAddress(hinstLib, "ahkdll");
   ahkReady ahkReady_ = (ahkReady)GetProcAddress(hinstLib, "ahkReady");
   
   if (ahkdll_ == NULL || ahkReady_ == NULL)
   {
      printf("ERROR: unable to find DLL function/n");
      FreeLibrary(hinstLib);
      return 1;
   }
   
   // Call function.
   ahkdll_(L"D://MyScript.ahk", L"", L"");
   
   // Wait for script to finish
   while (ahkReady_())
      Sleep(50);
   // Unload DLL file
   FreeLibrary(hinstLib);
   return 0;
}


can I get the return value of the AHK code in the QM code?  How to use dll in function Ahkexec?  Is it easier to use dll?  Can you provide an example? thank you very much  Smile

dll download:
https://codeload.github.com/HotKeyIt/ahk...zip/master


Attached Files Image(s)
   


Forum Jump:


Users browsing this thread: 4 Guest(s)