Borrar filtros
Borrar filtros

2 Different GUI needs the same inputs

3 visualizaciones (últimos 30 días)
Fabio
Fabio el 20 de Mzo. de 2023
Comentada: Rik el 21 de Mzo. de 2023
Hello, i have opened 2 different Matlab IDES that runs separately the same program, i need to start 2 equal programs in matlab that have 2 identical GUI interface, but i need them to read the same keyboards inputs and they do not, they only read it when i click on the GUI, is there a solution ?
  2 comentarios
chrisw23
chrisw23 el 21 de Mzo. de 2023
2 Matlab IDE's connected via NamedPipes can share data either on the same local machine or via network. Each GUI detects the keyboard input an sends a message to the other. The NamedPipe connection can be optional so that GUI instances may run independent, but the Srv/Client role has to be set (i.e. UserOption).
I set up a package with a Srv and a Client class. (example constructor code fragment)
function obj = PipeServer(pipeName)
import System.IO.Pipes.*
import WinNetIO.NamedPipes.*
NET.addAssembly("System.Core");
obj.PipeName = pipeName;
obj.pipeServerStream = NamedPipeServerStream(...
pipeName, ...
PipeDirection.InOut, ...
...
function obj = PipeClient(pipeName,pipeServer)
arguments
pipeName string
pipeServer string = "." % for local computer
end
import System.IO.Pipes.*
import WinNetIO.NamedPipes.*
% PipeName and Server
obj.PipeName = pipeName;
obj.PipeServerName = pipeServer;
NET.addAssembly('System.Core');
% client pipeStream object is opened in InOut mode
obj.pipeClientStream = System.IO.Pipes.NamedPipeClientStream(...
obj.PipeServerName,...
obj.PipeName,...
Rik
Rik el 21 de Mzo. de 2023
@chrisw23 This looks like an answer to me, especially if you slightly expand your post.

Iniciar sesión para comentar.

Respuestas (1)

Rik
Rik el 20 de Mzo. de 2023
There is no general solution to do this, because the two instances of Matlab are separate.
If Matlab were able to do this, it could function as a key logger.
A workaround would be to have the active GUI write the key presses to a file, which the non-active GUI can then read with a listener.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by