GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
Interfaces.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using System;
18using System.Collections.Generic;
19using System.Drawing;
20using System.Linq;
21using System.Text;
22using System.Threading.Tasks;
23using OpenQA.Selenium;
25using static GenerallyPositive.Enums;
26using static GenerallyPositive.GPAL;
28using System.Windows.Automation;
29
31{
32 #region <Application Interfaces>
33 #region <Base Application Interfaces>
34 public interface IAllowPersistentCallBack
35 {
36 // return values
37 // 0 = not handled
38 // 1 = handled
39 // -1 = error
40 [Callback(Description = "GLOBAL based callback if any selector in any UOW is found")]
41 IAllowPersistentCallBack PersistentCallIfFound(Application.CallIfDelegate CallIfFound);
42 [Callback(Description = "GLOBAL based callback if any selector in any UOW is NOT found")]
43 IAllowPersistentCallBack PersistentCallIfNotFound(Application.CallIfDelegate CallIfNotFound);
44 }
45
46 public interface IAllowFillInFrom
47 {
48 [Data(Description = "")] IAllowSelectorActionOrAnySelector FillInFrom(string textToUse);
49 [Data(Description = "")] IAllowSelectorActionOrAnySelector AppendFrom(string textToUse);
50 [Data(Description = "")] IAllowSelectorActionOrAnySelector InsertFrom(string textToUse);
51
52 [Data(Description = "")] IAllowSelectorActionOrAnySelector FillInFrom(GPALFile inputFile);
53 [Data(Description = "")] IAllowSelectorActionOrAnySelector AppendFrom(GPALFile inputFile);
54 [Data(Description = "")] IAllowSelectorActionOrAnySelector InsertFrom(GPALFile inputFile);
55
56 [Data(Description = "")] IAllowSelectorActionOrAnySelector FillInFrom(GPALDatabase inputDatabase);
57 [Data(Description = "")] IAllowSelectorActionOrAnySelector AppendFrom(GPALDatabase inputDatabase);
58 [Data(Description = "")] IAllowSelectorActionOrAnySelector InsertFrom(GPALDatabase inputDatabase);
59
60 [Data(Description = "")] IAllowSelectorActionOrAnySelector FillInFrom(IGPALGrid<string> inputGrid);
61 [Data(Description = "")] IAllowSelectorActionOrAnySelector AppendFrom(IGPALGrid<string> inputGrid);
62 [Data(Description = "")] IAllowSelectorActionOrAnySelector InsertFrom(IGPALGrid<string> inputGrid);
63 }
64 public interface IAllowClicks
65 {
66 [Action(Description = "")] IAllowSelectorActionOrAnySelector LeftClick(Selector selector = null);
67 [Action(Description = "")] IAllowSelectorActionOrAnySelector LeftClick(ModifierKeys modifierKeys);
68 [Action(Description = "")] IAllowSelectorActionOrAnySelector LeftDoubleClick(Selector selector = null);
69 [Action(Description = "")] IAllowSelectorActionOrAnySelector MiddleClick(Selector selector = null);
70 [Action(Description = "")] IAllowSelectorActionOrAnySelector RightClick(Selector selector = null);
71 [Action(Description = "Drag-and-drop using selector's DeltaX/DeltaY as the drag distance from the element's origin. Always uses hardware mouse events.")] IAllowSelectorActionOrAnySelector DragAndDrop(Selector selector = null);
72 [Action(Description = "Drag-and-drop while holding a modifier key.")] IAllowSelectorActionOrAnySelector DragAndDrop(ModifierKeys modifierKeys);
73 }
74 public interface IAllowKeyboardActions
75 {
82 [Data(Description = "")] IAllowSelectorActionOrAnySelector SendString(string textToSend);
83 [Data(Description = "")] IAllowSelectorActionOrAnySelector SendKey(byte VKCode);
84 IAllowSelectorActionOrAnySelector PressModifierKey(ModifierKeys modifierKeys);
85 IAllowSelectorActionOrAnySelector ReleaseModifierKey(ModifierKeys modifierKeys);
86 }
87 public interface IAllowScrolling
88 {
89 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollHorizontalSmall(int iterations);
90 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollHorizontalLarge(int iterations);
91 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollHorizontalPercent(int percent);
92 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollVerticalSmall(int iterations);
93 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollVerticalLarge(int iterations);
94 [Scroll(Description = "")] IAllowSelectorActionOrAnySelector ScrollVerticalPercent(int percent);
95 }
96 public interface IAllowCallBack
97 {
98 // return values
99 // 0 = not handled
100 // 1 = handled
101 // -1 = error
102 [Callback(Description = "UOW based callback if any selector in the UOW is found")]
103 IAllowAfterAnySelector CallIfFound(Application.CallIfDelegate CallIfFound);
104 [Callback(Description = "UOW based callback if any selector in the UOW is NOT found")]
105 IAllowAfterAnySelector CallIfNotFound(Application.CallIfDelegate CallIfNotFound);
106 [Callback(Description = "UOW based callback when a row of input is consumed and entered.\nUseful for chaining to another workflow")]
107 IAllowAfterAnySelector CallAfterFillIn(Application.CallAfterFillInDelegate CallAfterFillIn);
108 }
109
110 public interface IAllowSizeControl
111 {
112 [Action(Description = "")]
113 IAllowAllApplicationAndAllSelector Maximize { get; }
114 [Action(Description = "")]
115 IAllowAllApplicationAndAllSelector Minimize { get; }
116 [Action(Description = "")]
118 [Action(Description = "Resize the window matched by WaitForWindow to the given width and height in pixels.")]
119 IAllowAllApplicationAndAllSelector ResizeWindow(int width, int height);
120 [Action(Description = "Move the window matched by WaitForWindow to the given screen coordinates.")]
121 IAllowAllApplicationAndAllSelector MoveWindow(int x, int y);
122 }
123 public interface IAllowWaitForWindow
124 {
125 [Wait(Description = "")]
126 IAllowAfterWaitForAndSizeControl WaitForWindow(string windowName);
127 [Wait(Description = "")]
128 IAllowAfterWaitForAndSizeControl WaitForWindowRegex(string windowNameRegex);
129 [Wait(Description = "")]
130 IAllowAfterWaitForAndSizeControl WithWaitForWindowTimeout(int waitTimeInSeconds);
131
132 }
133 public interface IAllowTabActions
134 {
135 [Action(Description = "")] IAllowAllActionAndAnySelector SwitchToTab(Selector selector = null);
136 }
137 public interface IAllowApplicationOpen
138 {
139 [Fluent(Description = "")]
140 IAllowAllExceptParameters Open([Directory()] string ApplicationPath);
141 }
143 {
144 [Settings(Description = "Name to use in Information and Exception channel messages")]
145 IAllowApplicationSettingsOrOpen WithName(string name);
146 [Settings(Description = "Parameter to pass into the program (will be concatenated to one string)")]
147 IAllowApplicationSettingsOrOpen WithParameter(string parameter);
148 [Settings(Description = "Use hardwre emulation for the entire workflow")]
149 IAllowApplicationSettingsOrOpen WithUseHardware(bool trueFalse);
150 }
151 #endregion <Base Application Interfaces>
152 #region <Derived Application Interfaces>
167 // NOTE: Add to this list what is added above
175
176 public interface IAllowSelectorAction
186 , IAllowToGPALObject<Application>
187 { }
188
205 public interface IAllowFileActions
206 {
207 [File(Description = "Save the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
208 IAllowAllActionAndAnySelector SaveTo([GPALFile(Description = "")] GPALFile file);
209 [File(Description = "Append the retrieved grid. Output format and delimiter are determined by the GPALFile (its extension, or explicit file settings).")]
210 IAllowAllActionAndAnySelector AppendTo([GPALFile(Description = "")] GPALFile file);
211 }
237 public interface IAllowApplicationAction
241 { }
242 public interface IAllowAnySelector
244 { }
249
250 #endregion <Derived Application Interfaces>
251 #region <Application Atoms>
252 public interface IAllowToGPALObject<TResult>
253 {
254 [Fluent(Description = "Ends a declaration or workflow, returning a GPAL object which can be assigned. Use instead of an explicit cast. [ Selector mySel = GPAL.Selector.WithCSS(css).ToGPALObject() ]")]
255 TResult ToGPALObject();
256 }
258 {
259 [Selector(Description = "")]
260 IAllowPersistence WithPersistentSelector(Selector selector);
261 }
262 public interface IAllowWithSelector
263 {
264 [Selector(Description = "")]
265 IAllowSelectorActionOrAnySelector WithSelector(Selector selector);
266 }
267 public interface IAllowClose
268 {
269 [Action(Description = "")]
270 void Close();
271 }
272 public interface IAllowFocus
273 {
274 [Action(Description = "")] IAllowSelectorActionOrAnySelector Focus(Selector selector = null);
275 }
276 public interface IAllowHover
277 {
278 [Action(Description = "")] IAllowSelectorActionOrAnySelector Hover(Selector selector = null);
279 }
280 public interface IAllowWithAllThatMatch
281 {
282 [Settings(Description = "")]
283 IAllowAfterAnySelectorExceptWithAll WithAllThatMatch(int rowCount);
284 }
285 public interface IAllowMoveTo
286 {
287 [Action(Description = "")] IAllowSelectorActionOrAnySelector MoveTo(Selector selector = null);
288 }
289 public interface IAllowGetGrid
290 {
291 [Action(Description = "Retrieve data and add it into this GPALGrid. Pass a grid configured with .WithDedupeData(true) to skip duplicate rows. GPAL also keeps it internally for SaveTo*.")]
292 IAllowWithHeaderOrFileActions GetGrid(ref IGPALGrid<string> returnGrid);
293 }
294 public interface IAllowWaitFor
295 {
296 [Action(Description = "")]
297 IAllowAfterWaitForAndSizeControl WaitFor(int waitForTimeInTicks);
298 }
299 public interface IAllowWithHardware
300 {
301 IAllowAfterAnySelector WithHardware
302 {
303 [Settings(Description = "")]
304 get;
305 }
306 }
307 public interface IAllowWithHeader
308 {
309 [Settings(Description = "")]
310 IAllowWithHeaderOrFileActions WithHeader(string header);
311 }
312 public interface IAllowWithGridToSave
313 {
314 [Settings(Description = "")]
315 IAllowWithHeaderOrFileActions WithGridToSave(IGPALGrid<string> _);
316 }
318 {
319 [Data(Description = "When retrieving multiple pages of results, the control to click to load the next page.")]
320 IAllowWithPagesAndGridActions WithNextPageButton(Selector selector);
321 }
323 {
324 IAllowWithPagesAndGridActions WithInfiniteScroll
325 {
326 [Data(Description = "When retrieving multiple pages of results, scroll to load more rows. Not supported for desktop applications.")]
327 get;
328 }
329 }
330 public interface IAllowWithPages
331 {
332 [Data(Description = "Number of result pages to retrieve when paging through results.")]
333 IAllowGetGridAndFillInFrom WithPages(int numberOfPages);
334 }
342 { }
346 { }
347 public interface IAllowSetRange
348 {
349 [Data(Description = "Set the value of an input slider, number and other range/numeric inputs")]
350 IAllowAllActionAndAnySelector SetRange(double rangeValue);
351 }
352
353 #endregion <Application Atoms>
369 {
370 System.Diagnostics.Process Process { get; }
371 object ManagedRootAutomationElement { get; }
375 AutomationElement RootAutomationElement { get; }
382 string Name { get; }
388 string ApplicationPath { get; }
389 }
390 #endregion <Application Interfaces>
391 #region <Element Assistant Interfaces>
396 public interface IAllowElementActions
397 {
399 IAllowElementSettingsAndActions LeftClick(ModifierKeys modifierKeys);
400 IAllowElementSettingsAndActions LeftDoubleClick();
402 IAllowElementSettingsAndActions FillInFrom(string inputText);
403 IAllowElementSettingsAndActions InsertFrom(string inputText);
404 IAllowElementSettingsAndActions AppendFrom(string inputText);
405 IAllowElementSettingsAndActions SendKeyCode(byte keyCode);
406 IAllowElementSettingsAndActions PressModifierKey(ModifierKeys modifierKeys);
407 IAllowElementSettingsAndActions ReleaseModifierKey(ModifierKeys modifierKeys);
408 IAllowElementSettingsAndActions ScrollHorizontal(System.Windows.Automation.ScrollAmount scrollAmount);
409 IAllowElementSettingsAndActions ScrollHorizontalPercent(int percent);
410 IAllowElementSettingsAndActions ScrollVertical(System.Windows.Automation.ScrollAmount scrollAmount);
411 IAllowElementSettingsAndActions ScrolVerticalPercent(int percent);
412 }
413 public interface IAllowElementSetting
414 {
416 IAllowElementSettingsAndActions WithHardware { get; }
417 }
418 public interface IAllowForSelector { IAllowElementSetting ForSelector(Selector selector); };
419 #endregion <Element Assistant Interfaces>
420
421
422}
423
Application object that contains the fluent methods to create your Application workflow....
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...
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...
Class to define database usage. Currently only used for input from a table, sql or stored procedure....
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
Definition GPALFile.cs:36
Form object that contains the fluent methods to create interactive forms. Instatiated using GPAL....
Definition GPALForm.cs:64
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49
GPAL Selector used to locate Application and Browser elements. Instantiated with GPAL....
Definition Selector.cs:56
IAllowSelectorActionOrAnySelector SendString(string textToSend)
Simulates typing via hardware key events, one character at a time. Honors GPAL.TypingDelay (see GPAL....
string Name
A name you provide to be used when publishing events. Use .WithName to provide your own friendly nam...
string ApplicationPath
The path of the program you Opened. This get is intended for debugging only.
AutomationElement RootAutomationElement
The starting AutomationElement for the application. All xpath searches start from this AutomationElem...