How to start an external executable, size its main window, and place it where I want ? (1 Viewer)

amorosik

Member
Local time
Today, 16:47
Joined
Apr 18, 2020
Messages
378
I am trying, from vba code, to start Anydesk indicating a certain device Id to connect to
Something like that
c: \ programs \ anydesk.exe 123456789
And everything starts correctly, as expected
But it leaves where he wants it and as big as he wants it
Searching in the web site of the manufacturer I find that the commands to size the window just started and position it where you want, would also be provided, but only as options for the 'custom client'

https://support.anydesk.com/Custom_Client_Advanced_Options#Position_and_size_of_the_window

Instead I would like to do everything from vba code, then launch the connection with the client, size as I like, place where I like
The goal of the whole is to open the connection on 6-8 remote stations at the same time and keep them under control all together
As a parameter on the startup command line, it seems you can't (if you could tell me)
So I thought, "and I'll shoot you the command from outside"
Having the window handle just open, I think it is possible to give it position and size
Then the question is: how to start an external executable, size its main window, and place it where I want?
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:47
Joined
Feb 28, 2001
Messages
27,005
There are several ways to launch an exterior application, but unless the app cooperates with you by exposing its properties via automation (the Common Object Model or COM ideas, for example), the sizing and placement parts of your question are a lot tougher. You need to find the Window Handle, usually a property called HWND, for the external app's window because all sizing and placement properties will be reachable through the window handle. You might need to look up some stuff on window management but it is a matter of just finding the window and then adjusting its properties. That's not so difficult.

The first question, therefore, is whether this external thing you want to run has a .DLL file that lets you interact with it programmatically. If the answer is NO to that question, then you need to define a bunch of Windows API calls to allow you to scan the Windows task list (a.k.a. process list) until you find the window you wanted based on its name (or the name of the file it is running). This can be rather extensive.

The goal of the whole is to open the connection on 6-8 remote stations at the same time and keep them under control all together

I am not sure of how you actually mean this. Are you suggesting that there will be a central active process controlling the sessions? Windows might not like that because you appear to be reversing the roles of client and server when you do that. (I.e. the "control" arrow is pointing the wrong way.)
 

amorosik

Member
Local time
Today, 16:47
Joined
Apr 18, 2020
Messages
378
There are several ways to launch an exterior application, but unless the app cooperates with you by exposing its properties via automation (the Common Object Model or COM ideas, for example), the sizing and placement parts of your question are a lot tougher. You need to find the Window Handle, usually a property called HWND, for the external app's window because all sizing and placement properties will be reachable through the window handle. You might need to look up some stuff on window management but it is a matter of just finding the window and then adjusting its properties. That's not so difficult.

The first question, therefore, is whether this external thing you want to run has a .DLL file that lets you interact with it programmatically. If the answer is NO to that question, then you need to define a bunch of Windows API calls to allow you to scan the Windows task list (a.k.a. process list) until you find the window you wanted based on its name (or the name of the file it is running). This can be rather extensive.



I am not sure of how you actually mean this. Are you suggesting that there will be a central active process controlling the sessions? Windows might not like that because you appear to be reversing the roles of client and server when you do that. (I.e. the "control" arrow is pointing the wrong way.)

I think that

Code:
Dim intVal as Integer
intVal = ShellExecute(1, "open", eseguibile_teleassistenza, id_telefono, "", 1)
Call Sleep(200)

Dim nome_classe As String
nome_classe = GetClassName()
hWndTest = FindWindow(nome_classe, vbNullString)
If hWndTest > 0 Then
    Call SetWindowPos(hWndTest, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
    endif

can be a starting point
But i don't know how to retrive GetClassName()
 

Users who are viewing this thread

Top Bottom