Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: MALA SDK and Autohotkey (send info to MALA and get info from MALA)  (Read 5350 times)

0 Members and 1 Guest are viewing this topic.

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 05:02:57 am
    • My personal forum
Ive just read the mala event pluging API pdf file.
We have this messages
Quote
MALAMSG_STOPBGMUSIC = WM_USER + 10;
MALAMSG_STARTBGMUSIC = WM_USER + 11;
MALAMSG_NEXTSONG = WM_USER + 12;
MALAMSG_PREVIOUSSONG = WM_USER + 13;
MALAMSG_SWITCHORIENTATION = WM_USER + 20;
MALAMSG_FLIPORIENTATION = WM_USER + 21;
MALAMSG_STARTSCREENSAVER = WM_USER + 30;
MALAMSG_STOPSCREENSAVER = WM_USER + 31;
MALAMSG_ONEUP = WM_USER + 40;
MALAMSG_ONEDOWN = WM_USER + 41;
MALAMSG_XUP = WM_USER + 42;
MALAMSG_XDOWN = WM_USER + 43;
MALAMSG_LETTERUP = WM_USER + 44;
MALAMSG_LETTERDOWN = WM_USER + 45;
MALAMSG_NEXTGAMELIST = WM_USER + 50;
MALAMSG_PREVIOUSGAMELIST = WM_USER + 51;
MALAMSG_NEXTEMULATOR = WM_USER + 52;
MALAMSG_PREVIOUSEMULATOR = WM_USER + 53;
MALAMSG_STARTGAME = WM_USER + 60;
MALAMSG_STARTRNDGAME = WM_USER + 61;
MALAMSG_QUITGAME = WM_USER + 62;
MALAMSG_EXIT = WM_USER + 70;
MALAMSG_SETLED = WM_USER + 80;
MALAMSG_ALLLEDON = WM_USER + 81;
MALAMSG_ALLLEDOFF = WM_USER + 82;
MALAMSG_RESETLEDSTATE = WM_USER + 83;
MALAMSG_LOADHOTLIST = WM_USER + 90; // NOT USED ... Yet
MALAMSG_MAINSETFOCUS = WM_USER + 91; // NOT USED ... Yet
MALAMSG_ROTATE0 = WM_USER + 93;
MALAMSG_ROTATE90 = WM_USER + 94;
MALAMSG_ROTATE180 = WM_USER + 95;
MALAMSG_ROTATE270 = WM_USER + 96;

I want from an autohotkey script to send a message to MALA. Is this possible?
I've this script
Code: [Select]
k::
WinWait MaLa
MALAMSG_QUIT = WM_USER + 40
SendMessage, MALAMSG_QUIT
SendMessage, MALAMSG_QUIT,0,0,MaLa
SendMessage, MALAMSG_QUIT,0,0,0,MaLa
SendMessage, MALAMSG_QUIT,0,0,0,0,MaLa
SendMessage, MALAMSG_QUIT,0,MaLa
PostMessage, MALAMSG_QUIT,0,0,MaLa
MsgBox test
return

I run the script.
I run MALA with my list.
Press the k key and I can see the test message in my windows but nothing occurs in MALA.

Any idea?

Sorry for my bad english.
« Last Edit: January 21, 2015, 09:06:31 am by empardopo »

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 05:02:57 am
    • My personal forum
Re: MALA SDK and Autohotkey
« Reply #1 on: January 20, 2015, 09:03:20 am »
1.- Is It possible to send messages to MALA from an Autohotkey exe or another exe file?
2.- Anybody know the value of WM_USER?

Thanks
« Last Edit: January 20, 2015, 09:46:39 am by empardopo »

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9269
  • Last login:Today at 07:12:10 am
  • ...
Re: MALA SDK and Autohotkey
« Reply #2 on: January 20, 2015, 10:36:21 am »
That stuff is over my head, but if fake key pressed don't work in Mala for the same reasons that it doesn't work with MAME, you might try sending fake gamepad presses.
Of course you'd need to have a fake gamepad installed via Headkaze's vjoy or similar program.  That would make it hard to incorporate into your program.

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 05:02:57 am
    • My personal forum
Re: MALA SDK and Autohotkey
« Reply #3 on: January 21, 2015, 03:35:30 am »
This is the code of MalaMessages.exe
Code: [Select]
unit main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

const

     // MaLa Messages
     MALAMSG_STOPBGMUSIC = WM_USER + 10;
     MALAMSG_STARTBGMUSIC = WM_USER + 11;
     MALAMSG_NEXTSONG = WM_USER + 12;
     MALAMSG_PREVIOUSSONG = WM_USER + 13;

     MALAMSG_SWITCHORIENTATION = WM_USER + 20;
     MALAMSG_FLIPORIENTATION = WM_USER + 21;

     MALAMSG_STARTSCREENSAVER = WM_USER + 30;
     MALAMSG_STOPSCREENSAVER = WM_USER + 31;

     MALAMSG_ONEUP = WM_USER + 40;
     MALAMSG_ONEDOWN = WM_USER + 41;
     MALAMSG_XUP = WM_USER + 42;
     MALAMSG_XDOWN = WM_USER + 43;
     MALAMSG_LETTERUP = WM_USER + 44;
     MALAMSG_LETTERDOWN = WM_USER + 45;

     MALAMSG_NEXTGAMELIST = WM_USER + 50;
     MALAMSG_PREVIOUSGAMELIST = WM_USER + 51;
     MALAMSG_NEXTEMULATOR = WM_USER + 52;
     MALAMSG_PREVIOUSEMULATOR = WM_USER + 53;

     MALAMSG_STARTGAME = WM_USER + 60;
     MALAMSG_STARTRNDGAME = WM_USER + 61;
     MALAMSG_QUITGAME = WM_USER + 62;

     MALAMSG_EXIT = WM_USER + 70;

     MALAMSG_SETLED = WM_USER + 80;
     MALAMSG_ALLLEDON = WM_USER + 81;
     MALAMSG_ALLLEDOFF = WM_USER + 82;
     MALAMSG_RESETLEDSTATE = WM_USER + 83;

     MALAMSG_LOADHOTLIST = WM_USER + 90;

     MALAMSG_MAINSETFOCUS= WM_USER + 91;

     MALAMSG_ROTATE0= WM_USER + 93;
     MALAMSG_ROTATE90= WM_USER + 94;
     MALAMSG_ROTATE180= WM_USER + 95;
     MALAMSG_ROTATE270= WM_USER + 96;

type
  TfrmMain = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button17: TButton;
    Button18: TButton;
    Button19: TButton;
    Button20: TButton;
    Button21: TButton;
    Button22: TButton;
    Button15: TButton;
    Button16: TButton;
    edtLEDNr: TEdit;
    Label1: TLabel;
    cbxLEDOnOff: TCheckBox;
    Button23: TButton;
    Button24: TButton;
    Button25: TButton;
    Button26: TButton;
    Button27: TButton;
    Button29: TButton;
    Button28: TButton;
    Button30: TButton;
    Button31: TButton;
    Button32: TButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);
    procedure Button15Click(Sender: TObject);
    procedure Button19Click(Sender: TObject);
    procedure Button20Click(Sender: TObject);
    procedure Button21Click(Sender: TObject);
    procedure Button22Click(Sender: TObject);
    procedure Button17Click(Sender: TObject);
    procedure Button18Click(Sender: TObject);
    procedure Button16Click(Sender: TObject);
    procedure Button23Click(Sender: TObject);
    procedure Button24Click(Sender: TObject);
    procedure Button25Click(Sender: TObject);
    procedure Button26Click(Sender: TObject);
    procedure Button27Click(Sender: TObject);
    procedure Button28Click(Sender: TObject);
    procedure Button29Click(Sender: TObject);
    procedure Button30Click(Sender: TObject);
    procedure Button31Click(Sender: TObject);
    procedure Button32Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.DFM}

{*******************************************************************************
* BoolToInt
*******************************************************************************}
function BoolToInt(ABoolean: Boolean): Integer;
begin
    Result := 0;
    case ABoolean of
    true: Result := 1;
    false: Result := 0;
    end;
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
     SendMessage(FindWindow(nil,'MaLa'), MALAMSG_STOPBGMUSIC, 0, 0);
end;

procedure TfrmMain.Button2Click(Sender: TObject);
begin
     SendMessage(FindWindow(nil,'MaLa'), MALAMSG_STARTBGMUSIC, 0, 0);
end;

procedure TfrmMain.Button3Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_SWITCHORIENTATION, 0, 0);
end;

procedure TfrmMain.Button4Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_FLIPORIENTATION, 0, 0);
end;

procedure TfrmMain.Button5Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_STARTSCREENSAVER, 0, 0);
end;

procedure TfrmMain.Button6Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_STOPSCREENSAVER, 0, 0);
end;

procedure TfrmMain.Button7Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_NEXTSONG, 0, 0);
end;

procedure TfrmMain.Button8Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_PREVIOUSSONG, 0, 0);
end;

procedure TfrmMain.Button9Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ONEUP, 0, 0);
end;

procedure TfrmMain.Button10Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ONEDOWN, 0, 0);
end;

procedure TfrmMain.Button11Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_XUP, 0, 0);
end;

procedure TfrmMain.Button12Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_XDOWN, 0, 0);
end;

procedure TfrmMain.Button13Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_LETTERUP, 0, 0);
end;

procedure TfrmMain.Button14Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_LETTERDOWN, 0, 0);
end;

procedure TfrmMain.Button15Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_QUITGAME, 0, 0);
end;

procedure TfrmMain.Button19Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_NEXTEMULATOR, 0, 0);
end;

procedure TfrmMain.Button20Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_PREVIOUSEMULATOR, 0, 0);
end;

procedure TfrmMain.Button21Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_NEXTGAMELIST, 0, 0);
end;

procedure TfrmMain.Button22Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_PREVIOUSGAMELIST, 0, 0);
end;

procedure TfrmMain.Button17Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_STARTGAME, 0, 0);
end;

procedure TfrmMain.Button18Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_EXIT, 0, 0);
end;

procedure TfrmMain.Button16Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_STARTRNDGAME, 0, 0);
end;

procedure TfrmMain.Button23Click(Sender: TObject);
begin

     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_SETLED, StrToInt(edtLEDNr.Text), BoolToInt(cbxLEDOnOff.Checked));
end;

procedure TfrmMain.Button24Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ALLLEDOFF, 0, 0);
end;

procedure TfrmMain.Button25Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ALLLEDON, 0, 0);
end;

procedure TfrmMain.Button26Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_RESETLEDSTATE, 0, 0);
end;

procedure TfrmMain.Button27Click(Sender: TObject);
begin
       PostMessage(FindWindow(nil,'MaLa'), MALAMSG_LOADHOTLIST, 0, 0);
end;

procedure TfrmMain.Button29Click(Sender: TObject);
begin
    PostMessage(FindWindow(nil,'MaLa'), MALAMSG_MAINSETFOCUS, 0, 0);
end;


procedure TfrmMain.Button28Click(Sender: TObject);
begin
     PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ROTATE0, 0, 0);
end;


procedure TfrmMain.Button30Click(Sender: TObject);
begin
 PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ROTATE90, 0, 0);
end;

procedure TfrmMain.Button31Click(Sender: TObject);
begin
 PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ROTATE180, 0, 0);
end;

procedure TfrmMain.Button32Click(Sender: TObject);
begin
 PostMessage(FindWindow(nil,'MaLa'), MALAMSG_ROTATE270, 0, 0);
end;

end.


MalaMessages.exe doesn't use fake gamepad presses, doesn't it? On it, if you press a button then send the message...
I don't know what is WM_USER? What value must has it?

Thanks in advance.

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 05:02:57 am
    • My personal forum
Re: MALA SDK and Autohotkey
« Reply #4 on: January 21, 2015, 05:48:34 am »
From his link I have assumed that the value of WM_USER was 0x0400.

At this point, I tested with different postmessages sentences and YES!!!! I did it!!!

Here, my source script using Autohotkey
Code: [Select]
global WM_USER,MALAMSG_ONEUP,MALAMSG_ONEDOWN,MALAMSG_FLIPORIENTATION,MALAMSG_ROTATE0,MALAMSG_ROTATE90,MALAMSG_ROTATE180,MALAMSG_ROTATE270

WM_USER := 0x0400
MALAMSG_STOPBGMUSIC := WM_USER + 10
MALAMSG_STARTBGMUSIC := WM_USER + 11
MALAMSG_NEXTSONG := WM_USER + 12
MALAMSG_PREVIOUSSONG := WM_USER + 13
MALAMSG_SWITCHORIENTATION := WM_USER + 20
MALAMSG_FLIPORIENTATION := WM_USER + 21
MALAMSG_STARTSCREENSAVER := WM_USER + 30
MALAMSG_STOPSCREENSAVER := WM_USER + 31
MALAMSG_ONEUP := WM_USER + 40
MALAMSG_ONEDOWN := WM_USER + 41
MALAMSG_XUP := WM_USER + 42
MALAMSG_XDOWN := WM_USER + 43
MALAMSG_LETTERUP := WM_USER + 44
MALAMSG_LETTERDOWN := WM_USER + 45
MALAMSG_NEXTGAMELIST := WM_USER + 50
MALAMSG_PREVIOUSGAMELIST := WM_USER + 51
MALAMSG_NEXTEMULATOR := WM_USER + 52
MALAMSG_PREVIOUSEMULATOR := WM_USER + 53
MALAMSG_STARTGAME := WM_USER + 60
MALAMSG_STARTRNDGAME := WM_USER + 61
MALAMSG_QUITGAME := WM_USER + 62
MALAMSG_EXIT := WM_USER + 70
MALAMSG_SETLED := WM_USER + 80
MALAMSG_ALLLEDON := WM_USER + 81
MALAMSG_ALLLEDOFF := WM_USER + 82
MALAMSG_RESETLEDSTATE := WM_USER + 83
;MALAMSG_LOADHOTLIST := WM_USER + 90 // NOT USED ... Yet
;MALAMSG_MAINSETFOCUS := WM_USER + 91 // NOT USED ... Yet
MALAMSG_ROTATE0 := WM_USER + 93
MALAMSG_ROTATE90 := WM_USER + 94
MALAMSG_ROTATE180 := WM_USER + 95
MALAMSG_ROTATE270 := WM_USER + 96

gui,add,button, x10 y10 gMSGOneUp,OneUp
gui,add,button, x60 y10 gMSGOneDown,OneDown
gui,add,button, x10 y40 gMSGFlip,Flip
gui,add,button, x60 y40 gMSGRotate0,Rotate to 0
gui,add,button, x150 y40 gMSGRotate90,Rotate to 90
gui,add,button, x60 y70 gMSGRotate180,Rotate to 180
gui,add,button, x150 y70 gMSGRotate270,Rotate to 270
Gui, Add, Link,x170 y110 vlinkForo, <a href="http://arcadespain.info">ArcadeSpain</a>
Gui, Add, Link,x35 y110, <a href="mailto:empardopo@gmail.com">empardopo@gmail.com</a>
gui, show, w250 h130, Send Messages to MALA
return

MSGOneUp:
EnviaOneUp()
return

MSGOneDown:
EnviaOneDown()
return

MSGFlip:
EnviaFlip()
return

MSGRotate0:
EnviaRotate0()
return

MSGRotate90:
EnviaRotate90()
return

MSGRotate180:
EnviaRotate180()
return

MSGRotate270:
EnviaRotate270()
return

EnviaOneUp(){
PostMessage, MALAMSG_ONEUP,,,, ahk_class TfrmMain
}
EnviaOneDown(){
PostMessage, MALAMSG_ONEDOWN,,,, ahk_class TfrmMain
}

EnviaFlip(){
PostMessage, MALAMSG_FLIPORIENTATION,,,, ahk_class TfrmMain
}
EnviaRotate0(){
PostMessage, MALAMSG_ROTATE0,,,, ahk_class TfrmMain
}
EnviaRotate90(){
PostMessage, MALAMSG_ROTATE90,,,, ahk_class TfrmMain
}
EnviaRotate180(){
PostMessage, MALAMSG_ROTATE180,,,, ahk_class TfrmMain
}
EnviaRotate270(){
PostMessage, MALAMSG_ROTATE270,,,, ahk_class TfrmMain
}

Esc::
GuiClose:
ExitApp

BadMouth, I have add code where you can rotate the MALA window :-)

And now, a new important question!
I can send messages to MALA from Autohotkey but Is It possible to get information from MALA? For example, I can know what game I have selected?

Thanks

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9269
  • Last login:Today at 07:12:10 am
  • ...
Re: MALA SDK and Autohotkey (send info to MALA and get info from MALA)
« Reply #5 on: January 21, 2015, 09:22:05 am »
Talking above my skill level again, but Mala passes the rom name on to command lines, batch files, or compiled ahk scripts as variable %1.
If I remember correctly, it doesn't work with ahk scripts until they are compiled to an exe.

%1 is the rom name, %2 is the path

SGT's all games in one list workaround takes advantage of this.

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: MALA SDK and Autohotkey (send info to MALA and get info from MALA)
« Reply #6 on: January 21, 2015, 09:32:47 am »
Sorry to take so long.

The issue with getting events from an AHK script is that you need to register a DLL with mala that exposes function entry points that mala calls when those events happen.

As far as I know, AHK can't do that, so I believe that'll be a non-start.

You could write a C+DLL that could be registered as a plugin to mala, then forward those events to an AHK script somehow.

In reality, that's kind of what Engine18 is, the main dll just intercepts those calls and turns then in to .net events that are far more easily consumed by .net apps.

But that won't help with AHK.

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 05:02:57 am
    • My personal forum
Re: MALA SDK and Autohotkey (send info to MALA and get info from MALA)
« Reply #7 on: January 21, 2015, 09:58:19 am »
Sorry to take so long.

The issue with getting events from an AHK script is that you need to register a DLL with mala that exposes function entry points that mala calls when those events happen.

As far as I know, AHK can't do that, so I believe that'll be a non-start.

You could write a C+DLL that could be registered as a plugin to mala, then forward those events to an AHK script somehow.

In reality, that's kind of what Engine18 is, the main dll just intercepts those calls and turns then in to .net events that are far more easily consumed by .net apps.

But that won't help with AHK.

I've just to see your answer and I had sended an email :-)
I have to check it your engine. I'll take a look.

Thanks.

Buick455

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 154
  • Last login:April 03, 2024, 03:24:29 pm
  • I MUSTA WRECKED IT!
Re: MALA SDK and Autohotkey (send info to MALA and get info from MALA)
« Reply #8 on: January 21, 2015, 03:45:14 pm »
Sorry to take so long.

Completely understandable, you were busy watching the season 6 special for the 3rd time like me...  :P