P.I. Engineering User Forum

Product Support, Technical Questions and Answers, and Examples for P.I. Engineering Products

You are not logged in.

#1 2016-12-15 05:30:22

Registered: 2016-12-15
Posts: 1

VB .Net Clipboard Control

My name is Nathanael and I have been using the XKeys 24 product for almost 3 years now and I absolutely love it.

I do have a question though that has been plaguing me almost since I began.

The MW3 script does have methods for getting and setting clipboard text, which generally work just great.
(There was one release I downloaded where either the GetClipboardText or SetClipboardText method did not work, and after exploring it in Visual Studio's object browser I believe the problem was that the word "Text" was left off, this has since been rectified.)

Anyways, one of the first things I did when I started messing with the MW3 VB Script was that I tried to call
and print out what it received in a MsgBox, however it came up blank.
Over the years, I return to this about every 3-6 months and spend a day on it trying to figure out why this, as well as
all return blank.

I could be wrong, but I don't think that any of the clipboard functions work outside of the MW3 get and set methods, meaning that the GetDataObject and such also return blank values, I know that the Set methods for each of those do not work either.

This is me giving up at trying to solve this on my own. I'm mostly just curious as to why they don't work, but I also wonder if there is
any other .net functionality that doesn't work inside the MW3 setting.

My best guess is that it has to do with threading, and that's based off of other forums where users had intermittent issues with
clipboard commands.

It really isn't a huge deal, again, since you have the get and set built into MW3, I'm mostly just curious. Although, if there is anything
else effected by this in the script it would be nice to know as well.

Last edited by FusionNM (2016-12-15 05:36:08)


#2 2016-12-15 09:08:04

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196

Re: VB .Net Clipboard Control

Most likely those calls don't work because simply calling the method isn't enough; you probably need to also import in the Windows-provided DLL for that functionality. To see what DLL imports look like in our system, check out the RailDriver "Train Simulator" script which shows it in action. I also believe information on this was added to our Advanced Help file and will be in the next version.

Here's another example I just found on my PC from a script where we were capturing the mouse location:

'=↓=↓=↓= Initialize Variables Start =↓=↓=↓=↓=↓=↓=↓=↓=[MWTAG3]
    Dim MW3 As Interfaces.MW3
    Dim MyDevice As Integer() = {1029, -1, 1} 'Device Descriptor [MWTAG8]
    Dim AppName As String = "" 'Active application name
    Dim AppTitle As String = "" 'Active application title
    Dim Layer_Red As Integer = 0 'Red,3
    Public Structure POINTAPI
        Public x As Integer
        Public y As Integer
    End Structure
    <DllImport("user32.dll")> _
    Public Shared Function GetCursorPos(ByRef lpPoint As POINTAPI) As Integer
    End Function
    Dim p As New POINTAPI()
'=↑=↑=↑= Initialize Varibles End  =↑=↑=↑=↑=↑=↑=↑=↑=↑=[/MWTAG3]
    Public Sub Initialize(MW3 As Interfaces.MW3) Implements Interfaces.IScript.Initialize
        Me.MW3 = MW3
    End Sub
    Public Sub ScriptLoad() Implements Interfaces.IScript.ScriptLoad
        MW3.SetAllBacklightLED(MyDevice,1,0) ' Turn red off
        MW3.SetAllBacklightLED(MyDevice,0,1) ' Turn blue on
        MW3.SetBacklightIntensity(MyDevice,255,255) 'blue and red max intensity
        Dim dllpaths As String()={"C:\Windows\System32\"}

    End Sub

Amber from P.I. Engineering


Board footer

Powered by FluxBB