Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fortran callable QM functions
#1
I am wondering whether it is possible to call from a Fortran program a QM function, and if yes what is the procedure to pass/get parameters. Any advice is mostly welcome.
#2
Call directly - no. The fastest way is to find the main QM window and send message. More info in QM Help topic "Command line parameters".
#3
I am sorry, I cannot well understand, from which application should I send the message (for example SendMessage(qmw WM_SETTEXT 3 "M ''tempf02''")? Could you please give an example? Many thanks in advance.
#4
From the Fortran program. Or from any.
I cannot give a Fortran example. SendMessage is a Windows API function, and probably you can call it from Fortran.
#5
Solution finally given : Subroutine ses_qmi.for. Example to call qm item temf03 in fortran program rs.for. Any comments are welcome.


Attached Files
.zip   ses_qmi.zip (Size: 735 bytes / Downloads: 299)
#6
@ssimop

Thank you for sharing your experience.

I don't know much about Fortran programming language. Can you help me how to implement it in VB programming language? Thanks in advance Smile
#7
C# example
Code:
Copy      Help
    //using System.Runtime.InteropServices;

    [DllImport("user32.dll", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode)]
    internal static extern IntPtr SendMessageS(IntPtr hWnd, int Msg, uint wParam, string lParam);

    [DllImport("user32.dll", EntryPoint = "FindWindowW", CharSet = CharSet.Unicode)]
    internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    static void TestQm2SendMessage()
    {
        var hwnd = FindWindow("QM_Editor", null);
        if(hwnd == default(IntPtr)) return;
        SendMessageS(hwnd, 12, 1, "Q ' M 'Macro295' C test C#");
    }

VB.NET example
Code:
Copy      Help
   'Imports System.Runtime.InteropServices

   <DllImport("user32.dll", EntryPoint:="SendMessageW", CharSet:=CharSet.Unicode)>
   Function SendMessageS(hWnd As IntPtr, Msg As Int32, wParam As UInt32, lParam As String) As IntPtr
   End Function

   <DllImport("user32.dll", EntryPoint:="FindWindowW", CharSet:=CharSet.Unicode)>
   Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr
   End Function

   Sub TestQm2SendMessage()
       Dim hwnd = FindWindow("QM_Editor", Nothing)
       If hwnd = IntPtr.Zero Then Return
       SendMessageS(hwnd, 12, 1, "Q ' M 'Macro295' C test VB")
   End Sub
#8
thank you very much  Heart

@[b]Gintaras[/b]

I want to know, in QM3, whether to support the function module to generate dll files? provide calls to other programming languages  Smile

The above code is VB.net. How is it different from the VB Script code? Can you provide the code corresponding of VB Script? thanks
#9
Dll in QM3 - yes.

VBScript does not support calling Windows dll functions. It supports only COM dlls.

COM dll :
http://www.quickmacros.com/forum/showthr...9#pid32229


VBScript example using function VbsExec in QM:
Macro Macro82
Code:
Copy      Help
str vbs=
;set q = CreateObject("QmSendMessage.QMSM")
;q.Run "Q ^ M ^Fun5^ C test", true
VbsExec vbs
out "---"

Function Fun5
Code:
Copy      Help
mes _command
#10
Thank you for your reminder, Macro vbs call qm1 Can run successfully Smile
 but I have two questions Huh
 
Question 1: After Generated exe file is executed, a QmSendMessage.tlb file will be generated in the dll directory. How to disable it?

 Question 2: I need to run QM first, how to automatically run QM when calling function

______________________________________________________________________________


How written the code in the Macro vbs call qm2 (??? s1 ???) 

Question 1: The code of the QM function in the VBS code, how to run it using QM when calling

Question 2: If the code of the QM function is in a txt file, how to use QM to run it when called





Macro vbs call qm1
Code:
Copy      Help
RegisterNetComComponent "$qm$\QmSendMessage.dll" 2|4

str vbs=
;set q = CreateObject("QmSendMessage.QMSM")
;q.Run "Q ^ M ^Func1^", true

VbsExec vbs


Function Func1
Code:
Copy      Help
mes "Hello, I am in QM"


Macro vbs call qm2
Code:
Copy      Help
RegisterNetComComponent "$qm$\QmSendMessage.dll" 2|4

str vbs=
;set q = CreateObject("QmSendMessage.QMSM")
;Dim s1 = "mes ""Hello, I am from Vbs"""
;q.Run "Q ^ M ^??? s1 ???^", true

VbsExec vbs
#11
I created a run.bat file on the desktop with the following contents. In addition, the desktop also has a Macro2.qml file.

I double-click running run.bat can't support running macros, It will open the macro view dialog

how should I write code? The following image is a description of the QM help file:


_______________________________________________________________________

start "C:\Program Files (x86)\Quick Macros 2\qmcl.exe" "C:\Users\Administrator\Desktop\Macro2.qml"

pause


Attached Files Image(s)
       
#12
I tried a lot of methods, only calling the functions inside QM can succeed.

I hope someone can provide a way to run the external .qml file directly, thank you very much. Smile
#13
Cannot run .qml files or functions from external .qml files.

For other questions, need some changes in the C# code, and compile it with Visual Studio.
#14
Thank you for your reminder Heart

I have a question, how do I get the variable i2 from the QM to the VBS code?

Macro Macro2
Code:
Copy      Help
RegisterNetComComponent "$qm$\QmSendMessage.dll" 2|4
str vbs=
;set q = CreateObject("QmSendMessage.QMSM")
;q.Run "Q ^ MS ^Fun5^ C 1", true
;msgbox i2

VbsExec vbs
out "---"

Function Fun5
Code:
Copy      Help
int i=5
int i2=i+val(_command)
mes i2
#15
Write it in a file or registry, and let the VBS code read it from there.
#16
How to send a message to QM from autohotkey, I use the following code, no effect

MyVar:="M ''Macro2''"
SendMessage, 0xC, 0, &MyVar, QM_Editor

I don't understand how to send a message to QM in AHK. The above code is wrong. Undecided Can you guide me? thanks 

The following is the documentation

https://www.autohotkey.com/docs/commands...essage.htm

 A string may be sent via wParam or lParam by specifying the address of a variable. The following example uses the address operator (&) to do this:
SendMessage, 0xC, 0, &MyVar, ClassNN, WinTitle ; 0XC is WM_SETTEXT
#17
I am using the following code, can't succeed, why? Huh

AHK Format:
SendMessage, Msg , wParam, lParam, Control, WinTitle, WinText, ExcludeTitle, ExcludeText, Timeout

code:
1.
SendMessage, 0xC , 1, "M ''Macro2''", ahk_class QM_Editor, Quick Macros - Main - [Macro2]

2.
MyVar:="M ''Macro2''"
SendMessage, 0xC , 1, &MyVar, ahk_class QM_Editor, Quick Macros - Main - [Macro2]
#18
Has been successfully called, using dll  Smile

q := ComObjCreate("QmSendMessage.QMSM")
q.Run("Q ^ M ^Func2^")


Forum Jump:


Users browsing this thread: 4 Guest(s)