@@ -12,20 +12,14 @@ public class ExtPrograms : IWallpaper
12
12
{
13
13
public ExtPrograms ( string path , LibraryModel model , LivelyScreen display , int timeOut = 20 )
14
14
{
15
- string cmdArgs ;
16
- if ( model . LivelyInfo . Type == WallpaperType . unity )
17
- {
18
- //-popupwindow removes from taskbar
19
- //-fullscreen disable fullscreen mode if set during compilation (lively is handling resizing window instead).
20
- //Alternative flags:
21
- //Unity attaches to workerw by itself; Problem: Process window handle is returning zero.
22
- //"-parentHWND " + workerw.ToString();// + " -popupwindow" + " -;
23
- cmdArgs = "-popupwindow -screen-fullscreen 0" ;
24
- }
25
- else
26
- {
27
- cmdArgs = model . LivelyInfo . Arguments ;
28
- }
15
+ // Unity flags
16
+ //-popupwindow removes from taskbar
17
+ //-fullscreen disable fullscreen mode if set during compilation (lively is handling resizing window instead).
18
+ //Alternative flags:
19
+ //Unity attaches to workerw by itself; Problem: Process window handle is returning zero.
20
+ //"-parentHWND " + workerw.ToString();// + " -popupwindow" + " -;
21
+ //cmdArgs = "-popupwindow -screen-fullscreen 0";
22
+ string cmdArgs = model . LivelyInfo . Arguments ;
29
23
30
24
ProcessStartInfo start = new ProcessStartInfo
31
25
{
@@ -92,24 +86,30 @@ public WallpaperType GetWallpaperType()
92
86
93
87
public void Pause ( )
94
88
{
89
+ //Disabled, need further testing.
90
+ /*
95
91
try
96
92
{
97
93
ProcessSuspend.SuspendAllThreads(this);
98
94
//thread buggy noise otherwise?!
99
95
VolumeMixer.SetApplicationMute(Proc.Id, true);
100
96
}
101
97
catch { }
98
+ */
102
99
}
103
100
104
101
public void Play ( )
105
102
{
103
+ //Disabled, need further testing.
104
+ /*
106
105
try
107
106
{
108
107
ProcessSuspend.ResumeAllThreads(this);
109
108
//thread buggy noise otherwise?!
110
109
VolumeMixer.SetApplicationMute(Proc.Id, false);
111
110
}
112
111
catch { }
112
+ */
113
113
}
114
114
115
115
public void SetHWND ( IntPtr hwnd )
@@ -148,13 +148,13 @@ public async void Show()
148
148
}
149
149
else
150
150
{
151
- if ( GetWallpaperType ( ) != WallpaperType . unity )
152
- {
153
- WindowOperations . BorderlessWinStyle ( HWND ) ;
154
- WindowOperations . RemoveWindowFromTaskbar ( HWND ) ;
155
- }
151
+ WindowOperations . BorderlessWinStyle ( HWND ) ;
152
+ WindowOperations . RemoveWindowFromTaskbar ( HWND ) ;
156
153
//Program ready!
157
- WindowInitialized ? . Invoke ( this , new WindowInitializedArgs ( ) { Success = true , Error = null , Msg = null } ) ;
154
+ WindowInitialized ? . Invoke ( this , new WindowInitializedArgs ( ) {
155
+ Success = true ,
156
+ Error = null ,
157
+ Msg = null } ) ;
158
158
}
159
159
}
160
160
catch ( OperationCanceledException e1 )
@@ -231,36 +231,36 @@ private async Task<IntPtr> WaitForProcesWindow()
231
231
}
232
232
return wHWND ;
233
233
}
234
- else if ( GetWallpaperType ( ) == WallpaperType . unity )
234
+
235
+ //Find process window.
236
+ for ( int i = 0 ; i < timeOut && Proc . HasExited == false ; i ++ )
237
+ {
238
+ ctsProcessWait . Token . ThrowIfCancellationRequested ( ) ;
239
+ if ( ! IntPtr . Equals ( ( wHWND = GetProcessWindow ( Proc , true ) ) , IntPtr . Zero ) )
240
+ break ;
241
+ await Task . Delay ( 1 ) ;
242
+ }
243
+
244
+ //Player settings dialog of Unity (if exists.)
245
+ IntPtr cHWND = NativeMethods . FindWindowEx ( wHWND , IntPtr . Zero , "Button" , "Play!" ) ;
246
+ if ( ! IntPtr . Equals ( cHWND , IntPtr . Zero ) )
235
247
{
236
- //Player settings dialog of Unity (if exists.)
248
+ //Simulate Play! button click. (Unity config window)
249
+ NativeMethods . SendMessage ( cHWND , NativeMethods . BM_CLICK , IntPtr . Zero , IntPtr . Zero ) ;
250
+ //Refreshing..
251
+ wHWND = IntPtr . Zero ;
252
+ await Task . Delay ( 1 ) ;
253
+
254
+ //Search for Unity main Window.
237
255
for ( int i = 0 ; i < timeOut && Proc . HasExited == false ; i ++ )
238
256
{
239
257
ctsProcessWait . Token . ThrowIfCancellationRequested ( ) ;
240
258
if ( ! IntPtr . Equals ( ( wHWND = GetProcessWindow ( Proc , true ) ) , IntPtr . Zero ) )
259
+ {
241
260
break ;
261
+ }
242
262
await Task . Delay ( 1 ) ;
243
263
}
244
-
245
- IntPtr cHWND = NativeMethods . FindWindowEx ( wHWND , IntPtr . Zero , "Button" , "Play!" ) ;
246
- if ( ! IntPtr . Equals ( cHWND , IntPtr . Zero ) )
247
- {
248
- //Simulate Play! button click. (Unity config window)
249
- NativeMethods . SendMessage ( cHWND , NativeMethods . BM_CLICK , IntPtr . Zero , IntPtr . Zero ) ;
250
- }
251
- await Task . Delay ( 1 ) ;
252
- //Refresh
253
- wHWND = IntPtr . Zero ;
254
- }
255
-
256
- for ( int i = 0 ; i < timeOut && Proc . HasExited == false ; i ++ )
257
- {
258
- ctsProcessWait . Token . ThrowIfCancellationRequested ( ) ;
259
- if ( ! IntPtr . Equals ( ( wHWND = GetProcessWindow ( Proc , true ) ) , IntPtr . Zero ) )
260
- {
261
- break ;
262
- }
263
- await Task . Delay ( 1 ) ;
264
264
}
265
265
return wHWND ;
266
266
}
0 commit comments