コンソールのタイトルを表示するバッチファイル+JScript.NET @if(0)==(0) ECHO OFF SETLOCAL SET DOTNET=%SystemRoot%\Microsoft.NET\Framework FOR /F "delims=" %%1 IN ('DIR /AD /B /ON "%DOTNET%\v*"') DO IF EXIST "%DOTNET%\%%~1\jsc.exe" SET DOTNET=%DOTNET%\%%~1\jsc.exe "%DOTNET%" /nologo /d:_ /out:"%~f0.exe" "%~f0" "%~f0.exe" DEL "%~f0.exe" GOTO :EOF @end import System; import System.Diagnostics; var PC : PerformanceCounter=new PerformanceCounter('Process','Creating Process Id',Process.GetCurrentProcess().ProcessName); var PID : int = PC.RawValue; Console.WriteLine(Process.GetProcessById(PID).MainWindowTitle) ワーンングが出ますが、コードのほうで直せませんか?
>>119 サンクス。直りました。今度は最小化ですが、 import System; import System.Diagnostics; import System.Windows.Forms; const WM_SYSCOMMAND : int = 0x0112; const SC_MINIMIZE : int = 0xF020; var nCmdShow : int =SC_MINIMIZE; var PC : PerformanceCounter=new PerformanceCounter('Process','Creating Process Id',Process.GetCurrentProcess().ProcessName); var PID : int=int(PC.RawValue); var oProcess : System.Diagnostics.Process=System.Diagnostics.Process.GetProcessById(PID); var hwnd : IntPtr=oProcess.MainWindowHandle; var m : Message = Message.Create(hwnd,WM_SYSCOMMAND,IntPtr.op_Explicit(nCmdShow),IntPtr.op_Explicit(0)); var nw : NativeWindow = new NativeWindow(); nw.AssignHandle(hwnd); print(m.ToString()); nw.DefWndProc(m); // 型が一致しません。のエラーになります。なぜでしょう? nw.ReleaseHandle(); nw = null;