2016-11-07 33 views
0

我覺得我在這裏失去了一些東西,但無法環繞它。 該應用應該移動到不同的位置在屏幕上時,它切換焦點鉻代替記事本C#計時器沒有正確響應布爾語句


它tldr是一個按鈕的應用程序之間切換,但是一旦應用程序被最小化按鈕應該前進到其根據打開的窗口修改位置。這在if (IsIconic(prc[0].MainWindowHandle) && isMesOpen)

中被調用但是相反從兩個窗口都被最小化時的位置移動。

private void OeeCheckTimer_Tick(object sender, EventArgs e) 
{ 
    bool isMesOpen = false; 
    foreach (Process procesjexd in Process.GetProcesses()) 
    { 
     if (procesjexd.MainWindowTitle.ToLower().Contains("chrome")) 
     { 
      isMesOpen = IsIconic(procesjexd.MainWindowHandle); 
     } 
    } 

    //oee 
    var prc = Process.GetProcessesByName("notepad"); 
    if (prc.Any()) 
    { 
     if (IsIconic(prc[0].MainWindowHandle) && isMesOpen) 
     { 
      var x = System.Windows.SystemParameters.PrimaryScreenWidth - 122; 
      var y = System.Windows.SystemParameters.PrimaryScreenHeight - 155; 
      Location = new Point((int)x, (int)y); 
      IsOEE = false; 
     } 

回答

0

我認爲

isMesOpen = IsIconic(procesjexd.MainWindowHandle); 

應該

isMesOpen = true; 
    break;