Access docker's buttons from other application

Hello,

I created a docker for X7 with two buttons.

It works fine. (Thanks to bonus630. Great project).

Please could you explain or point me to other previous topic about :

1. How to check from other application if the docker is installed?

2. How to start or close the docker from other application?

3. How to press one of the buttons from other application?

Thank you in advance

  • When you say 'other application' can it be any type of application?

    For instance, in the next VBS code, you can see how to solve the first two issues. Of course, you must know the docker guide.... In the following example I use my docker guide.

    If the guide does not belong to any installed docker the code does not return any error... You can find the guide in AppUI.xslt: (in bonus630   47 line): check="*Docker('f3f09ab3-a8b6-4400-9152-62ffbe93ecb5')"

    dim drawApp, Found
    Set drawApp = CreateObject("CorelDraw.Application")
    
    drawApp.Framework.ShowDocker "f3f09ab3-a8b6-4400-9152-62ffbe93ecb5"
    if drawApp.FrameWork.IsDockerVisible("f3f09ab3-a8b6-4400-9152-62ffbe93ecb5") = true then
      msgbox "Docker installed"
      Found = true
    else
      msgbox "Docker not installed"
    end if
    if Found then drawApp.FrameWork.HideDocker "f3f09ab3-a8b6-4400-9152-62ffbe93ecb5"
    
    set drawApp = nothing
    

    Pressing the buttons is a little more difficult...

    • Thank you, FaneDuru,
      The "other application"(controlling) is c# console program driving a few instances of CorelDraw. One is a server and the rest are clients. Server and clients are implemented as two dockers.They have intercommunication via TCP.
      The controlling application starts all the instances of CorelDraw using Process class.
      I tried to obtain COM object from Process variable, but without success .
      If anybody has experience with that, please share.
      • What did you succeed to do up to now?  Do you have client and server already defined?

        In principle, I think you shouldn't bother about the COM... If you make a server on a docker and a client on the other and they are able to communicate you do not need something else. I mean it is only necessary to define the sent messages and translate them on the receiver in whatever you wont. To press buttons, to send messages, populate list boxes, etc. For instance, if you send the character "A" and client is 'instructed' when receive it to press a specific button why the problem will not be solved? In order to be relevant you can send the button name_press. Just text...

        You just have to take care that the client must listen on a specific port and the server must connect on that specific port for the known IP. If that IP is not internal and try to connect through internet, your router must forward it...

        But can you tell me why this need? Is it just a way to experiment and learn, or you really need such an application? Otherwise you may use TeamViewer and take al the screen... I do not have two computers having Corel installed in a network at home and, if I will find time, I will try such an experiment at the office. Just for the sake of experimenting and learning...

        On internet there are a lot of code samples to build client and server application. I would suggest the server/client like different classes and the rest of the docker project like it is now, just using the class for connection...

        • Thank you, FaneDuru
          The task is to build multi machine processing of large data.
          I established on one machine server and client and they are working well till now .
          The data is growing up and I decided to use multi machine scenario.
          I have client and server dockers. They are communicating well for data processing.
          The problem is when I start computers and CorelDraw applications.
          Only one has to be server-docker over whole lan.
          On the same machine could work and a few clients and on the other machines the rest of clients.
          On the "client-only" machines I will install only "client docker" .If the docker is loaded when closing Corel app all is fine.
          The helper (other C# application) start Corels using Process class and the dockers can get control.
          On the mixed server-client-docker machine on one of the Corels I have manually to close client docker and start server docker and then I have full scenario running.
          I would like to automate the process of starting the scenario even in case if I forget to close the server docker or forget to open client in closing the last CorelDraw application.
          • Can you explain how the scenario works well when the docker is loaded at Corel closing? Do you have a closing/unloaded event doing something when Corel closes?

            If nothing confidential can you post the client/server code? Or to send those projects on my public mail (in my profile...)? I will try some tests on the problem you have.

            Firstly, without knowing how/why all go well when the docker is loaded I would suggest using of MacroStorage QueryQuit event in order to load the docker if not loaded already. I would like to suggest the next VBA code. The code can be written on the fly by C# application and if you test and it looks to be a viable solution I will show you how can that be done:

            Private Sub GlobalMacroStorage_QueryQuit(Cancel As Boolean)
                If Application.FrameWork.IsDockerVisible("f3f09ab3-a8b6-4400-9152-62ffbe93ecb5") = False Then
                     Application.FrameWork.ShowDocker "f3f09ab3-a8b6-4400-9152-62ffbe93ecb5"
                End If
            End Sub
            

            Of course, you must use your docker guide. I am afraid that if your good scenario involves the docker unloaded event it will not be triggered when Corel quits...

            How can be the docker controlled by that 'helper application'? Is it used only for Corel application start or it does something for that mentioned controlling?

            When you say that for having a good scenario 'On the mixed server-client-docker machine on one of the Corels I have manually to close client docker and start server docker' why that problem? Can't you use Loaded event of server docker and this one to be start by a Corel QueryQuit event?

            • Thank you, FaneDuru for going deep into my problem and I apologize for my English.
              1. When I close Corel it saves configuration with loaded client docker and unloaded server docker. On the next starts of Corel instances Process class uses this configuration and loads all configurations as clients. After that I open CorelDraw.Application COM object and for me it is chosen randomly. In COM object I can close client and start server docker. When they are started control is mine :-). and "scenario works well ".
              2. The suggestion to use QueryQuit event is excellent , I thing, I will use it. In addition I will clear an external flag (file or registry) and on the first instance of QueryQuit event the program will set it. All the rest will be clients. So thanks once again for the idea.
              3. External helper is only for preparing the network configuration of clients and server .

              • We did it !
                Now for stopping all Corel applications I use Process class in helper c# application.
                For controlling which machine to have a server Corel instance I need only to create a file
                ServerFlagFileName = "y:\ServerFlagFile.txt"
                Then again with Process class helper starts instances of CorelDraw.
                The macros is :


                Private Sub GlobalMacroStorage_Start()
                serverGUID = "533768c9-af16-4144-ba3e-520abed3fa47"
                clientGUID = "a2b2f5fc-defb-4371-88ab-7ce0ed8cb054"
                ServerFlagFileName = "y:\ServerFlagFile.txt"
                Set FSO = CreateObject("scripting.filesystemobject")
                If FSO.FileExists(ServerFlagFileName) = True Then
                FSO.deletefile (ServerFlagFileName)
                If Application.FrameWork.IsDockerVisible(clientGUID) = True Then
                Application.FrameWork.HideDocker clientGUID
                End If
                If Application.FrameWork.IsDockerVisible(serverGUID) = False Then
                Application.FrameWork.ShowDocker serverGUID
                End If
                Else
                If Application.FrameWork.IsDockerVisible(clientGUID) = False Then
                Application.FrameWork.ShowDocker clientGUID
                End If
                If Application.FrameWork.IsDockerVisible(serverGUID) = True Then
                Application.FrameWork.HideDocker serverGUID
                End If
                End If
                End Sub


                If somebody is interested I can post the c# code of the helper.
                The problem is solved following FaneDuru's recommendations , but the interest to control many CorelDraw applications as COM objects remains :-)