I'm trying to write a plugin with VB.NET that would get the telemetry data from GTR2.
There's a little application and an OCX version created by a guy that goes by the nick Nye. This application (and it's OCX version) grabs some data from GTR2's shared memory area, and you can use the OCX to write your own program.
First problem: the OCX seems to be event-driven. As I see, the Smartie plugin can't be made with it, because Smartie's calls to the DLL will never sync with the events. Then I made a small tray app that keeps receiving these events and updating the variables, but I couldn't get it to pass the values to another application (in this case, the Smartie DLL).
So the application now copies the data to the clipboard, and my Smartie DLL tries to read the clipboard.
Second problem: I can't get the plugin to get the data, sepparate the variables (they're sepparated with a "chr(124)") and return it as a string.
Even before the "return" statement, I get problems.
Here's my code:
Code: Select all
Try
Dim xData As Object = System.Windows.Forms.Clipboard.GetDataObject
Dim Dades As Array = Split(xData, Chr(124))
Dim dades2 As String = Dades(param1)
Return dades2
Catch ex As Exception
Return ex.Message
End Try
The funniest part is that I have this in my tray application (in the same function that handles the event. It copies to the clipboard, and right after, executes the same snippet as above, only instead of "return", it writes to a textbox):
Code: Select all
Try
Dim xData As Object = System.Windows.Forms.Clipboard.GetDataObject
Dim Dades As Array = Split(xData, Chr(124))
Dim dades2 As String = Dades(2)
Me.TextBox1.Text = dades2
Catch ex As Exception
Me.TextBox1.Text = ex.Message
End Try
Any suggestions?
Also, does anybody know of a simple yet efficient (and, why not, more ellegant) way to do true IPC instead of this clipboard workaround (without involving TPC/HTTP and network stuff - direct memmory-like)?
P.S.: The output from the clipboard is something like this: (I added some newlines because it would break the page layout, but it's a long single-lined string)
Player Name|38,28391|38,12056|2|1338,833|7999,751|1|1|49,97912|-1|0|-1|0|20,16783|20,20591|20,21888|20,21918
|20,20641|20,16698|20,17661|20,20854|20,20793|20,20847|20,20823|20,1764|168,0618|168,0618|168,0618
|168,0618|0|0|0|0|0|0|0|0|SilverstoneGP|0|4|0|0|0|0|21,44589|20|20,30797|20,30797|20,23023|20,23044|BMW M3 GTR|[/code]