public void Click(string id, params string[] arguments)
 {
     try
     {
         bool clicked = false;
         AutomationElement element = null;
         for (int i = 0; i < 5; i++)
         {
             element = GetElement(id);
             if (element.Current.IsEnabled && element.GetSupportedPatterns().Contains(InvokePattern.Pattern))
             {
                 ((InvokePattern)element.GetCurrentPattern(InvokePattern.Pattern)).Invoke();
                 clicked = true;
                 break;
             }
             if (element.Current.IsEnabled && element.GetSupportedPatterns().Contains(ExpandCollapsePattern.Pattern))
             {
                 ((ExpandCollapsePattern)element.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Expand();
                 ((ExpandCollapsePattern)element.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Collapse();
                 clicked = true;
                 break;
             }
             if (element.Current.IsEnabled && !element.Current.IsOffscreen)
             {
                 WinApi.ClickLeftMouse(element);
                 clicked = true;
                 break;
             }
             Thread.Sleep(1000);
         }
         if (!clicked)
         {
             throw new Exception(string.Format("Click fail: {0} cannot be clicked.", id));
         }
     }
     catch
     {
         if (arguments.Contains("-i"))
         {
             return;
         }
         throw;
     }
 }