Jump to content

Recommended Posts

Posted

  On 3/21/2011 at 10:29 PM, 'JCarson said:

Out of morbid curiosity, has anyone attempted to connect to and OPC server using this code?

To my knowledge OPC is an automation protocol for field hardware and has no relation to DDE... However, many OPC drivers offer DDE control interface, those can be most certainly handled through DDEML. Very often such OPC drivers give you COM or .NET API as well, which raises the question "Why bother with DDE then?" All in all OPC stuff is extremely vendor specific.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

  • 3 weeks later...
Posted

  On 2/24/2009 at 3:51 PM, 'byseob said:

but, i can't understand the DDE Server Advise looping mechanism..

..

so i need "Advise looping about AutoIT3 DDE Server Example Source.. using DDEML.au3 UDF.

I also have the same question..

Read many times in MSDN, but still not understand how to do that!

and tried many times,all fail.. :)

have someone can give a sample?

thanks

Posted

Is there any reason why a DDE request would be refused? My 2500-line script works fine for about 5 minutes, then consistently stops receiving DDE responses.

_DdeConnect(0x0000C000, 0x0000C028)=0x6C684D80

_DdeClientTransaction(Int32, 0)

_DdeDisconnect(0x6C684D80)=1

which then turns into

_DdeConnect(0x0000C000, 0x0000C001)=0x00000000

_DdeClientTransaction(Int32, 0)

_DdeDisconnect(0)=0

Now, in the original configuration I *am* pounding a DDE server with 120 requests every second. When I reduce this to 120 requests every three seconds, the same happens, although I'm not sure if it takes exactly as long. But where is the limitation?

Posted

This is the exact transition point between works and fails. As you can see, there's no apparent error message, instead it looks like the server starts ignoring requests. I've already delayed the data request intensity by another few seconds, so am not sure what the problem is now.

_DdeConnect(0x0000C000, 0x0000C029)=0x3496CD80

_DdeClientTransaction(Int32, 0)

_DdeConnect(0x0000C000, 0x0000C029)=0x00000000

_DdeClientTransaction(Int32, 0)

Posted (edited)

Solution found (not sure any more what the problem was though)

I've added a _DdeUninitialize() in addition to the _DdeDisconnect($hConvSrv) which was already there. I didn't think this would be necessary, but apparently there's a leak somewhere? Tested this by pounding the DDE server with 1000+ requests per second for a long time, which didn't give any problems.

Edited by FF255
  • 10 months later...
Posted

Hi!

Could you please give me an example on how to implement asynchronous transactions to receive a value from DDE server in real time?

Thanks in advance

Posted

As far as i understood MSDN docs, i have to use something like Local $hData = _DdeClientTransaction($XTYP_ADVSTART, $hConv, $TIMEOUT_ASYNC, 10000, $hszItem, $wFmt), but could you explain me how to

1. At program start: establish connection with DDE server in asynchronous mode

2. Continuously receive a value of a specific Service-Topic-Item from DDE server and store it into a variable

3. At program end (e.g. closing a form) disconnect from DDE Server in a proper way

  • 2 years later...
Posted

Hey guys,

I have a few examples of DDE for a program (BMC Remedy) in other languages, and I even wrote a really small DDE execute app in C++, but I can't figure out what I'm doing wrong here.

Global $oRemedyServer
Global $fieldVauleList
Global $entryListFieldList
Global $g_eventerror = 0
Global $hConvSrv = 0

_DdeInitialize("", $APPCMD_CLIENTONLY)
$hszService = _DdeCreateStringHandle("ARUSER-SERVER")
$hszTopic = _DdeCreateStringHandle("DoExecMacro")

$hConvSrv = _DdeConnect($hszService, $hszTopic)
If 0 = $hConvSrv Then
    MsgBox(0, "DDE Client", "Failed to connect service")
Else
    MsgBox(0, "DDE Client", "Connected")
        _DDEMLClient_Execute($hszService, $hszTopic, "[RunMacro(C:\temp,Wood)]")
;~         Local $stData
;~         If _DDEML_CreateDataStruct("[RunMacro(C:\temp,Wood)]", $stData) Then
;~             Local $hData = _DdeCreateDataHandle($stData)
;~             $res = _DdeClientTransaction($XTYP_EXECUTE, $hConvSrv, $hData, 60000)
;~             $stData = 0
;~         EndIf
    If 0 <> $hszService Then _DdeFreeStringHandle($hszService)
    If 0 <> $hszTopic Then _DdeFreeStringHandle($hszTopic)
EndIf

It always tells me its not connected to the server.  The examples coming straight out of the helpfile are:

Word macro
Sub MAIN
RunMacroString$ = "[RunMacro(C:appmacro,Send Message,Name=John
Smith,Contents=Don’t forget our meeting on Friday)]"
channelNumber = DDEInitiate("ARUSER-SERVER", "DoExecMacro")
DDEExecute channelNumber, RunMacroString$
DDETerminate channelNumber
End Sub

Visual Basic macro
Private Sub cmdExecute_Click()
Dim RunMacroString As String
' Application|Topic
txtMacroPath.LinkTopic = "ARUSER-SERVER|DoExecMacro"
txtMacroPath.LinkMode = 2
RunMacroString = "[RunMacro("C:appmacro,SendMessage,Name=John
Smith,Contents=Don’t forget our meeting on Friday)]"
txtMacroPath.LinkExecute RunMacroString 'send DDE message
End Sub

My C++ app uses a dll call, but I would expect the service and topic to be the same:

DdeClient client = new DdeClient("ARUSER-SERVER", "DoExecMacro");
            //Console.WriteLine("new client");
            // Connect to the server.  It must be running or an exception will be thrown.
            client.Connect();
            //Console.WriteLine("client connect");
            // Synchronous Execute Operation
            string mycommand = "[RunMacro(C:temp,Wood)]";
            //Console.WriteLine("string");
            client.Execute(mycommand, 60000);
            //Console.WriteLine("execute");
            client.Disconnect();

Any ideas where I'm going wrong?  I'm trying to use DDE to run Remedy Macros that have parameters.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
  • 5 months later...
Posted
  On 9/5/2014 at 12:47 PM, someone said:

 

...It always tells me its not connected to the server.  The examples coming straight out of the helpfile are:...

Any ideas where I'm going wrong?  I'm trying to use DDE to run Remedy Macros that have parameters.

 

Sorry for late answer: this forum doesn't allow permanent subscriptions and I have no time for monitoring all topics.

In case help still needed:

First of all in order to use DDE communication your DDE server application must be up and running, Windows won't start it for you. Also, both client and server must be running in the same security context (unless NetDDE is involved, which is a science in itself), i.e. a server running as system service or with high privileges (Administrator) are not allowed to answer DDE calls from user land.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE 

Posted

Hey doudou,

Thanks a lot for the response.  Funny I haven't been on the forums regularly in a while and just happened to stop in the last week or so.  I ended up going a different route, to be honest I have to revisit what didn't work and put it into context of what you said to see if that helps me get anywhere.

In case anyone runs into the same thing, I was trying to automate a BMC Remedy Macro where you need to supply arguments.  So say I setup a macro to look for a ticket # based on a client name, you are supposed to be able to run the macro and give it John Doe and have it silently run the macro.

The DDE interface for Remedy is deprecated but everything I read and tried seems they broke the COM interface for this function.  I can run macros that do not require parameters, but not anything with.

Turns out someone at work had a working DDE C++ code, so I stole adopted that and it did work...except there was a character limit, and its really low.  I couldn't run half the macros I wanted.

So I ended up with 2 different workarounds...I'm just automating the keystrokes to run the macro against the Remedy window (which actually works ALOT better then I thought that it would).

Back to using a COM wrapper created to provide better functionality then what BMC offers. 

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
  • 1 year later...
Posted

Hi, i cannot download this files, this is error:

Sorry, there is a problem
The page you requested does not exist
Error code: 2S100/6

please repost! thanks

Posted

Thanks Danp2, but the au3_ddeml_samples_1.5.3.zip is same of au3_ddeml_1.5.4.zip, is erroneous posted? I need the samples.. Regards

  • 5 months later...
  • 5 months later...
  • 1 year later...
Posted

I start learn python - to be able help my 9 years old son, on his lesson.
Of course I was interested how to exchange data beetwen Python and AutoIt

DDE is one of solution:
https://stackoverflow.com/questions/28931475/get-data-via-dde-in-python-by-bypassing-excel

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 month later...
Posted (edited)

Hello.

I have 2 questions:

1) in registers under ddeexec key for .dwg files (for AutoCAD) says

[open("%1")]

Do I need to enclose the command in square brackets?

2) for some reason when I try use something like this:

#include <DDEML.au3>
#include <DDEMLClient.au3>
$hData = _DDEMLClient_Execute("AutoCAD.r15.DDE", "system", 'open("D:\\test.dwg")')
ConsoleWrite("_DDEMLClient_Execute()=" & $hData & ", error=" & @error & ", extended=" & @extended & @CRLF)

It returns in console:

  Quote

_DdeInitialize()=0, pid=16777344
_DdeConnect(0x0000C000, 0x0000C001)=0x02000580
_DdeClientTransaction(Ptr, -1)
_DdeDisconnect(0x02000580)=1
_DdeUninitialize()=1
_DDEMLClient_Execute()=0x00000001, error=0, extended=0

Expand  

Which looks fine, but AutoCAD shows bunch of question marks:

??????????

Is it possible that DDEML converts the command into UTF16 and AutoCAD 2002 doesn't support it? If so, is there a way send command in ASCII?

 

Thank you.

 

[EDIT]

Answering my own questions:

1) yes, it must be enclosed in square brackets.

2) turned out it's the opposite, it was sending as plain text, but required in unicode format.

My solution was to add 4th parameter in _DDEMLClient_Execute function:

Func _DDEMLClient_Execute($szService, $szTopic, $szCommand, $wFmt = $CF_TEXT)
    Local $res = 0
    Local $dwRes = _DdeInitialize("", BitOR($APPCMD_CLIENTONLY, $CBF_SKIP_ALLNOTIFICATIONS))
    If $DMLERR_NO_ERROR <> $dwRes Then
        SetError($dwRes)
        Return $res
    EndIf

    Local $hszService = 0
    If 0 < StringLen($szService) Then $hszService = _DdeCreateStringHandle($szService)
    Local $hszTopic = 0
    If 0 < StringLen($szTopic) Then $hszTopic = _DdeCreateStringHandle($szTopic)

    Local $hConv = _DdeConnect($hszService, $hszTopic)
    If 0 <> $hConv Then
        Local $stData
        If _DDEML_CreateDataStruct($szCommand, $stData, $wFmt) Then
            Local $hData = _DdeCreateDataHandle($stData)
            $res = _DdeClientTransaction($XTYP_EXECUTE, $hConv, $hData)
            $stData = 0
        EndIf
        _DdeDisconnect($hConv)
    EndIf
    If 0 <> $hszService Then _DdeFreeStringHandle($hszService)
    If 0 <> $hszTopic Then _DdeFreeStringHandle($hszTopic)
    _DdeUninitialize()

    Return $res
EndFunc

And then use this:

#include <DDEML.au3>
#include <DDEMLClient.au3>
$hData = _DDEMLClient_Execute("AutoCAD.r15.DDE", "system", '[open("D:\test.dwg")]', $CF_UNICODETEXT)
ConsoleWrite("_DDEMLClient_Execute()=" & $hData & ", error=" & @error & ", extended=" & @extended & @CRLF)

(also no need escape backslashes in file path)

Edited by VAN0
Found solution
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...