2014-06-25 1 views
0

Je travaille avec WatIn et je sauvegarde les fichiers avec la boîte de dialogue saveAs, mais quand je verrouille Windows/pc ce processus est stop, j'ai besoin de lancer Invoke sur SendMessage que ce processus tournera quand mon pc sera verrouillé.Invoke to SendMessage

Existe-t-il un moyen de le faire?

de code avec pice Invoke

private static void ClickSaveAs(AutomationElement mainWindow, AutomationElementCollection dialogElements, string filename) 
     { 


      foreach (AutomationElement element in dialogElements) 
      { 

       if (element.Current.Name.Equals("Save")) 
       { 
        AutomationElementCollection dialogSubElements = element.FindAll(TreeScope.Children, Automation.ContentViewCondition); 
        InvokePattern clickPatternForSaveDropdown = (InvokePattern)dialogSubElements[0].GetCurrentPattern(AutomationPattern.LookupById(10000)); 
       //I need to change this to.. 
        clickPatternForSaveDropdown.Invoke(); 

//This 
        //start 
        int intWhdr = FindWindow("IEFrame", ""); 
        int currChild = FindWindowEx(intWhdr, 0, "", "Frame Notification Bar"); 
        currChild = 104755016; 
        int intRes1 = SendMessage(currChild, WM_LBUTTONDOWN, 0, 0); 
        System.Threading.Thread.Sleep(100); 
        intRes1 = SendMessage(currChild, WM_LBUTTONUP, 0, 1); 
        System.Threading.Thread.Sleep(200); 
        //end 
        Thread.Sleep(1500); 

        AutomationElementCollection dialogElementsInMainWindow = mainWindow.FindAll(TreeScope.Children, Condition.TrueCondition); 
        foreach (AutomationElement currentMainWindowDialogElement in dialogElementsInMainWindow) 
        { 
         if (currentMainWindowDialogElement.Current.LocalizedControlType == "menu") 
         { 
          // first array element 'Save', second array element 'Save as', third second array element 'Save and open' 
          InvokePattern clickMenu = (InvokePattern)currentMainWindowDialogElement.FindAll(TreeScope.Children, Condition.TrueCondition)[1].GetCurrentPattern(AutomationPattern.LookupById(10000)); 
          clickMenu.Invoke(); 
          Thread.Sleep(1); 
          ControlSaveDialog(mainWindow, filename); 
          break; 
          //strt 


          //end 
         } 
        } 
       } 
      } 
     } 

Répondre

0

Watin ne fonctionne pas lorsque la machine est verrouillée. Comme il utilise, les références binaires Microsoft.mshtml et Interop.SHDocVw. Ces fichiers binaires sont des composants COM et nécessitent une interface utilisateur interactive. Pour l'exemple, vous pouvez essayer de vous connecter au lieu de télécharger. Commencez le test et verrouillez la machine puis déverrouillez. Observez le résultat, il échouera en lançant une erreur comme l'exception COM .... Essayez d'utiliser la mise à jour des clés Reg pour déverrouiller la machine en permanence ...