@@ -47,35 +47,44 @@ This is automatically called for you on the {ref}`RemoteInput variable`.
4747procedure TRemoteInput.Setup();
4848var
4949 timer: TCountDown;
50+ window: TWindowHandle;
51+ pid: TProcessID;
5052begin
51- if GetSimbaTargetWindow().GetClassName() <> 'SunAwtCanvas' then Exit;
53+ {$IFDEF SIMBAHEADLESS}
54+ window := StrToInt(Target.ToString().Between('Handle=', ','));
55+ {$ELSE}
56+ window := GetSimbaTargetWindow();
57+ {$ENDIF}
58+
59+ if window.GetClassName() <> 'SunAwtCanvas' then
60+ Exit;
61+
62+ pid := window.GetPID();
5263
5364 try
54- RIInject(GetSimbaTargetPID() );
65+ RIInject(pid );
5566 except
5667 if GetExceptionMessage() = 'Access violation' then
5768 ErrorDialog(
5869 'RemoteInput',
5970 'A different RemoteInput has already been paired with this client.' +
6071 LINE_SEP + LINE_SEP + 'Please open a new one.'
61- )
62- else
63- raise GetExceptionMessage();
72+ );
73+ raise GetExceptionMessage();
6474 end;
6575
6676 timer.Start(2000);
6777 repeat
6878 try
69- Self.Target := EIOS_PairClient(GetSimbaTargetPID() );
79+ Self.Target := EIOS_PairClient(pid );
7080 except
7181 if GetExceptionMessage() = 'Access violation' then
7282 ErrorDialog(
7383 'RemoteInput',
7484 'A different RemoteInput has already been paired with this client.' +
7585 LINE_SEP + LINE_SEP + 'Please open a new one.'
76- )
77- else
78- raise GetExceptionMessage();
86+ );
87+ raise GetExceptionMessage();
7988 end;
8089
8190 if Self.Target <> nil then
@@ -90,12 +99,16 @@ begin
9099 end;
91100
92101 try
93- Target.SetPlugin({$MACRO LOADEDLIB(libremoteinput)}, ToStr(GetSimbaTargetPID() ), RSClient.Canvas);
102+ Target.SetPlugin({$MACRO LOADEDLIB(libremoteinput)}, ToStr(pid ), RSClient.Canvas);
94103 except
95104 if GetExceptionMessage() = 'Access violation' then
96- raise GetDebugLn('RemoteInput', 'A different RemoteInput has already been paired with this client. Please open a new one.')
97- else
98- raise GetExceptionMessage();
105+ ErrorDialog(
106+ 'RemoteInput',
107+ 'A different RemoteInput has already been paired with this client.' +
108+ LINE_SEP + LINE_SEP + 'Please open a new one.'
109+ );
110+
111+ raise GetExceptionMessage();
99112 end;
100113end;
101114
@@ -128,11 +141,19 @@ This is automatically called for you on the {ref}`WaspInput variable`.
128141*)
129142procedure TWaspInput.Setup();
130143var
144+ window: TWindowHandle;
131145 pid: TProcessID;
132146begin
133- if GetSimbaTargetWindow().GetClassName() <> 'JagRenderView' then Exit;
147+ {$IFDEF SIMBAHEADLESS}
148+ window := StrToInt(Target.ToString().Between('Handle=', ','));
149+ {$ELSE}
150+ window := GetSimbaTargetWindow();
151+ {$ENDIF}
152+
153+ if window.GetClassName() <> 'JagRenderView' then
154+ Exit;
134155
135- pid := GetSimbaTargetPID ();
156+ pid := window.GetPID ();
136157 Inject({$MACRO LOADEDLIB(waspinput)}, pid);
137158 Target.SetPlugin({$MACRO LOADEDLIB(waspinput)}, ToStr(pid), RSClient.Canvas);
138159 Self.Target := @pid;
0 commit comments