### Start Recording Script
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/StartRecBehavior.sikuli/StartRecBehavior.html
This script checks for a specific image on the screen, clicks it if found, and then exits. It's used to automate the initiation of a recording process.
```Python
if not exists():
exit(1)
click()
sleep(1)
exit(0)
```
--------------------------------
### Console Execution Command Example
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/docs/index.md
This command demonstrates how to execute Vanessa Automation tests using a VAParams.json profile in a console environment. Ensure the paths to the 1C executable and the Vanessa Automation module are correct.
```bash
%V83PATH% /Execute C:\vanessa-automation\vanessa-automation.epf /TESTMANAGER /C"StartFeaturePlayer;VAParams=C:\VAParams.json"
```
--------------------------------
### Run EnjoyHint Tour
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_script_js/Ext/Template.txt
Initializes and runs an EnjoyHint tour using predefined sets. The EnjoyHint library is used for creating guided product tours. Ensure EnjoyHint and its configurations are properly set up before running.
```javascript
let enjoyhint = new EnjoyHint();
enjoyhint.set(sets);
enjoyjoyhint.run();
// $('.enjoyhint_close_btn').hide();
// setTimeout(() => (enjoyhint.stop()), 6000);
}
```
--------------------------------
### Get Label Element
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Creates and returns a jQuery object representing the label element with specified text and position.
```javascript
c.getLabelElement = function(b) {
return a("
", {
class: "enjoy_hint_label",
id: "enjoyhint_label"
}).css({
top: b.y + "px",
})
```
--------------------------------
### EnjoyHint Script Control Functions
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Provides functions to control the EnjoyHint script execution, including stopping, rerunning, starting, resuming, and setting the current step.
```javascript
var t = function() {
n++,
s()
}
, u = function() {
n--,
s()
}
, v = function() {
var b = m[n]
, c = a(b.selector);
y(b.event),
c.off(w(b.event)),
r()
}
, w = function(a, b) {
return a + (b ? "custom" : "") + ".enjoy_hint"
}
, x = function(a, b) {
o.on(w(a, !0), b)
}
, y = function(a) {
o.off(w(a, !0))
};
window.addEventListener("resize", function() {
null != d && o.enjoyhint("redo_events_near_rect", d[0].getBoundingClientRect())
}, !1),
e.stop = function() {
v()
}
,
e.reRunScript = function(a) {
n = a,
s()
}
,
e.runScript = function() {
n = 0,
l.onStart(),
s()
}
,
e.resumeScript = function() {
s()
}
,
e.setCurrentStep = function(a) {
n = a
}
,
e.getCurrentStep = function() {
return n
}
,
e.trigger = function(a) {
switch (a) {
case "next":
t();
break;
case "skip":
v();
break;
default:
o.trigger(w(a, !0))
}
}
,
e.setScript = function(a) {
if (!(a instanceof Array) && a.length < 1)
throw new Error("Configurations list isn't correct.");
m = a
}
,
e.set = function(a) {
e.setScript(a)
}
,
e.setSteps = function(a) {
e.setScript(a)
}
,
e.run = function() {
```
--------------------------------
### EnjoyHint API: Showing and Hiding Elements
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Control the visibility of the tutorial overlay and its components using `show` and `hide` methods. Specific buttons like next, previous, and skip can also be individually shown or hidden.
```javascript
show: function() {
return this.each(function() {
this.enjoyhint_obj.show()
}),
this
},
hide: function() {
return this.each(function() {
this.enjoyhint_obj.hide()
}),
this
},
hide_next: function() {
return this.each(function() {
this.enjoyhint_obj.hideNextBtn()
}),
this
},
hide_prev: function() {
return this.each(function() {
this.enjoyhint_obj.hidePrevBtn()
}),
this
},
show_prev: function() {
return this.each(function() {
this.enjoyhint_obj.showPrevBtn()
}),
this
},
show_next: function() {
return this.each(function() {
this.enjoyhint_obj.showNextBtn()
}),
this
},
hide_skip: function() {
return this.each(function() {
this.enjoyhint_obj.hideSkipBtn()
}),
this
},
show_skip: function() {
return this.each(function() {
this.enjoyhint_obj.showSkipBtn()
}),
this
}
```
--------------------------------
### Set Maximum Time to Find Window
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/docs/JsonParams/JsonParamsEN.md
Specifies the maximum duration Vanessa Automation will wait to find a window during a step. Example: `Then "WindowTitle" window is opened`.
```gherkin
timetofindwindow
```
--------------------------------
### Find and Click All Matches (Sikuli - Commented)
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/ClickCoordinates.sikuli/ClickCoordinates.html
This commented-out section demonstrates how to find all occurrences of an image on the screen, iterate through them, print their locations, click each one, and capture a region around each match. This is useful for automating interactions with multiple identical UI elements.
```Sikuli
#findAll("1492761928555.png")
#mm = SCREEN.getLastMatches()
#while mm.hasNext(): # loop as long there is a first and more matches
# TekMatch = mm.next()
# print "found: ", TekMatch # access the next match in the row
# location = TekMatch.getTarget()
# print "match",";",location.x,";",location.y
# click(location)
# sleep(1)
# print mm.x
# t1= capture(mm.getX(), mm.getY(), mm.getW(), mm.getH())
```
--------------------------------
### Wait and Click Image
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/SourceTree.sikuli/AutoClick.html
This snippet demonstrates how to wait for a specific image to appear on the screen and then click it. Ensure the image file (e.g., DownloadSour.png) is accessible to the script.
```sikuli
wait()
click()
```
--------------------------------
### Prevent Text Overwrite in Fields After Server Call
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/docs/JsonParams/JsonParamsEN.md
Enables a mechanism to prevent user-entered text in form fields from being overwritten after a server call completes. Requires the VAExtension installed.
```gherkin
DisableForFieldsAbilityToOverwriteTextWhenServerCall
```
--------------------------------
### Rendering and Button Logic in EnjoyHint
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
This snippet handles the rendering of tutorial elements, including labels and navigation buttons. It dynamically adjusts button positions based on window size and element visibility, and includes logic for rendering arrows and closing the tutorial.
```javascript
}
O = K + s / 2,
P = b.center_y > L + t / 2 ? L + t : L,
b.center_y < 0 ? N = 20 : b.center_y > window.innerHeight + 20 && (N = window.innerHeight - 20),
b.center_y >= L && b.center_y <= L + t && (O = b.center_x > K ? K + s : K,
P = b.center_y),
c.renderLabel({
x: K,
y: L,
text: b.text
}),
setTimeout(function() {
var a = c.$next_btn.width() + c.$skip_btn.width() + c.$prev_btn.width() + 30
, b = K - 100
, e = L + t + 40;
a + K > M && (b = M >= O ? M + 20 : K + s / 2),
(a + b > window.innerWidth || b < 0) && (b = 10,
e = P < N ? L - 80 : L + t + 40);
var f = b
, g = e;
window.innerWidth <= 640 ? (b = 10,
e = 10,
c.$next_btn.html("›"),
c.$prev_btn.html("‹")) : (b = f,
e = g,
c.$next_btn.html(d.nextButton && d.nextButton.text ? d.nextButton.text : "Next"),
c.$prev_btn.html(d.prevButton && d.prevButton.text ? d.prevButton.text : "Previous")),
c.$prev_btn.css({
left: b,
top: e
});
var h = b + c.$prev_btn.width() + 10
, i = b + c.$prev_btn.width() + c.$next_btn.width() + 20;
"hide" === c.nextBtn && (i = b + c.$prev_btn.width() + 10),
"hide" === c.prevBtn && (h = b,
i = b + c.$next_btn.width() + 10),
c.$next_btn.css({
left: h,
top: e
}),
c.$skip_btn.css({
left: i,
top: e
})
}, 0),
c.$close_btn.css({
right: 10,
top: 10
}),
c.disableEventsNearRect({
top: h.top,
bottom: h.bottom,
left: h.left,
right: h.right
}),
c.renderArrow({
x_from: O,
y_from: P,
x_to: M,
y_to: N,
by_top_side: Y
})
}
,
c.clear = function() {
c.ctx.clearRect(0, 0, 3e3, 2e3)
}
,
this
})
}
```
--------------------------------
### Handle Dialog Closing Event
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Attaches a listener to the 'dialogClosing' event for a dialog element. When the dialog starts closing, it calls the stopFunction. This ensures that any ongoing interactive process is halted gracefully.
```javascript
null != f && a(f).on("dialogClosing", function() {
c.stopFunction()
})
```
--------------------------------
### Calculate Element Positions for Web EnjoyHint
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Calculates various positions and dimensions for elements based on window size, element properties, and predefined areas. Use this for positioning tooltips or guides.
```javascript
common_area: x * u,
width: x,
height: u
}, {
name: "right_bottom",
common_area: x * v,
width: x,
height: v
}, {
name: "left_center",
common_area: w * window.innerHeight,
width: w,
height: window.innerHeight
}, {
name: "left_top",
common_area: w * u,
width: w,
height: u
}, {
name: "left_bottom",
common_area: w * v,
width: w,
height: v
}, {
name: "center_top",
common_area: window.innerWidth * u,
width: window.innerWidth,
height: u
}, {
name: "center_bottom",
common_area: window.innerWidth * v,
width: window.innerWidth,
height: v
}], D = s, E = window.innerHeight <= 670 ? A : A + 20, F = C.sort(function(a, b) {
return a.common_area - b.common_area
}), G = "oversized", H = 0; H < F.length; H++) {
var I = F[H].name
, J = F[H];
J.width > D && J.height > E && (G = I)
}
var K, L, M, N, O, P, Q = "circle" === b.shape ? 2 * b.radius : b.width ? b.width : 2 * b.radius, R = "circle" === b.shape ? 2 * b.radius : b.height ? b.height : 2 * b.radius, S = b.center_x + Q / 2 + 80, T = b.center_x - s - Q / 2 - 80, U = window.innerWidth / 2 - s / 2, V = b.center_y - B - t, W = b.center_y + B, X = window.innerHeight / 2 - E / 2 + 20, Y = "hor";
switch (G) {
case "center_top":
L = V,
K = U,
M = b.center_x,
N = b.center_y - R / 2 - 20;
break;
case "center_bottom":
L = W,
K = U,
M = b.center_x,
N = b.center_y + R / 2 + 20;
break;
case "left_center":
L = X,
K = T,
M = b.center_x - Q / 2 - 20,
N = b.center_y,
Y = "ver";
break;
case "left_top":
L = V,
K = T,
M = b.center_x - Q / 2,
N = b.center_y - 20;
break;
case "left_bottom":
L = W,
K = T,
M = b.center_x - Q / 2,
N = b.center_y + 20,
Y = "ver";
break;
case "right_center":
L = X,
K = S,
M = b.center_x + Q / 2 + 20,
N = b.center_y,
Y = "ver";
break;
case "right_top":
L = V,
K = S,
M = b.center_x + Q / 2,
N = b.center_y - 20;
break;
case "right_bottom":
L = W,
K = S,
M = b.center_x + Q / 2,
N = b.center_y + 20,
Y = "ver";
break;
case "oversized":
setTimeout(function() {
a("#enjoyhint_arrpw_line").remove(),
a(".enjoy_hint_label").css({
"border-radius": "20px",
"-webkit-border-radius": "20px",
"-moz-border-radius": "20px",
"background-color": "#272A26",
"-webkit-transition": "background-color ease-out 0.5s",
"-moz-transition": "background-color ease-out 0.5s",
"-o-transition": "background-color ease-out 0.5s",
transition: "background-color ease-out 0.5s"
})
}, 450),
L = X,
K = U
```
--------------------------------
### EnjoyHint API: Rendering Custom Shapes
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Utilize `render_circle` and `render_label` to draw custom shapes and text labels on the tutorial overlay. These methods allow for flexible visual customization of tutorial steps.
```javascript
render_circle: function(a, b, c) {
return this.each(function() {
this.enjoyhint_obj.renderCircle(a, b, c)
}),
this
},
render_label: function(a, b, c) {
return this.each(function() {
this.enjoyhint_obj.renderLabel(a, b, c)
}),
this
},
render_label_with_shape: function(a, b, d) {
```
--------------------------------
### Click Folder and Exit
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/OpenDialogClickFolderSelect.sikuli/OpenDialogClick.html
This snippet demonstrates how to click on a specific folder using a pattern and then exit the script. It's useful for automating file selection processes.
```sikuli
click(Pattern().targetOffset(34,0))
exit(0)
```
--------------------------------
### EnjoyHint Plugin Initialization and Method Calls
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Demonstrates how to initialize the EnjoyHint plugin and call its various methods using jQuery. This is the primary way to interact with the plugin's features.
```javascript
return this.each(function() {
c.stopFunction = b,
this.enjoyhint_obj.renderLabelWithShape(a, d)
}),
this
},
redo_events_near_rect: function(a) {
c.disableEventsNearRect({
top: a.top,
bottom: a.bottom,
left: a.left,
right: a.right
})
},
clear: function() {
return this.each(function() {
this.enjoyhint_obj.clear()
}),
this
},
close: function(a) {
return this.each(function() {
this.enjoyhint_obj.closePopdown()
}),
this
}
};
a.fn.enjoyhint = function(b) {
return p[b] ? p[b].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof b && b ? (a.error("Method " + b + " does not exist on $.numinput"),
this) : p.init.apply(this, arguments)
}
```
--------------------------------
### EnjoyHint Base Styles
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_css/Ext/Template.txt
Sets up the main EnjoyHint overlay container. It's fixed to cover the entire screen and has a high z-index to appear above other content. Pointer events are disabled by default.
```css
.enjoyhint {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1010;
pointer-events: none;
overflow: hidden
}
```
--------------------------------
### Automate Atom IDE: Open File and Search
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/GoToProcedure.sikuli/VscIsOpen.html
This Sikuli script automates opening a file in Atom and searching for 'Gherkin'. It relies on image recognition to locate UI elements and simulates mouse clicks and keyboard input. Ensure the specified image patterns are present and visible on the screen.
```Jython
wait(Pattern().similar(0.60),60)
if not exists(Pattern(1464017836667.png)).similar(0.60)):
exit(1)
click(Pattern().similar(0.60).targetOffset(18,2))
#type("n",KeyModifier.CTRL)
wait(Pattern().similar(0.60),60)
click(Pattern().similar(0.60))
wait(Pattern().similar(0.60),30)
click(Pattern().similar(0.60))
sleep(1)
paste("Gherkin")
sleep(1)
type(Key.ENTER)
exit(0)
```
--------------------------------
### Handle Keyboard Events for EnjoyHint Steps
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Attaches a listener for keyboard events to advance the EnjoyHint tour. Allows specifying a custom key code or using the default behavior.
```javascript
else
d.on(c, function(a) {
f.keyCode && a.keyCode != f.keyCode || (n++,
s())
})
```
--------------------------------
### Auto-Click Download Source Script
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/Git.sikuli/SourceTree.html
This script automates clicking a 'Download Source' button if it appears on the screen within a 15-second timeout. It exits with 0 on success and 1 on failure.
```sikuli
if exists(,15):
click()
exit(0)
exit(1)
```
--------------------------------
### Detect and Activate Atom Window with Sikuli
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/ChooseGherkin.sikuli/SwitchToConf.html
This script repeatedly searches for a specific image (presumably representing the Atom window) on the screen. If found, it clicks the leftmost occurrence to activate the window. It includes a timeout to prevent infinite loops.
```Jython
kol = 0
while True:
FindIm = findAll()
ArrOfImage = list(FindIm)
KolImages = len(ArrOfImage)
id = -1
maxX = -1
print 'KolImages=' + str(KolImages)
for n in range(0, KolImages):
t = ArrOfImage[n]
print 't.x=' + str(t.x)
if t.x > maxX:
maxX = t.x
id = n
if KolImages > 0:
t = ArrOfImage[id]
print 'click t.x=' + str(t.x)
click(Location(t.x+5,t.y+5))
break
sleep(1)
kol = kol+1
if kol > 5:
exit(1)
exit(0)
```
--------------------------------
### Handle Button Configurations in EnjoyHint
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Configures previous and skip buttons for the EnjoyHint tour. Sets button text and CSS classes based on provided configuration.
```javascript
h.text(f.prevButton.text || "Previous"),
e.prevUserClass = f.prevButton.className
}
if (f.skipButton) {
var i = a(".enjoyhint_skip_btn");
i.addClass(f.skipButton.className || ""),
i.text(f.skipButton.text || "Skip"),
e.skipUserClass = f.skipButton.className
```
--------------------------------
### Simulate HOME Key Press
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/TypeHome.sikuli/TypeHome.html
This script simulates pressing the HOME key on the keyboard and then exits. It's useful for automating navigation to the beginning of a line or document.
```Sikuli
type(Key.HOME)
exit(0)
```
--------------------------------
### Automate Opening a File with SikuliX
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/OpenFile.sikuli/OpenFile.html
This script automates opening a file by interacting with the GUI. It requires the file path as a command-line argument. Ensure the 'OpenFile.sikuli' script and its associated image ('MdaainaHIFIH.png') are in the same directory.
```Python
import sys
path = sys.argv[1]
click(Pattern(").targetOffset(36,0))
sleep(1)
paste(path )
sleep(1)
type(Key.ENTER)
exit(0)
```
--------------------------------
### Click at Specified Coordinates (Sikuli)
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/ClickCoordinates.sikuli/ClickCoordinates.html
This snippet takes two command-line arguments representing the X and Y coordinates, creates a Location object, and then clicks at that location on the screen. Ensure the script is run with valid integer arguments for coordinates.
```Sikuli
location = Location(int(sys.argv[1]),int(sys.argv[2]))
click(location)
```
--------------------------------
### Press Win+Up and Exit
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/ClickFlagGenUF.sikuli/MoveActiveWindowFullScreen.html
This script simulates pressing the Windows key and the Up arrow key, then exits the script. It's useful for actions like maximizing a window.
```Sikuli
type(Key.UP, KeyModifier.WIN)
sleep(1)
exit(0)
```
--------------------------------
### Check and Click Atom Window (Sikuli)
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/ClickFlagGenUF.sikuli/ClickGeneratorEPF.html
This script checks for the presence of an image 'FenepampEPF.png'. If found, it clicks the image and exits successfully. If not found, it exits with an error code.
```sikuli
if not exists():
exit(1)
click()
sleep(1)
exit(0)
```
--------------------------------
### Open Dialog and Click Folder Script
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/tools/Sikuli/OpenDialogClickFolder.sikuli/OpenDialogClickFolder.html
This script uses Sikuli's image recognition to click on a folder. Ensure the 'Ilama.png' image is available and correctly represents the target folder. The script then exits.
```sikuli
click(Pattern("").targetOffset(23,0))
exit(0)
```
--------------------------------
### EnjoyHint Initialization and Options
Source: https://github.com/pr-mex/vanessa-automation/blob/develop/lib/VanessaInteractive/CommonTemplates/Web_enjoyhint_min_js/Ext/Template.txt
Initializes the EnjoyHint object, setting default options and extending them with user-provided configurations. Manages class names for styling and DOM elements.
```javascript
var r = {
onNextClick: function() {},
onSkipClick: function() {},
onPrevClick: function() {},
animation_time: 800
};
this.enjoyhint_obj = {},
c = this.enjoyhint_obj,
c.resetComponentStuff = function() {
d = null,
e = null,
f = null,
g = null,
h = null,
i = null,
j = null,
k = null,
l = null,
m = null,
n = window.innerWidth,
o = window.innerHeight
}
;
var s = a(this);
c.options = a.extend(r, p),
c.gcl = {
chooser: "enjoyhint"
},
c.cl = {
enjoy_hint: "enjoyhint",
hide: "enjoyhint_hide",
disable_events_element: "enjoyhint_disable_events",
btn: "enjoyhint_btn",
skip_btn: "enjoyhint_skip_btn",
close_btn: "enjoyhint_close_btn",
next_btn: "enjoyhint_next_btn",
previous_btn: "enjoyhint_prev_btn",
main_canvas: "enjoyhint_canvas",
main_svg: "enjoyhint_svg",
svg_wrapper: "enjoyhint_svg_wrapper",
svg_transparent: "enjoyhint_svg_transparent",
kinetic_container: "kinetic_container"
},
c.canvas_size = {
w: 1.4 * a(window).width(),
h: 1.4 * a(window).height()
},
c.enjoyhint = a("