Sendmessage documentation
- Mattotone
- Android Dev (Moderator)
- Posts: 1238
- Joined: 10 Jul 2007, 17:30
- FreeStyler Version: BETA
- I Use FreeStyler for: Just for the Fun of it.
Sendmessage documentation
New documentation for freestyler SendMessage and inbuilt TCP/IP server
You do not have the required permissions to view the files attached to this post.
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
-
- Knows how to turn Lights ON
- Posts: 4
- Joined: 21 Jun 2010, 14:48
- FreeStyler Version: 3.2.2
- I Use FreeStyler for: DJ
Re: Sendmessage documentation
So now my Application works fine, so I created a new example with c#. I created a class for communication with FreeSyler, so just add the dll to your application and use the functions. Its tested with FreeStyler 3.3.2 on 64bit OS
Maybe it will help somebody.
Maybe it will help somebody.
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace FSCommunicator
{
public class FreestylerCommunicator
{
[DllImport("User32.dll", CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar);
[DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SendMessageA")]
private static extern int SendMessage2(IntPtr hWnd, int msg, IntPtr wPar, COPYDATASTRUCT lparam);
[DllImport("User32.dll", EntryPoint = "FindWindowA")]
private static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
private IntPtr parent;
private IntPtr ThWnd;
private const int WM_COPYDATA = 0x4A;
private const int WM_USER = 0x400;
public struct COPYDATASTRUCT
{
public long dwData;
public long cbData;
public IntPtr lpData;
}
/// <summary>
/// creates an Instance of FreestylerCommunicator
/// </summary>
/// <param name="WindowHandle"></param>
public FreestylerCommunicator(IntPtr WindowHandle)
{
parent = WindowHandle;
refreshHandle();
}
/// <summary>
/// return an Pointer to the given Object
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
private static IntPtr VarPtr(object o)
{
System.Runtime.InteropServices.GCHandle GC =
System.Runtime.InteropServices.GCHandle.Alloc(o,
System.Runtime.InteropServices.GCHandleType.Pinned);
IntPtr ret = GC.AddrOfPinnedObject();
GC.Free();
return ret;
}
private bool refreshHandle()
{
ThWnd = FindWindow("ThunderRT6FormDC", "FS");
if (ThWnd != IntPtr.Zero) return true;
else return false;
}
/// <summary>
/// Sending Commands to FreeStyler
/// </summary>
/// <param name="wparam">CommandCode</param>
/// <param name="lparam">Value</param>
public bool SendCommand(int wparam, int lparam)
{
if (refreshHandle())
{
SendMessage(ThWnd, WM_USER, new IntPtr(wparam), new IntPtr(lparam));
return true;
}
return false;
}
/// <summary>
/// Sending Data to FreeStyler
/// </summary>
/// <param name="Functioncode"></param>
/// <param name="Length">Arraylength</param>
/// <param name="arrValues"></param>
public bool SendData(long Functioncode, long Length, Byte[] arrValues)
{
COPYDATASTRUCT cdCopyData;
cdCopyData.dwData = Functioncode; //see it in the docs (page 8 or 9)
cdCopyData.cbData = Length; //512
cdCopyData.lpData = VarPtr(arrValues);
if (refreshHandle())
{
SendMessage2(ThWnd, WM_COPYDATA, parent, cdCopyData);
return true;
}
return false;
}
}
}
You do not have the required permissions to view the files attached to this post.
- Mattotone
- Android Dev (Moderator)
- Posts: 1238
- Joined: 10 Jul 2007, 17:30
- FreeStyler Version: BETA
- I Use FreeStyler for: Just for the Fun of it.
Re: Sendmessage documentation
Code: Select all
using System;
using System.Runtime.InteropServices;
namespace FS_Go_Monkey
{
public class sendMessageClass
{
//COMPILE AS X86 otherwise pointers need changing
//For use with WM_COPYDATA and COPYDATASTRUCT
[DllImport("User32.dll")]
public static extern int SendMessage(int hWnd, int Msg, int wParam, ref COPYDATASTRUCT lParam);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int Msg, int wParam, int LParam);
[DllImport("user32.dll")]
static extern int FindWindow(string lpClassName, string lpWindowName);
private const int WM_USER = 0x400;
private const int WM_COPY = 0x4A;
private int freestylerConnected()
{
int ihandle = FindWindow(null, "FS");
return ihandle;
}
private static Int32 VarPtr(object o)
{
GCHandle GC = GCHandle.Alloc(o, GCHandleType.Pinned);
IntPtr ptr = GC.AddrOfPinnedObject();
GC.Free();
return ptr.ToInt32();
}
public struct COPYDATASTRUCT
{
public Int32 dwData;
public Int32 cbData;
[MarshalAs(UnmanagedType.I4)]
public Int32 lpData;
}
public void sendCHMessageFunction(byte[] DMXvalues, int functionCode)
{
COPYDATASTRUCT cds;
cds.dwData = functionCode;
cds.lpData = VarPtr(DMXvalues);
cds.cbData = DMXvalues.Length;
int hWnd = freestylerConnected();
if (hWnd != 0)
{
SendMessage(hWnd, WM_COPY, 0, ref cds);
}
}
public void sendMessageFunction(int command, int value)
{
int iHandle = freestylerConnected();
if (freestylerConnected() != 0)
{
SendMessage(iHandle, WM_USER, command, value);
}
}
}
}
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
- Mattotone
- Android Dev (Moderator)
- Posts: 1238
- Joined: 10 Jul 2007, 17:30
- FreeStyler Version: BETA
- I Use FreeStyler for: Just for the Fun of it.
Re: Sendmessage documentation
DLL for simple connection to Freestyler.
//use for sending dmx values and sequences etc
FreestylerConnection.sender.sendMessageFunction(byte[] message, int functionCode);
//use for commands such as blackout
FreestylerConnection.sender.sendCommandFunction(int command, int value)
//if not 0 then FS is connected
FreestylerConnection.sender.freestylerConnected() returns int
Commands can be found in SendMessage documentation found in the FS directory
//use for sending dmx values and sequences etc
FreestylerConnection.sender.sendMessageFunction(byte[] message, int functionCode);
//use for commands such as blackout
FreestylerConnection.sender.sendCommandFunction(int command, int value)
//if not 0 then FS is connected
FreestylerConnection.sender.freestylerConnected() returns int
Commands can be found in SendMessage documentation found in the FS directory
You do not have the required permissions to view the files attached to this post.
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
- Mattotone
- Android Dev (Moderator)
- Posts: 1238
- Joined: 10 Jul 2007, 17:30
- FreeStyler Version: BETA
- I Use FreeStyler for: Just for the Fun of it.
Re: Sendmessage documentation
Here is a visual studio2010 example project
You do not have the required permissions to view the files attached to this post.
Freestyler Addons www.120db.uk
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024
Free Dropbox. 2GB account http://db.tt/J4c5G8C
$100 free credit @DigitalOcean Private Server: https://m.do.co/c/5c4a7c7d6693
Freestyler Android App: https://play.google.com/store/apps/deta ... rts.fs1024