19using System.Collections.Generic;
20using System.Diagnostics;
24using System.Threading;
25using System.Threading.Tasks;
26using System.Windows.Automation;
48 public class Application
85 public delegate CallIfStatus
CallIfDelegate(Application application, List<IGPALAutomationElement> foundElements, List<IGPALAutomationElement> matchedElements,
Selector selector,
bool matchedAll);
113 #region <Working Variables>
117 internal ApplicationSettings applicationSettings {
get;
set; }
118 private dynamic persistenceList;
122 internal UnitOfWork CurrentUOW {
get;
set; } =
null;
124 #endregion <Working Variables>
164 persistenceList =
new List<UnitOfWork>
168 applicationSettings =
new ApplicationSettings(
this);
176 private bool CheckWaitFor()
178 bool matchFound =
true;
179 List<GPALAutomationElement> foundElements =
null;
184 if (
null != CurrentUOW.WaitForSatisfied)
186 GPAL.PublishSimpleEvent(GPALEventType.DEBUG, $
"Selectors for this unit of work already found at [{CurrentUOW.WaitForSatisfied:HH:mm:ss.fff}], skipping redundant wait.",
this, GPALObjectType.Application);
190 if (WaitTime.Never < CurrentUOW.WaitForInMs)
193 foundElements = ElementHelper.WaitFor(
this, CurrentUOW.WaitForInMs, out matchFound);
195 if (0 < foundElements?.Count)
196 CurrentUOW.WaitForSatisfied = DateTime.Now;
207 private bool InAction(
bool checkWaitFor)
209 ApplicationHelper.TopProcess(this.
Process);
211 CurrentUOW.ActionCalled =
true;
213 SelectorListMaintenanceSweep(CurrentUOW);
214 SelectorListMaintenanceSweep(persistentUOW);
215 CheckPersistentSelectors();
218 if (
true == checkWaitFor)
231 private static void SelectorListMaintenanceSweep(dynamic CurrentUOW)
233 for (
int idx = 0; idx < CurrentUOW.WithSelectorList.Count; idx++)
234 if (
true == CurrentUOW.WithSelectorList[idx].DeleteMe)
235 CurrentUOW.WithSelectorList.RemoveAt(idx);
237 for (
int idx = 0; idx < CurrentUOW.InSelectorList.Count; idx++)
238 if (
true == CurrentUOW.InSelectorList[idx].DeleteMe)
239 CurrentUOW.InSelectorList.RemoveAt(idx);
245 private void CheckPersistentSelectors()
248 if (0 < (persistentUOW.WithSelectorList?.Count ?? 0))
249 foreach (Selector selector
in persistentUOW.WithSelectorList)
250 ElementHelper.FindElements(
this, persistentUOW, selector, out
bool matchedAll, out List<GPALAutomationElement> elems);
253 #region <Application Actions>
293 if (
true == InAction(
true))
294 ApplicationHelper.ResizeWindow(ApplicationSettings.LastWindowHandle, width, height);
302 if (
true == InAction(
true))
316 DatabaseHelper.TokenizeDatabase(CurrentUOW, inputDatabase);
317 if (
true == InAction(
true))
331 ((IGPALFileInternal)inputFile).TokenList =
FileHelper.TokenizeFile(CurrentUOW, inputFile);
333 if (
true == InAction(
true))
348 if (
true == InAction(
true))
361 if (
true == InAction(
true))
362 ElementHelper.FillInFrom(
this, textToUse, WriteMode.Append);
374 IntPtr processHandle = IntPtr.Zero;
376 StringBuilder parameters =
new StringBuilder();
379 foreach (
string parameter
in applicationSettings.Parameters)
382 parameters.Append(
" ");
385 parameters.Append(parameter);
390 GPAL.
PublishSimpleEvent(GPALEventType.ERROR,
"Unable to Open/control more than one program. Please use another Application.",
this, GPALObjectType.Application);
400 processes =
Process.GetProcessesByName(Path.GetFileNameWithoutExtension(applicationPath));
401 bool attached =
false;
402 if (
null != processes && 0 < processes.Length)
406 foreach (
Process process
in processes)
408 applicationSettings.Process = process;
409 AutomationElement existingRoot = WaitForRootAutomationElement(process, 2000);
410 if (
null != existingRoot)
412 applicationSettings.RootAutomationElement = existingRoot;
413 processHandle = process.MainWindowHandle;
420 if (
false == attached)
422 applicationSettings.Process =
Process.Start(applicationPath, parameters.ToString());
426 AutomationElement root = WaitForRootAutomationElement(applicationSettings.Process,
427 Math.Max(1, applicationSettings.WaitForWindowTimeout) * 1000);
431 string msg = $
"Timed out after [{applicationSettings.WaitForWindowTimeout}]s waiting for the main window / root automation element of [{applicationPath}].";
436 applicationSettings.RootAutomationElement = root;
437 processHandle = applicationSettings.Process.MainWindowHandle;
442 GPAL.
PublishSimpleEvent(GPALEventType.EXCEPTION, $
"Unable to launch [{applicationPath}].",
this, GPALObjectType.Application, ex);
446 if (
null == applicationSettings.Process)
447 GPAL.
PublishSimpleEvent(GPALEventType.ERROR, $
"Unable to launch [{applicationPath}].",
this, GPALObjectType.Application);
451 CurrentUOW.ActionCalled =
true;
464 private AutomationElement WaitForRootAutomationElement(
Process process,
int timeoutMs)
469 Stopwatch stopwatch = Stopwatch.StartNew();
473 try { process.WaitForInputIdle(timeoutMs); }
catch { }
475 while (stopwatch.ElapsedMilliseconds < timeoutMs)
480 IntPtr handle = process.MainWindowHandle;
481 if (IntPtr.Zero != handle)
483 AutomationElement root = AutomationElement.FromHandle(handle);
517 DatabaseHelper.TokenizeDatabase(CurrentUOW, inputDatabase);
519 if (
true == InAction(
true))
534 ((IGPALFileInternal)inputFile).TokenList =
FileHelper.TokenizeFile(CurrentUOW, inputFile);
535 if (
true == InAction(
true))
549 if (
true == InAction(
true))
561 if (
true == InAction(
true))
562 ElementHelper.FillInFrom(
this, textToUse, WriteMode.Overwrite);
574 if (
true == InAction(
true))
575 ElementHelper.Focus(
this);
588 if (
true == InAction(
true))
589 ElementHelper.Hover(
this, CurrentUOW);
601 if (
true == InAction(
true))
602 ElementHelper.FillInFrom(
this, textToUse, WriteMode.Insert);
615 DatabaseHelper.TokenizeDatabase(CurrentUOW, inputDatabase);
616 if (
true == InAction(
true))
630 if (
true == InAction(
true))
644 ((IGPALFileInternal)inputFile).TokenList =
FileHelper.TokenizeFile(CurrentUOW, inputFile);
645 if (
true == InAction(
true))
658 if (
true == InAction(
true))
659 ElementHelper.LeftClick(
this);
669 if (
true == InAction(
true))
670 ElementHelper.LeftClick(
this, modifierKeys);
681 if (
true == InAction(
true))
682 ElementHelper.GenericClick(
this, ClickType.LeftDoubleClick);
693 if (
true == InAction(
true))
694 ElementHelper.GenericClick(
this, ClickType.MiddleClick);
705 if (
true == InAction(
true))
706 ElementHelper.MoveTo(
this);
717 if (
true == InAction(
true))
718 ElementHelper.DragAndDrop(
this);
729 if (
true == InAction(
true))
730 ElementHelper.DragAndDrop(
this, modifierKeys);
741 HardwareHelper.PressModifierKey(modifierKeys);
752 HardwareHelper.ReleaseModifierKeys(modifierKeys);
777 if (
true == InAction(
true))
778 HardwareHelper.SendKey(VKCode);
799 if (
true == InAction(
true))
800 ElementHelper.SwitchToTab(
this);
810 if (
true == InAction(
true))
811 ElementHelper.SetRange(
this, rangeValue);
823 if (
true == InAction(
true))
824 ElementHelper.GenericClick(
this, ClickType.RightClick);
840 if (
true == CurrentUOW.ActionCalled)
841 Thread.Sleep(timeoutInTicks);
843 CurrentUOW.WaitForInMs = timeoutInTicks;
856 if (
true == InAction(
true))
857 ApplicationSettings.LastWindowHandle = FormHelper.WaitForWindow(windowTitle, ApplicationSettings.WaitForWindowTimeout);
869 if (
true == InAction(
true))
870 ApplicationSettings.LastWindowHandle = FormHelper.WaitForWindowRegex(windowTitleRegex, ApplicationSettings.WaitForWindowTimeout);
881 for (; 0 < iterations; iterations--)
882 ElementHelper.Scroll(
this, ScrollAmount.SmallIncrement, ScrollTypes.Increments, ScrollTypes.Horizontal);
884 for (; 0 > iterations; iterations++)
885 ElementHelper.Scroll(
this, ScrollAmount.SmallDecrement, ScrollTypes.Increments, ScrollTypes.Horizontal);
897 for (; 0 < iterations; iterations--)
898 ElementHelper.Scroll(
this, ScrollAmount.LargeIncrement, ScrollTypes.Increments, ScrollTypes.Horizontal);
900 for (; 0 > iterations; iterations++)
901 ElementHelper.Scroll(
this, ScrollAmount.LargeDecrement, ScrollTypes.Increments, ScrollTypes.Horizontal);
911 if (0 > percent || 100 < percent)
913 GPAL.
PublishSimpleEvent(GPALEventType.WARNING, $
"Invalid percantage value [{percent}], unable to scroll using supplied values. Normalizing to nearest endpoint.",
this, GPALObjectType.Application);
914 int newPercent = (0 > percent ? 0 : (100 < percent ? 100 : percent));
916 ElementHelper.Scroll(
this, percent, ScrollTypes.Percent, ScrollTypes.Horizontal);
927 for (; 0 < iterations; iterations--)
928 ElementHelper.Scroll(
this, ScrollAmount.SmallIncrement, ScrollTypes.Increments, ScrollTypes.Vertical);
930 for (; 0 > iterations; iterations++)
931 ElementHelper.Scroll(
this, ScrollAmount.SmallDecrement, ScrollTypes.Increments, ScrollTypes.Vertical);
943 for (; 0 < iterations; iterations--)
944 ElementHelper.Scroll(
this, ScrollAmount.LargeIncrement, ScrollTypes.Increments, ScrollTypes.Vertical);
946 for (; 0 > iterations; iterations++)
947 ElementHelper.Scroll(
this, ScrollAmount.LargeDecrement, ScrollTypes.Increments, ScrollTypes.Vertical);
957 ElementHelper.Scroll(
this, percent, ScrollTypes.Percent, ScrollTypes.Vertical);
960 #endregion <Application Actions>
968 CurrentUOW.AppCallIfFound.Remove(func);
969 CurrentUOW.AppCallIfNotFound.Remove(func);
972 foreach (
Selector selector
in CurrentUOW.WithSelectorList)
974 selector.SelectorSettings.AppCallIfFound.Remove(func);
975 selector.SelectorSettings.AppCallIfNotFound.Remove(func);
978 foreach (
Selector selector
in CurrentUOW.InSelectorList)
980 selector.SelectorSettings.AppCallIfFound.Remove(func);
981 selector.SelectorSettings.AppCallIfNotFound.Remove(func);
984 persistentUOW.AppCallIfFound.Remove(func);
985 persistentUOW.AppCallIfNotFound.Remove(func);
987 foreach (
Selector selector
in persistentUOW.WithSelectorList)
989 selector.SelectorSettings.AppCallIfFound.Remove(func);
990 selector.SelectorSettings.AppCallIfNotFound.Remove(func);
994 #region <Application Settings>
1016 persistentUOW.AppCallIfFound.Add(persistentCallIfFound);
1031 persistentUOW.AppCallIfNotFound.Add(persistentCallIfNotFound);
1048 if (
true == CurrentUOW.ActionCalled)
1051 persistenceList.Add(persistentUOW);
1054 selector.Application =
this;
1056 persistentUOW.WithSelectorList.Add(selector);
1069 selector.ElementsFoundAndMatchedCount = 0;
1071 if (
true == CurrentUOW.ActionCalled)
1079 ApplicationSettings.MySelector = selector;
1081 CurrentUOW.WithSelectorList.Add(ApplicationSettings.MySelector);
1100 CurrentUOW.WithAllThatMatch = rowCount;
1104 #region <GetGrid / SaveTo / Pagination>
1121 CurrentUOW.GetGridCalled =
true;
1122 CurrentUOW.RetGrid.Clear();
1124 if (!TryGetGridFromControl())
1125 GetGridFromSelectors();
1130 if (
null == returnGrid)
1131 returnGrid = (IGPALGrid<string>)CurrentUOW.RetGrid;
1133 returnGrid.Add((IGPALGrid<string>)CurrentUOW.RetGrid);
1141 private bool TryGetGridFromControl()
1143 if (1 != CurrentUOW.WithSelectorList.Count
1144 || SelectorType.Selector != CurrentUOW.WithSelectorList[0].selectorSettings.SelectorType)
1147 Selector sel = CurrentUOW.WithSelectorList[0];
1148 bool matchedAll; List<GPALAutomationElement> matched;
1149 var found = ElementHelper.FindElements(
this, CurrentUOW, sel, out matchedAll, out matched);
1150 AutomationElement ae = (
null != found && found.Count > 0) ? found[0].Ae : null;
1152 if (
null == ae || !ae.TryGetCurrentPattern(GridPattern.Pattern, out gpObj))
1155 GridPattern grid = (GridPattern)gpObj;
1156 int rows = grid.Current.RowCount;
1157 int cols = grid.Current.ColumnCount;
1159 List<string> headers =
null;
1161 if (ae.TryGetCurrentPattern(TablePattern.Pattern, out tpObj))
1163 AutomationElement[] colHeaders = ((TablePattern)tpObj).Current.GetColumnHeaders();
1164 if (
null != colHeaders && colHeaders.Length > 0)
1166 headers =
new List<string>();
1167 foreach (AutomationElement h
in colHeaders)
1168 headers.Add(h.GetText() ??
string.Empty);
1172 int cap = (int.MaxValue == CurrentUOW.WithAllThatMatch)
1175 for (
int r = 0; r < rows && CurrentUOW.RetGrid.Count() < cap; r++)
1177 var row =
new List<string>(cols);
1178 for (
int c = 0; c < cols; c++)
1183 AutomationElement cell = grid.GetItem(r, c);
1184 text = (
null != cell) ? (cell.GetText() ??
string.Empty) : GPAL.ErrorPlaceholder;
1188 text = GPAL.ErrorPlaceholder;
1192 CurrentUOW.RetGrid.AddRow(row);
1195 if (
null != headers && headers.Count > 0
1196 && (
null == CurrentUOW.HeaderList || 0 == CurrentUOW.HeaderList.Count))
1197 CurrentUOW.HeaderList = headers;
1199 GPAL.PublishSimpleEvent(GPALEventType.INFO, $
"GetGrid: [{sel.Name}] resolved to a UIA grid ([{rows}] x [{cols}]).",
this, GPALObjectType.Application);
1206 private void GetGridFromSelectors()
1208 var names =
new List<string>();
1209 foreach (Selector s
in CurrentUOW.WithSelectorList)
1212 var seenRows =
new HashSet<string>();
1213 bool capReached =
false;
1214 int cap = (int.MaxValue == CurrentUOW.WithAllThatMatch)
1217 for (
int page = 0; page < CurrentUOW.PageCount && !capReached; page++)
1219 var columns =
new List<List<string>>();
1222 foreach (Selector sel
in CurrentUOW.WithSelectorList)
1224 var col =
new List<string>();
1225 if (SelectorType.Selector == sel.selectorSettings.
SelectorType)
1227 bool matchedAll; List<GPALAutomationElement> matched;
1228 var found = ElementHelper.FindElements(
this, CurrentUOW, sel, out matchedAll, out matched);
1229 List<GPALAutomationElement> elems =
1230 (!matchedAll &&
null != matched && matched.Count > 0)
1232 : (null != found ? found.ToList() : new List<GPALAutomationElement>());
1233 foreach (GPALAutomationElement e
in elems)
1234 col.Add((
null != e.Ae) ? (e.Ae.GetText() ??
string.Empty) : GPAL.ErrorPlaceholder);
1236 else if (SelectorType.Data == sel.selectorSettings.
SelectorType)
1238 else if (SelectorType.DataFunc == sel.selectorSettings.
SelectorType)
1239 col.Add(sel.selectorSettings.DataFunction());
1242 if (col.Count > maxRows) maxRows = col.Count;
1246 for (
int i = 0; i < columns.Count; i++)
1247 while (columns[i].Count < maxRows)
1248 columns[i].Add($
"{GPAL.ErrorPlaceholder} : {names[i]}");
1250 for (
int r = 0; r < maxRows && !capReached; r++)
1252 var row =
new List<string>(columns.Count);
1253 for (
int c = 0; c < columns.Count; c++)
1254 row.Add(columns[c][r]);
1256 string key =
string.Join(
"", row);
1257 if (!seenRows.Add(key))
1259 CurrentUOW.RetGrid.AddRow(row);
1260 if (CurrentUOW.RetGrid.Count() >= cap)
1264 if (!capReached && page < CurrentUOW.PageCount - 1)
1265 if (!ApplicationHelper.GotoNextPage(
this))
1267 GPAL.PublishSimpleEvent(GPALEventType.INFO, $
"GetGrid: no next page after page [{page + 1}].",
this, GPALObjectType.Application);
1272 if (
null == CurrentUOW.HeaderList || 0 == CurrentUOW.HeaderList.Count)
1273 CurrentUOW.HeaderList = names;
1279 if (
true == CurrentUOW.GetGridCalled)
1281 CurrentUOW.GetGridCalled =
false;
1282 CurrentUOW.HeaderList.Clear();
1284 CurrentUOW.HeaderList.Add(header);
1291 CurrentUOW.RetGrid = gridToSave;
1298 CurrentUOW.NextPageButton = selector;
1307 CurrentUOW.InfiniteScroll =
true;
1315 CurrentUOW.PageCount = numberOfPages;
1327 private List<string> ResolveHeaderColumns(
GPALFile file)
1329 List<string> selectorNames = CurrentUOW.WithSelectorList?.Where(s =>
null != s.
Name).Select(s => s.
Name).ToList()
1330 ??
new List<string>();
1332 List<string> fileColumns =
new List<string>();
1333 IGPALGrid<string> columnList = ((IGPALFileInternal)file).FileSettings.ColumnList;
1334 if (
null != columnList && 0 < columnList.Count() &&
null != columnList[0])
1335 fileColumns =
new List<string>(columnList[0]);
1337 List<string> resolved = (
null != CurrentUOW.HeaderList && 0 < CurrentUOW.HeaderList.Count)
1338 ?
new List<string>(CurrentUOW.HeaderList)
1339 :
new List<string>();
1340 for (
int i = resolved.Count; i < fileColumns.Count; i++)
1341 resolved.Add(fileColumns[i]);
1342 for (
int i = resolved.Count; i < selectorNames.Count; i++)
1343 resolved.Add(selectorNames[i]);
1353 GPAL.
PublishSimpleEvent(GPALEventType.INFO, $
"Saving [{CurrentUOW.RetGrid?.Rows ?? 0}] rows of window data to [{file?.Filename}].",
this, GPALObjectType.Application);
1355 var converter =
GPAL.
Converter.WithInput(CurrentUOW.RetGrid).WithColumnNames(ResolveHeaderColumns(file));
1358 if (
null != CurrentUOW.HeaderList && 0 < CurrentUOW.HeaderList.Count)
1359 converter.WithFirstLineHasColumnNames(
true);
1360 converter.SaveTo(file);
1370 GPAL.
PublishSimpleEvent(GPALEventType.INFO, $
"Appending [{CurrentUOW.RetGrid?.Rows ?? 0}] rows of window data to [{file?.Filename}].",
this, GPALObjectType.Application);
1372 GPAL.
Converter.WithInput(CurrentUOW.RetGrid).WithColumnNames(ResolveHeaderColumns(file)).AppendTo(file);
1375 #endregion <GetGrid / SaveTo / Pagination>
1383 ApplicationSettings.WaitForWindowTimeout = waitTimeInSeconds;
1393 ApplicationSettings.Parameters.Add(parameter);
1403 ApplicationSettings.UseHardware = trueFalse;
1418 CurrentUOW.AppCallIfFound.Add(callIfFoundDelegate);
1433 CurrentUOW.AppCallIfNotFound.Add(callIfNotFoundDelegate);
1445 CurrentUOW.AppCallAfterFillIn = callAfterFillIn;
1448 #region <Getters/Setters>
1459 return applicationSettings.Process;
1463 applicationSettings.Process = value;
1473 return applicationSettings.ManagedRootAutomationElement;
1478 applicationSettings.ManagedRootAutomationElement = value;
1488 return applicationSettings.RootAutomationElement;
1493 applicationSettings.RootAutomationElement = value;
1506 return ApplicationSettings.Name;
1511 ApplicationSettings.Name = value;
1523 return applicationSettings.ApplicationPath;
1527 applicationSettings.ApplicationPath = value;
1534 internal ApplicationSettings ApplicationSettings
1538 return applicationSettings;
1541 #endregion <Getters/Setters>
1542 #endregion <Application Settings>
Application object that contains the fluent methods to create your Application workflow....
string ApplicationPath
The path of the program you Opened. This get is intended for debugging only.
IAllowSelectorActionOrAnySelector SendKey(byte VKCode)
Type special characters like Enter, Page Up, Page Down, Tab, etc. Use GPAL.VK constants for ease of ...
IAllowSelectorActionOrAnySelector FillInFrom(GPALFile inputFile)
FillIn data from the file overwriting text in the input Selector(s) defined in the UOW One token (on...
IAllowAfterWaitForAndSizeControl WithWaitForWindowTimeout(int waitTimeInSeconds)
Define the time in seconds to WaitForWindow/Regex.
IAllowApplicationSettingsOrOpen WithParameter(string parameter)
Define the parameters to use in the Open command.
IAllowSelectorActionOrAnySelector ScrollHorizontalPercent(int percent)
Element's horizontal scroll position as a percentage of the total content area within the AutomationE...
IAllowAllActionAndAnySelector SwitchToTab(Selector selector=null)
Switch to any TabControl defined in the current UOW. This will hardware click the tab control if the ...
IAllowSelectorActionOrAnySelector DragAndDrop(ModifierKeys modifierKeys)
Performs a drag from the source element to the target element, both found via Selector(s) defined in ...
object ManagedRootAutomationElement
The root UI Automation element (AutomationElement) for the managed application's main window.
IAllowApplicationSettingsOrOpen WithName(string appName)
Sets the application's name, used when publishing events.
IAllowWithPagesAndGridActions WithInfiniteScroll
Scroll to load more rows between pages. Not supported for desktop apps (single page).
IAllowSelectorActionOrAnySelector ScrollHorizontalSmall(int iterations=1)
Scroll the element horizontally in a small increment. https://docs.microsoft.com/en-us/windows/win32...
IAllowAfterAnySelector CallIfNotFound(Application.CallIfDelegate callIfNotFoundDelegate)
Add a Unit of Work level CallIfNotFound handler to be called if any defined selectors DO NOT find/mat...
IAllowSelectorActionOrAnySelector DragAndDrop(Selector selector=null)
Performs a drag from the source element to the target element, both found via Selector(s) defined in ...
Application ToGPALObject()
Return a GPAL.Application object so that GPAL.Application does not have to be cast.
IAllowAllActionAndAnySelector SetRange(double rangeValue)
Set the value of a range-based control (e.g. a slider) found via Selector(s) defined in the UOW.
IAllowPersistentCallBack PersistentCallIfFound(CallIfDelegate persistentCallIfFound)
Add a persistent CallIfFound handler to be called if any defined persistent selectors find/match elem...
IAllowAllApplicationAndAllSelector Restore
Restore the application to 'original' size, unminimize.
IAllowAfterAnySelector CallIfFound(Application.CallIfDelegate callIfFoundDelegate)
Add a Unit of Work level CallIfFound handler to be called if any defined selectors find/match element...
IAllowSelectorActionOrAnySelector PressModifierKey(ModifierKeys modifierKeys)
Press and hold a modifier key (Alt, Control, Shift) using hardware emulation.
IAllowSelectorActionOrAnySelector SendString(string textToSend)
Send the string using hardware emulation.
IAllowSelectorActionOrAnySelector Hover(Selector selector=null)
Hover the mouse over the current element found via the Selector. Only the first element per Selector ...
IAllowAfterWaitForAndSizeControl WaitForWindowRegex(string windowTitleRegex)
Wait for a Windows window with title that matches the regex pattern to appear on the desktop....
IAllowAfterWaitForAndSizeControl WaitFor(int timeoutInTicks)
Either wait the amount of time specified or wait UP TO the amount of time specified waiting for eleme...
IAllowSelectorActionOrAnySelector ReleaseModifierKey(ModifierKeys modifierKeys)
Release a previously pressed modifier key (Alt, Control, Shift) using hardware emulation.
IAllowSelectorActionOrAnySelector InsertFrom(IGPALGrid< string > inputGrid)
Insert the data from the grid at the beginning of the text in the input Selector(s) defined in the UO...
IAllowAfterAnySelector CallAfterFillIn(CallAfterFillInDelegate callAfterFillIn)
Add a handler to call after a row of tokens is consumed and after all inputs are filled in with data....
IAllowSelectorActionOrAnySelector LeftClick(Enums.ModifierKeys modifierKeys)
Left click the element found for Selector(s) defined in the UOW, optionally emulating pressing a modi...
string Name
A name you provide to be used when publishing events. Use .WithName to provide your own friendly nam...
IAllowSelectorActionOrAnySelector InsertFrom(GPALDatabase inputDatabase)
Insert the text from the database at the beginning of the input Selector(s) defined in the UOW One t...
IAllowAfterWaitForAndSizeControl WaitForWindow(string windowTitle)
Wait for a Windows window with title to appear on the desktop. Used in conjunction with ....
IAllowSelectorActionOrAnySelector FillInFrom(GPALDatabase inputDatabase)
FillIn data from the database overwriting text in the input Selector(s) defined in the UOW One token...
IAllowApplicationSettingsOrOpen WithUseHardware(bool trueFalse)
Force all workflow element interactions to use hardware emulation (UIAutomation is default).
IAllowAllApplicationAndAllSelector MoveWindow(int x, int y)
Move the window last matched by WaitForWindow to the specified screen coordinates.
IAllowSelectorActionOrAnySelector FillInFrom(string textToUse)
FillIn the text from the string overwriting text in the first input in the UOW. Should probably only ...
delegate CallIfStatus CallAfterFillInDelegate(Application application, IGPALGrid< string > tokens, int tokenIdx)
Delegate callback for the CallAfterFillIn EventHandler which will be invoked after each row of tokens...
IAllowSelectorActionOrAnySelector InsertFrom(string textToUse)
Insert the text from the string at the beginning of the first input in the UOW. Should probably only ...
IAllowSelectorActionOrAnySelector Focus(Selector selector=null)
Focus the current element found via the Selector. Only the first element per Selector found will be f...
delegate CallIfStatus CallIfDelegate(Application application, List< IGPALAutomationElement > foundElements, List< IGPALAutomationElement > matchedElements, Selector selector, bool matchedAll)
Delegate callback for the CallIfFound/CallIfNotFound EventHandlers which will be invoked when a selec...
IAllowSelectorActionOrAnySelector LeftClick(Selector selector=null)
Left click the element found for Selector(s) defined in the UOW One left click for the first element...
IAllowSelectorActionOrAnySelector RightClick(Selector selector=null)
Right click the element found for Selector(s) defined in the UOW One right click for the first eleme...
IAllowSelectorActionOrAnySelector MiddleClick(Selector selector=null)
Middle click the element found for Selector(s) defined in the UOW.
IAllowAllApplicationAndAllSelector Minimize
Minimize the application to the taskbar.
IAllowWithHeaderOrFileActions WithGridToSave(IGPALGrid< string > gridToSave)
Supply a GPALGrid (perhaps built elsewhere) to be saved by a following SaveTo*.
IAllowAllActionAndAnySelector AppendTo(GPALFile file)
Append the retrieved grid. The output format and delimiter are determined by the GPALFile (its extens...
IAllowSelectorActionOrAnySelector WithSelector(Selector selector)
Add a selector to the current UOW. Selectors make up a Unit of Work (UOW) to perform actions upon....
IAllowSelectorActionOrAnySelector ScrollVerticalLarge(int iterations=1)
Scroll the element vertically in a large increment. https://docs.microsoft.com/en-us/windows/win32/a...
IAllowAfterAnySelectorExceptWithAll WithAllThatMatch(int rowCount=int.MaxValue)
Indicates the Selectors refer to/match repeating, multiple elements on the page. Use after all your ...
IAllowSelectorActionOrAnySelector FillInFrom(IGPALGrid< string > inputGrid)
FillIn data from the grid overwriting text in the input Selector(s) defined in the UOW One token (on...
IAllowGetGridAndFillInFrom WithPages(int numberOfPages)
Number of result pages to retrieve. Use with WithNextPageButton.
IAllowSelectorActionOrAnySelector ScrollVerticalPercent(int percent)
Element's vertical scroll position as a percentage of the total content area within the AutomationEle...
IAllowSelectorActionOrAnySelector LeftDoubleClick(Selector selector=null)
Left double click the element found for Selector(s) defined in the UOW.
IAllowAllApplicationAndAllSelector ResizeWindow(int width, int height)
Resize the window last matched by WaitForWindow to the specified pixel dimensions.
Process Process
The current Windows process for the program run via Open. Only one program can be Opened/controlled ...
IAllowAllActionAndAnySelector SaveTo(GPALFile file)
Save the retrieved grid. The output format and delimiter are determined by the GPALFile (its extensio...
IAllowSelectorActionOrAnySelector AppendFrom(GPALDatabase inputDatabase)
Append the data from the database to the end of the input Selectors defined in the UOW One token (on...
IAllowSelectorActionOrAnySelector AppendFrom(GPALFile inputFile)
Append the data from the input file to the end of the input Selectors defined in the UOW One token (...
IAllowSelectorActionOrAnySelector AppendFrom(string textToUse)
Append the given text to the first input in the UOW. Should probably only be used with one selector a...
AutomationElement RootAutomationElement
The starting AutomationElement for the application. All xpath searches start from this AutomationElem...
IAllowSelectorActionOrAnySelector InsertFrom(GPALFile inputFile)
Insert the data from the file at the beginning of the text in the input Selector(s) defined in the UO...
IAllowAllExceptParameters Open([Directory()] string applicationPath)
Launch the application specified in the path. Find the root automation element and place into applic...
IAllowSelectorActionOrAnySelector ScrollHorizontalLarge(int iterations=1)
Scroll the element horizontally in a large increment. https://docs.microsoft.com/en-us/windows/win32...
IAllowPersistence WithPersistentSelector(Selector selector)
Add a persistent selector to the persistent UOW. Persistent selectors are always looked for whenever ...
IAllowSelectorActionOrAnySelector MoveTo(Selector selector=null)
Move the mouse cursor to the element found for Selector(s) defined in the UOW.
IAllowAllApplicationAndAllSelector Maximize
Maximize the application to full-screen.
IAllowPersistentCallBack PersistentCallIfNotFound(CallIfDelegate persistentCallIfNotFound)
Add a persistent CallIfNotFound handler to be called if any defined persistent selectors DO NOT find/...
IAllowSelectorActionOrAnySelector AppendFrom(IGPALGrid< string > inputGrid)
Append the data from the input grid to the end of the input Selectors defined in the UOW One token (...
void RemoveCallIfHandlerEverywhere(Application.CallIfDelegate func)
Helper method for GPAL applications to remove a handler from all UOWs. Envisioned to be used in a per...
IAllowWithHeaderOrFileActions GetGrid(ref IGPALGrid< string > returnGrid)
Retrieve the current selectors' data (or a table/grid control's data) into a GPALGrid....
IAllowWithHeaderOrFileActions WithHeader(string header)
Column header for exported data. Overrides selector names / table headers, in order.
IAllowSelectorActionOrAnySelector ScrollVerticalSmall(int iterations=1)
Scroll the element vertically in a small increment. https://docs.microsoft.com/en-us/windows/win32/a...
IAllowWithPagesAndGridActions WithNextPageButton(Selector selector)
The control to click to load the next page when paging through results.
void Close()
Close/terminate the application. This terminates the fluent interface and nothing can be chained to ...
static void TopProcess(Process process)
Brings the given process's main window to the foreground/top of the z-order, if it is not already.
static void FillInWithTokens(Application.Application application, List< IGPALGrid< string > > tokenList, WriteMode writeMode)
Enter tokens into form controls for each grid of tokens in the list.
File-side plumbing behind the fluent chain: writing a unit of work's data out in a delimited format,...
Class to define database usage. Currently only used for input from a table, sql or stored procedure....
IGPALGrid< string > Tokens
The rows/columns returned from the database. Tokens are loaded upon calling any [Append/FillIn/Inser...
Thrown where GPAL deliberately ends the workflow, such as a CallIf handler returning CallIfStatus....
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
static IAllowConverterInput Converter
New GPAL Convertor.
static void PublishSimpleEvent(GPALEventType gPALEventType, string msg, dynamic gPALObject=null, Enums.GPALObjectType gPALObjectType=GPALObjectType.None, Exception ex=null)
Publish a message to either the information channel or exception channel (if exception passed in) Pub...
GPAL Selector used to locate Application and Browser elements. Instantiated with GPAL....
string SelectorPath
Returns the first defined selector path string.
string Name
The name you gave this selector, or one assigned by GPAL [selector1, selector2...] Used in Informati...
SelectorType SelectorType
Type of selector: A selector for an element, or literal data or a data function for dynamic data not ...
Everything revolves around the Unit of Work. A Unit of Work is defined as one or more selectors betw...
IAllowSelectorActionOrAnySelector SendString(string textToSend)
Simulates typing via hardware key events, one character at a time. Honors GPAL.TypingDelay (see GPAL....