ToString() public method

public ToString ( ) : string
return string
示例#1
0
        public static void CheckProcess()
        {
            gameProcess = Process.GetProcessesByName("Spotify").FirstOrDefault();

            if (gameProcess != null)
            {
                var gameModule  = gameProcess.MainModule;
                var baseAddress = gameModule.BaseAddress.ToInt64() + 0x0152ED0C;
                var offsets     = new [] { 0x2E8 };

                var realAddress = Program.GetRealAddress(gameProcess.Handle, (IntPtr)baseAddress, offsets);
                Program.foundAddress = (IntPtr)realAddress;

                var array = BitConverter.GetBytes(100);
                int bytesWritten;
                //WriteProcessMemory(gameProcess.Handle, Program.foundAddress, array, (uint)array.Length, out bytesWritten);

                string Address = realAddress.ToString("X");

                Console.WriteLine(gameProcess.ToString());
                Console.WriteLine(gameModule.ToString());
                Console.WriteLine(baseAddress.ToString());
                Console.WriteLine(foundAddress.ToString());
                Console.WriteLine(Address);
            }
        }
示例#2
0
        public override bool Init()
        {
            Logger.LogError("Executable loading not yet supported!");
            return(false);

            Logger.Log($"Loading '{_exeName}'", Level.Info);
            Process p = new Process()
            {
                StartInfo = new ProcessStartInfo(_exeName)
                {
                    UseShellExecute = false,
                    //	RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    Arguments = "Some Text",
                }
            };

            p.OutputDataReceived += (sender, args) => Logger.Log($"Got Data: {sender.ToString()}, {args.Data}", Level.Verbose);
            p.Start();
            Logger.Log(p.ToString(), Level.Debug);
            p.BeginOutputReadLine();
            p.WaitForExit();
            return(true);
        }
        public TopLevelWindow[] GetTopLevelWindow(string[] blacklist)
        {
            List <TopLevelWindow> windows = new List <TopLevelWindow>();

            VirtualDesktopManager vdm = new VirtualDesktopManager();

            int zIndex = 0;

            WinApiUtil.EnumDelegate filter = delegate(IntPtr hWnd, int lParam)
            {
                StringBuilder   strbTitle         = new StringBuilder(255);
                int             nLength           = WinApiUtil.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1);
                string          strTitle          = strbTitle.ToString();
                WinApiUtil.RECT positionPlacement = new WinApiUtil.RECT();

                try
                {
                    if (WinApiUtil.IsWindowVisible(hWnd) && string.IsNullOrEmpty(strTitle) == false && vdm.IsWindowOnCurrentVirtualDesktop(hWnd) && WinApiUtil.GetWindowRect(hWnd, ref positionPlacement))
                    {
                        uint pid = 0;
                        TopLevelWindow.WindowState windowState = TopLevelWindow.WindowState.NORMAL;
                        WinApiUtil.GetWindowThreadProcessId(hWnd, out pid);
                        Process process = Process.GetProcessById((int)pid);
                        WinApiUtil.WINDOWPLACEMENT placement = new WinApiUtil.WINDOWPLACEMENT();
                        WinApiUtil.GetWindowPlacement(hWnd, ref placement);
                        switch (placement.showCmd)
                        {
                        case 1:
                            windowState = TopLevelWindow.WindowState.NORMAL;
                            break;

                        case 2:
                            windowState = TopLevelWindow.WindowState.MINIMIZED;
                            break;

                        case 3:
                            windowState = TopLevelWindow.WindowState.MAXIMIZED;
                            break;
                        }
                        TopLevelWindow w = new TopLevelWindow(process.ToString(), strTitle, (int)hWnd, new Rectangle(positionPlacement.Left, positionPlacement.Top, positionPlacement.Right - positionPlacement.Left,
                                                                                                                     positionPlacement.Bottom - positionPlacement.Top), zIndex, windowState);
                        windows.Add(w);
                    }
                }catch (System.Runtime.InteropServices.COMException e)
                {
                }catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                zIndex++;
                return(true);
            };

            if (WinApiUtil.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero))
            {
                return(windows.ToArray <TopLevelWindow>());
            }

            return(null);
        }
示例#4
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            foreach (Guid id in Record)
            {
                ExecuteAction(id.ToString(), Process.ToString(), delegate
                {
                    OrganizationRequest request = new OrganizationRequest()
                    {
                        RequestName = "ExecuteWorkflow"
                    };
                    request.Parameters["EntityId"]   = id;
                    request.Parameters["WorkflowId"] = Process;

                    OrganizationResponse response = _repository.Execute(request);

                    if (PassThru)
                    {
                        Guid asyncId = (Guid)response.Results["Id"];
                        WriteObject(_repository.Get("asyncoperation", asyncId));
                    }
                });
            }
        }
示例#5
0
文件: UnitTest1.cs 项目: Wepled/Torim
        public void Process_Create_Test()
        {
            Process process     = processFactory.CreateProcess("PrInTest", "PrInIdTestovich", "PrTyTest", "PrATest");
            Process testProcess =
                new Process("PrTyTest_PrInTest_1", "PrInTest", "PrInIdTestovich", "PrTyTest", "PrATest");

            Assert.AreEqual(process.ToString(),
                            testProcess.ToString());
        }
    public static void Main()
    {
        int     sample  = 0;
        Process process = null;

        try {
            // Start a process to execute the notepad.exe program.
            process = Process.Start("notepad.exe", ".\\ProcessMonitor.cs");

            // Display the process statistics until the user closes the program.
            do
            {
                if (!process.HasExited)
                {
                    // Refresh the current process property values.
                    process.Refresh();
                    Console.WriteLine();

                    // Display current process statistics.
                    Console.WriteLine("{0}[{1}] -", process.ToString(), ++sample);
                    Console.WriteLine("-------------------------------------");
                    Console.WriteLine("  physical memory usage: {0} KB", process.WorkingSet64 / 1024);
                    Console.WriteLine("  base priority: {0}", process.BasePriority);
                    Console.WriteLine("  priority class: {0}", process.PriorityClass);
                    Console.WriteLine("  user-mode processor time: {0}", process.UserProcessorTime);
                    Console.WriteLine("  kernel-mode processor time: {0}", process.PrivilegedProcessorTime);
                    Console.WriteLine("  total processor time: {0}", process.TotalProcessorTime);
                    Console.WriteLine("  pagedSystemMemorySize64: {0} KB", process.PagedSystemMemorySize64 / 1024);
                    Console.WriteLine("  pagedMemorySize64: {0} KB", process.PagedMemorySize64 / 1024);

                    //Console.WriteLine("Threads: {0}", process.Threads.Count);

                    Console.WriteLine("Threads({0}): ", process.Threads.Count);
                    foreach (ProcessThread pt in process.Threads)
                    {
                        Console.Write(" 0x{0:x16} - {1}:{2}", pt.StartAddress.ToInt64(), pt.Id, pt.ThreadState);
                    }
                    Console.WriteLine();
                }
            } while (!process.WaitForExit(5000));

            Console.WriteLine();
            Console.WriteLine("process exit code: {0}", process.ExitCode);

            // Display peak memory statistics for the process.
            Console.WriteLine("peak physical memory usage: {0} KB", process.PeakWorkingSet64 / 1024);
            Console.WriteLine("peak paged memory usage: {0} KB", process.PeakPagedMemorySize64 / 1024);
            Console.WriteLine("peak virtual memory usage: {0} KB", process.PeakVirtualMemorySize64 / 1024);
        } finally {
            if (process != null)
            {
                process.Close();
            }
        }
    }
示例#7
0
        private bool ProcessEnd(Process process)
        {
            Debug.Log(this.name + " (" + id + ") [Completed Process: " + process.ToString() + "]");

            if (onProcessEnd != null)
            {
                onProcessEnd(this, processSet.ToArray(), process);
            }

            return(processSet.Remove(process));
        }
示例#8
0
        private void ProcessError(Process erroringProcess)
        {
            processSet.Add(Process.Error);

            Debug.Log(this.name + " (" + id + ") [Erroring Process: " + erroringProcess.ToString() + "]");

            if (onProcessError != null)
            {
                onProcessError(this, processSet.ToArray(), erroringProcess);
            }
        }
示例#9
0
        /// <summary>
        /// Gets information about all processes and returns it in an HTML formatted string
        /// </summary>
        /// <param name="Process">Process to get information about</param>
        /// <param name="HTMLFormat">Should this be HTML formatted?</param>
        /// <returns>An HTML formatted string</returns>
        public static string GetInformation(this Process Process, bool HTMLFormat = true)
        {
            StringBuilder Builder = new StringBuilder();

            return(Builder.Append(HTMLFormat ? "<strong>" : "")
                   .Append(Process.ProcessName)
                   .Append(" Information")
                   .Append(HTMLFormat ? "</strong><br />" : "\n")
                   .Append(Process.ToString(HTMLFormat))
                   .Append(HTMLFormat ? "<br />" : "\n")
                   .ToString());
        }
示例#10
0
        private void cmbTerminal_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string    str = cmbTerminal.SelectedValue.ToString();
            DataTable dt  = DataUtils.Interface.GetProcessFromTerminal(str);

            if (dt.Rows.Count > 0)
            {
                Terminal          = str;
                Process           = dt.Rows[0][0].ToString();
                processID.ToolTip = Process.ToString();
            }
        }
        /// <summary>
        /// Gets information about all processes and returns it in an HTML formatted string
        /// </summary>
        /// <param name="Process">Process to get information about</param>
        /// <param name="HTMLFormat">Should this be HTML formatted?</param>
        /// <returns>An HTML formatted string</returns>
        public static string GetInformation(this Process Process, bool HTMLFormat = true)
        {
            Contract.Requires <ArgumentNullException>(Process != null, "Process");
            var Builder = new StringBuilder();

            return(Builder.Append(HTMLFormat ? "<strong>" : "")
                   .Append(Process.ProcessName)
                   .Append(" Information")
                   .Append(HTMLFormat ? "</strong><br />" : "\n")
                   .Append(Process.ToString(HTMLFormat))
                   .Append(HTMLFormat ? "<br />" : "\n")
                   .ToString());
        }
 static void Run()
 {
     Process
     proc
     =
     new
     Process();
     bool
     ret;
     proc.StartInfo.FileName="wibble-redir";
     proc.StartInfo.Arguments="arg1    arg2\targ3 \"arg4a arg4b\"";
     proc.StartInfo.UseShellExecute=false;
     proc.StartInfo.RedirectStandardInput=true;
     ret=proc.Start();
     Console.WriteLine("Start returns "
     +
     ret);
     Console.WriteLine("Process is "
     +
     proc.ToString());
     Console.WriteLine("Pid is "
     +
     proc.Id);
     Console.WriteLine("Handle is "
     +
     proc.Handle);
     Console.WriteLine("HandleCount is "
     +
     proc.HandleCount);
     Console.WriteLine("Writing [foo bar]");
     proc.StandardInput.WriteLine("foo bar");
     System.Threading.Thread.Sleep(1000);
     Console.WriteLine("Writing [wibble wobble]");
     proc.StandardInput.WriteLine("wibble wobble");
     System.Threading.Thread.Sleep(1000);
     Console.WriteLine("Closing stdin");
     proc.StandardInput.Close();
     Console.WriteLine("Waiting for exit...");
     proc.WaitForExit();
     Console.WriteLine("Wait returned");
     Console.WriteLine("Exit code is "
     +
     proc.ExitCode);
     Console.WriteLine("Process started at "
     +
     proc.StartTime);
     Console.WriteLine("Process ended at "
     +
     proc.ExitTime);
 }
示例#13
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Process process = Process.GetProcessesByName("notepad")[0];

            try
            {
                Injection.inject("Jsharp.dll", process);
                MessageBox.Show(process.ToString());
            }
            catch (Exception args)
            {
                MessageBox.Show(args.Message);
            }
        }
示例#14
0
        /// <summary>
        /// Kill all processes matching the name "processName".  This name should
        /// not include the extension (like ".exe")
        /// </summary>
        /// <param name="processId">ID of the process to kill</param>
        /// <param name="closeWindowFirst">Attempt the close window first before killing the process</param>
        private static bool KillProcessById(int processId, bool closeWindowFirst)
        {
            bool success;

            try
            {
                LogToFile.Info("Killing processes matching ID \"{0}\"", processId);

                // Get all instances of process (matching processName)
                Process localProcess = Process.GetProcessById(processId);

                success = EndLocalProcesses(new[] { localProcess }, closeWindowFirst);
            }
            catch (Exception ex)
            {
                LogToFile.Error("Unable to kill processes by ID \"{0}\"\r\n{1}",
                                processId, ex.ToString());
                success = false;
            }

            // check that the process is gone
            if (success)
            {
                try
                {
                    Process checkProcess = null;
                    for (int count = 0; count < 10; count++)
                    {
                        Thread.Sleep(200);
                        checkProcess = Process.GetProcessById(processId);
                    }

                    LogToFile.Error("Error checking process was ended \"{0}\"\r\n    {1}",
                                    processId, (checkProcess != null) ? checkProcess.ToString() : "(NULL)");
                    success = false;
                }
                catch (ArgumentException)
                {
                    //Expected result because the ProcessID no longer exists
                }
                catch (Exception ex)
                {
                    LogToFile.Error("Unable to get processes by ID \"{0}\"\r\n{1}",
                                    processId, ex.ToString());
                    success = false;
                }
            }
            return(success);
        }
示例#15
0
        private void print(Process p, bool t)
        {
            if (!String.IsNullOrEmpty(p.MainWindowTitle))
            {
                if (t)
                {
                    Form1.main.appendText("Program Start Detected : " + "Name: " + p.MainWindowTitle + "\t\t ProcessName : " + p.ProcessName + "\t StartTime: " + p.StartTime + "\t ProcessorTime: " + p.TotalProcessorTime);
                }

                else
                {
                    Form1.main.appendText("Program Stop Detected : " + "Name: " + p.ToString());
                }
            }
        }
示例#16
0
        private void TrySendProcess(Process process)
        {
            try {
                if (Socket.Connected && process.Id > 0)
                {
                    String data = process.Id + ";" + process.ProcessName;
                    RemoteAppManager.Packets.Message message = new RemoteAppManager.Packets.Message(MessageTypes.RESPONSE_PROCESS, data);

                    Send(Socket, message.Data, true);
                }
            }
            catch (Exception e) {
                Utils.Log(LogLevels.WARNING, "Process not sent " + process.ToString());
            }
        }
示例#17
0
        /// <summary>
        /// Handle process exit (success, error, or interrupt).
        /// </summary>
        void ProcessExit(object sender, EventArgs e)
        {
            if (_process == null)
            {
                return;
            }

            var exitCode    = _process.ExitCode; // That's all the info you can get from a process that has exited - no name etc
            var processName = _process.ToString();

            _process = null;
            bool processKilled = _processKilled;

            _processKilled = false;

            if (exitCode == 0)
            {
                // Tricky: we have to wait for the final output of the last process to
                // be logged, otherwise the output from the next process may be interleaved.
                RunUI(() =>
                {
                    _exitTimer = new Timer {
                        Interval = MAX_PROCESS_OUTPUT_DELAY
                    };
                    _exitTimer.Tick += (o, args) =>
                    {
                        _exitTimer.Stop();
                        RunNext(null, null);
                    };
                    _exitTimer.Start();
                });
            }
            else
            {
                try
                {
                    if (!processKilled)
                    {
                        Log(Environment.NewLine + "# Process " + (_processName ?? string.Empty) + " had nonzero exit code " + exitCode + Environment.NewLine);
                    }
                    RunUI(() => CommandsDone(_restartOnProcessFailure && !processKilled ? EXIT_TYPE.error_restart : EXIT_TYPE.error_stop));
                }
// ReSharper disable once EmptyGeneralCatchClause
                catch (Exception)
                {
                }
            }
        }
示例#18
0
        private void monitorTimerCallback(object sync)
        {
            IntPtr window = GetForegroundWindow();

            if (window == null)
            {
                ISLogger.Write("GetForegroundWindow() returned null");
                return;
            }

            int w = GetSystemMetrics(0); //width of primay monitor
            int h = GetSystemMetrics(1); //height of primary monitor

            GetWindowRect(window, out RECT rect);

            int pw = Math.Abs(rect.left - rect.right);
            int ph = Math.Abs(rect.top - rect.bottom);

            //To detect a fullscreen application, we check to see if size of the foreground window is equal to the primary monitor
            //This only works for fullscreen applications that are displayed on primary monitor

            if (pw == w && ph == h)
            {
                if (!FullscreenApplicationRunning)
                {
                    CurrentFullscreenProcess = GetForegroundWindowProcess(window);

                    //When explorer/desktop is in focus, it will be detected as fullscreen, we want to ignore this
                    if (CurrentFullscreenProcess.ToString() == "explorer")
                    {
                        return;
                    }

                    ProcessEnteredFullscreen?.Invoke(this, CurrentFullscreenProcess);
                    FullscreenApplicationRunning = true;
                }
            }
            else
            {
                if (FullscreenApplicationRunning)
                {
                    ProcessExitedFullscreen?.Invoke(this, CurrentFullscreenProcess);
                    CurrentFullscreenProcess     = null;
                    FullscreenApplicationRunning = false;
                }
            }
        }
示例#19
0
        public static string TryFindOwnerAppDataPath(Process process)
        {
            try
            {
                using (ManagementObjectSearcher searcher = GetProcessSearcherForId(process.Id))
                {
                    foreach (ManagementObject @object in searcher.Get())
                    {
                        Debug.WriteLine("Found running process ");

                        string[] OwnerInfo = new string[2];
                        @object.InvokeMethod("GetOwner", (object[])OwnerInfo);

                        string username = OwnerInfo[0];
                        string domain   = OwnerInfo[1];

                        Debug.WriteLine(string.Format(" Owner {0}\\{1}", domain, username));

                        string[] OwnerSid = new string[1];
                        @object.InvokeMethod("GetOwnerSid", (object[])OwnerSid);

                        string sid = OwnerSid[0];
                        Debug.WriteLine(string.Format(" SID: {0}", sid));

                        string path = Registry.GetValue(regKeyFolders.Replace("<SID>", sid), regValueAppData, null) as string;

                        Debug.WriteLine(string.Format("AppData: {0}", path == null ? "<NULL>" : path));

                        return(path);
                    }
                }
            }
            catch (Win32Exception ex)
            {
                if ((uint)ex.ErrorCode != 0x80004005)
                {
                    Debug.WriteLine(ex.Message);
                    throw;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading process information for {0} : {1}", process.ToString(), ex.Message);
            }
            return(null);
        }
        /// <summary>
        /// Gets information about all processes and returns it in an HTML formatted string
        /// </summary>
        /// <param name="process">Process to get information about</param>
        /// <param name="htmlFormat">Should this be HTML formatted?</param>
        /// <returns>An HTML formatted string</returns>
        public static string GetInformation(this Process process, bool htmlFormat = true)
        {
            if (process is null)
            {
                return(string.Empty);
            }

            var Builder = new StringBuilder();

            return(Builder.Append(htmlFormat ? "<strong>" : "")
                   .Append(process.ProcessName)
                   .Append(" Information")
                   .Append(htmlFormat ? "</strong><br />" : "\n")
                   .Append(process.ToString(htmlFormat))
                   .Append(htmlFormat ? "<br />" : "\n")
                   .ToString());
        }
示例#21
0
 private void LoadProcesses()
 {
     Process[] processes = Process.GetProcesses();
     foreach (Process p in processes)
     {
         if (!String.IsNullOrEmpty(p.MainWindowTitle))
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 SecondModeVM.Processes.Add(new ProcessInfo(p));
             }));
         }
     }
     foreach (var Process in SecondModeVM.Processes)
     {
         Report.WriteToReportFile(Process.ToString() + " was started at " + Process.Process.StartTime);
     }
 }
 public string list()
 {
     if (first != null)
     {
         string  processString = first.ToString();
         Process temp          = first;
         for (int i = 2; i <= numberProcesses; i++)
         {
             temp           = temp.Next;
             processString += temp.ToString();
         }
         return(processString);
     }
     else
     {
         return("No se ha agregado ningún proceso a la cola");
     }
 }
示例#23
0
 private void btnAccept_Click(object sender, System.EventArgs e)
 {
     if (ProcImage != null && _currentProcess != Process.Zoom && _currentProcess != Process.Rotate)
     {
         OriginalImage       = ProcImage;
         pBox_Original.Image = OriginalImage;
         pBox_ProcImg.Image  = new Bitmap(pBox_ProcImg.Width, pBox_ProcImg.Height);
         ProcImage           = null;
         pBoxHistProc.Image  = new Bitmap(pBoxHistProc.Width, pBoxHistProc.Height);
         DrawHistogram(OriginalImage, pBoxHistOrig);
         listboxHistory.Items.Add(_currentProcess.ToString());
         ResetThresholdPanel();
         ResetRotationAndZoomControl();
     }
     else
     {
         MessageBox.Show("This process cannot be applied, Sorry");
     }
 }
示例#24
0
        /// <summary>
        /// Handle process exit (success, error, or interrupt).
        /// </summary>
        void ProcessExit(object sender, EventArgs e)
        {
            if (_process == null)
            {
                return;
            }

            var exitCode    = _process.ExitCode;
            var processName = _process.ToString();

            _process = null;

            if (exitCode == 0)
            {
                // Tricky: we have to wait for the final output of the last process to
                // be logged, otherwise the output from the next process may be interleaved.
                RunUI(() =>
                {
                    _exitTimer = new Timer {
                        Interval = MAX_PROCESS_OUTPUT_DELAY
                    };
                    _exitTimer.Tick += (o, args) =>
                    {
                        _exitTimer.Stop();
                        RunNext(null, null);
                    };
                    _exitTimer.Start();
                });
            }
            else
            {
                try
                {
                    Log(Environment.NewLine + "# Process " + processName + " had nonzero exit code " + exitCode + Environment.NewLine);
                    RunUI(() => CommandsDone(EXIT_TYPE.error_stop));
                }
// ReSharper disable once EmptyGeneralCatchClause
                catch (Exception)
                {
                }
            }
        }
示例#25
0
 protected override void Run()
 {
     try
     {
         StringBuilder strDis    = new StringBuilder();
         Process       myprocess = Process.GetCurrentProcess();
         strDis.AppendLine("开始执行GC收集,当前进程" + myprocess.ToString() + "占用内存大小:" + myprocess.PagedMemorySize64 / 1024);
         // Console.WriteLine("开始执行GC收集,当前进程" + myprocess.ToString() + "占用内存大小:" + myprocess.PagedMemorySize64 / 1024);
         GC.Collect();
         Process myprocess2 = Process.GetCurrentProcess();
         strDis.AppendLine("GC收集完成,当前进程" + myprocess2.ToString() + "占用内存大小:" + myprocess2.PagedMemorySize64 / 1024);
         // Console.WriteLine("GC收集完成,当前进程" + myprocess2.ToString() + "占用内存大小:" + myprocess2.PagedMemorySize64 / 1024);
         LogProxy.AddNodeLog(strDis.ToString());
         strDis = null;
     }
     catch (Exception ex)
     {
         LogProxy.AddNodeErrorLog("节点定时进行GC收集异常:" + JsonConvert.SerializeObject(ex));
     }
 }
示例#26
0
        public void Process_Constructor()
        {
            // Arrange
            var obj = BaseTests.LoadJson("Get-VSTeamProcess.json");

            // Act
            var target = new Process(obj[0]);

            // Assert
            Assert.AreEqual("Scrum", target.Name, "Name");
            Assert.AreEqual("system", target.Type, "Type");
            Assert.AreEqual(true, target.IsEnabled, "IsEnabled");
            Assert.AreEqual(false, target.IsDefault, "IsDefault");
            Assert.AreEqual("Scrum", target.ToString(), "ToString()");
            Assert.AreEqual("Scrum", target.ProcessTemplate, "ProcessTemplate");
            Assert.AreEqual("6b724908-ef14-45cf-84f8-768b5384da45", target.Id, "Id");
            Assert.AreEqual("6b724908-ef14-45cf-84f8-768b5384da45", target.TypeId, "TypeId");
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", target.ParentProcessTypeId, "ParentProcessTypeId");
            Assert.AreEqual("This template is for teams who follow the Scrum framework.", target.Description, "Description");
        }
示例#27
0
        static void Main(string[] args)
        {
            try
            {
                Win32.MessageBox(0, "Messagebox Crated from windows OS", "Title", 1);
            }
            catch (Exception er)
            {
                Win32.MessageBox(0, er.Message, "API Demo", 0);
            }
            int           hwnd      = Win32.GetForegroundWindow();
            StringBuilder title1    = new StringBuilder(2048);
            int           intLength = Win32.GetWindowText(hwnd, title1, title1.Capacity);

            if ((intLength <= 0) || (intLength > title1.Length))
            {
                Win32.MessageBox(0, title1.ToString(), "Title", 1);
            }
            string title = title1.ToString();

            Win32.MessageBox(0, title1.ToString(), "Title", 1);


            try
            {
                Process process = Process.GetProcessesByName("WINWORD")[0];
                if (process != null)
                {
                    process.WaitForInputIdle();
                    IntPtr s = process.MainWindowHandle;
                    Win32.SetForegroundWindow(s);
                    Console.Write("Proccess found: " + process.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Application is not running!\nException: " + ex.Message);
                return;
            }
            Console.ReadKey();
        }
 static void Run()
 {
     Process
     proc
     =
     new
     Process();
     bool
     ret;
     proc.StartInfo.FileName="wibble";
     proc.StartInfo.Arguments="arg1    arg2\targ3 \"arg4a arg4b\"";
     proc.StartInfo.UseShellExecute=false;
     ret=proc.Start();
     Console.WriteLine("Start returns "
     +
     ret);
     Console.WriteLine("Process is "
     +
     proc.ToString());
     Console.WriteLine("Pid is "
     +
     proc.Id);
     Console.WriteLine("Handle is "
     +
     proc.Handle);
     Console.WriteLine("HandleCount is "
     +
     proc.HandleCount);
     Console.WriteLine("Waiting for exit...");
     proc.WaitForExit();
     Console.WriteLine("Wait returned");
     Console.WriteLine("Exit code is "
     +
     proc.ExitCode);
     Console.WriteLine("Process started at "
     +
     proc.StartTime);
     Console.WriteLine("Process ended at "
     +
     proc.ExitTime);
 }
 public void Start()
 {
     Log("starting service");
     try
     {
         var config = SolrServiceConfigurationManager.GetSolrServiceConfiguration();
         process.StartInfo.FileName         = config.JavaExecutable;
         process.StartInfo.WorkingDirectory = config.WorkingDirectory;
         process.StartInfo.Arguments        = config.GetprocessStartArguments();
         process.StartInfo.UseShellExecute  = config.ShowConsole;
         Log(process.ToString());
         var result = process.Start();
         Log("result of batch start: " + result);
         //process.WaitForExit();
     }
     catch (Exception ex)
     {
         Log("An error occurred: " + ex.Message);
         throw;
     }
 }
示例#30
0
    static void Run()
    {
        Process proc = new Process();
        bool    ret;

        proc.StartInfo.FileName        = "wibble";
        proc.StartInfo.Arguments       = "arg1    arg2\targ3 \"arg4a arg4b\"";
        proc.StartInfo.UseShellExecute = false;
        ret = proc.Start();

        Console.WriteLine("Start returns " + ret);
        Console.WriteLine("Process is " + proc.ToString());
        Console.WriteLine("Pid is " + proc.Id);
        Console.WriteLine("Handle is " + proc.Handle);
        Console.WriteLine("HandleCount is " + proc.HandleCount);

        Console.WriteLine("Waiting for exit...");
        proc.WaitForExit();
        Console.WriteLine("Wait returned");
        Console.WriteLine("Exit code is " + proc.ExitCode);
        Console.WriteLine("Process started at " + proc.StartTime);
        Console.WriteLine("Process ended at " + proc.ExitTime);
    }
示例#31
0
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            Console.WriteLine("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp);
            Console.WriteLine("posX: {0}, posY: {1}", e.X, e.Y);

            if (altEnabled == true)
            {
                try
                {
                    setCurrentProcess();
                    Console.WriteLine(current.ToString());
                    Console.WriteLine("The modifier was pressed and we should replicate this input on every window");
                    Console.WriteLine("Current process id is : {0}", current.Id);
                    SetCursorPos(e.X, e.Y);
                    foreach (Process process in pcs)
                    {
                        Console.WriteLine("Targeted process id is : {0}", process.Id);
                        if (process.Id != current.Id)
                        {
                            SetForegroundWindow(process.MainWindowHandle);
                            Thread.Sleep(500);

                            /*
                             * mouse_event(WM_LBUTTONDOWN, 0, 0, 0, UIntPtr.Zero);
                             * Thread.Sleep(500);
                             * mouse_event(WM_LBUTTONUP, 0, 0, 0, UIntPtr.Zero);
                             * Thread.Sleep(500);
                             */
                        }
                    }
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc);
                }
            }
        }
示例#32
0
    static void Run()
    {
        Process proc = new Process();
        bool    ret;

        proc.StartInfo.FileName              = "wibble-redir";
        proc.StartInfo.Arguments             = "arg1    arg2\targ3 \"arg4a arg4b\"";
        proc.StartInfo.UseShellExecute       = false;
        proc.StartInfo.RedirectStandardInput = true;
        ret = proc.Start();

        Console.WriteLine("Start returns " + ret);
        Console.WriteLine("Process is " + proc.ToString());
        Console.WriteLine("Pid is " + proc.Id);
        Console.WriteLine("Handle is " + proc.Handle);
        Console.WriteLine("HandleCount is " + proc.HandleCount);

        Console.WriteLine("Writing [foo bar]");
        proc.StandardInput.WriteLine("foo bar");

        System.Threading.Thread.Sleep(1000);

        Console.WriteLine("Writing [wibble wobble]");
        proc.StandardInput.WriteLine("wibble wobble");

        System.Threading.Thread.Sleep(1000);

        Console.WriteLine("Closing stdin");
        proc.StandardInput.Close();

        Console.WriteLine("Waiting for exit...");
        proc.WaitForExit();
        Console.WriteLine("Wait returned");
        Console.WriteLine("Exit code is " + proc.ExitCode);
        Console.WriteLine("Process started at " + proc.StartTime);
        Console.WriteLine("Process ended at " + proc.ExitTime);
    }
示例#33
0
        private static void RecursiveSearch(Process currentProcess, Stack<Process> chain, HashSet<Process> searchSpace)
        {
            if (chain.Contains(currentProcess)) throw new Exception(currentProcess.ToString());

            chain.Push(currentProcess);

            foreach (var output in currentProcess.Outputs.Keys.Where(x => x != null))
            {
                var outputClosure = output;
                foreach (var other in searchSpace.Where(x => x.Inputs.Keys.Contains(outputClosure)))
                {
                    RecursiveSearch(other, chain, searchSpace);
                }
            }
            chain.Pop();
        }