SlideShare a Scribd company logo
1 of 58
EXPLORING THE INTERNAL STATE OF USER
INTERFACES BY
COMBINING COMPUTER VISION TECHNIQUES
USING SIKULI
Germiya K Jose
4MCA
Christ University
Bangalore
AGENDA
 Introduction
 Basics of Python
 Sikuli Script
 How Sikuli Works
 Technical capabilities
 Hello world Program
 Predefined Functions
 Disadvantages
 Exception Handling
 Special Keys
 Conclusion
IF YOU .............
 Are not good in programming !
 Want to avoid Repeating, Boring or Annoying
Coding ?
 Want to automate something but don’t have an
access to its source ?
WHAT DOES IT DO ?
 Single click to run a series of clicking and typing
 Make boring task easier and quicker
 Testing
WHY SIKULI?
 Sikuli automates anything you see on the screen.
 It uses image recognition to identify and control
GUI components.
 It is useful when there is no easy access to a GUI's
internal or source code.
 Sikuli is an open-source research project originally
started at the User Interface Design Group at MIT.
 Sikuli visual approach to search and automation
of graphical user interfaces using screenshots.
 Sikuli allows users to take a screenshot of a GUI
element (such as a toolbar button, icon, or dialog
box) and query a help system using the screenshot
instead of element’s name.
 Sikuli also provides a visual scripting API for
automating GUI interactions, using screenshot
patterns to direct mouse and keyboard events.
SIKULI SCRIPT
 Sikuli automates the interaction with a GUI by
executing it, recognizing widgets .
 such as buttons and text fields from their visual
appearance on the screen, and interacting with
those widgets by simulating mouse pointer or
keyboard actions .
 Sikuli uses python for scripting
PYTHON FEATURES
 Easy-to-learn
 Easy-to-read
 A broad standard library
 Interactive Mode
 Portable
 Databases
 Comments
 # symbol used
 Quoting
 single (')
 double (")
 triple (''' or """') [span the string across multiple lines]
 List
 Python's compound data type
 lists are similar to arrays
 list can be of different data type
 print (“ ",list[1:3]) or print list[2:] or print list[0] or print list
 del lis[2]
 Dictionary
 kind of hash table type
 consist of key-value pairs
 tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
IF - ELSE
if expression1:
statement(s)
elif expression2:
statement(s)
else:
statement(s)
 membership operator
 In
 Evaluates to true if it finds a variable in the specified sequence and
false otherwise.
 not in
 Evaluates to true if it does not finds a variable in the specified
sequence and false otherwise.
 identity operator
 Is
 Evaluates to true if the variables on either side of the operator point to
the same object and false otherwise.
 is not
 Evaluates to false if the variables on either side of the operator point
to the same object and true otherwise.
 Range()
 len keyword
 Break
 continue
 pass
LOOPS
 while
 for
 nested loops
 loop with else
FUNCTIONS
def printme( str ):
print str;
return;
Function call
printme("I'm first call !");
TECHNICAL CAPABILITIES
The three core of Sikuli are :
 Look
 Recognize
 Interact
LOOK:
 Sikuli uses a system API to grab the pixel data from
the screen buffer and analyzes it.
 This basic system function for screen capture is
available on most modern platforms
 including Windows, Mac, Linux and Android.
RECOGNIZE:
 Sikuli “recognizes” widgets on a GUI using
pattern matching based on visual appearance.
 There are two use cases that must be dealt with
separately:
 Recognizing a specific widget and recognizing a
class of widgets.
INTERACT:
 Sikuli uses the Java Robot class to simulate mouse
and keyboard interaction.
 After recognizing a widget, Sikuli knows that
widget’s location on the screen, and can move the
pointer to that location.
 At that location, it can issue a click command which
will effectively click on that widget
BASIC EXPLORATION STRATEGIES
 (a) random exploration first identifies all widgets on
the current screen image and interacts with one
uniformly at random. The length of each interaction
is a user-controlled parameter.
 (b) Depthfirst exploration systematically explores
all interactions upto a given length, assuming that
the system is deterministic.
HOW SIKULI WORKS ?
SIKULI SCRIPT
 Sikuli Script is a Jython and Java library that
automates GUI interaction using image patterns to
direct keyboard/mouse events.
 The core of Sikuli Script is a Java library that
consists of two parts:
 java.awt.Robot, which delivers keyboard and
mouse events to appropriate locations
 C++ engine based on OpenCV, which searches
given image patterns on the screen.
THE STRUCTURE OF A SIKULI
SOURCE/EXECUTABLE SCRIPT (.SIKULI, .SKL)
 A Sikuli script (.sikuli) is a directory that consists of a
Python source file (.py), and all the image files (.png)
used by the source file.
 All images used in a Sikuli script are simply a path to
the .png file in the .sikuli bundle. 
 Therefore, the Python source file can also be edited by
any text editor.
 While saving a script using Sikuli IDE, an extra HTML
file is also created in the .sikuli directory so that users
can share the scripts on the web easily.
SIKULI IDE
 Sikuli IDE edits and runs Sikuli source scripts. Sikuli
IDE integrates screen capturing and a custom text
editor (SikuliPane) to optimize the usability of
writing a Sikuli script.
 To show embedded images in the SikuliPane, all
string literals that ends with ”.png” are replaced by a
custom JButton object, ImageButton.
 If a user adjusts the image pattern’s similarity, a
Pattern() is automatically constructed on top of the
image.
SIKULI IDE
HELLO WORLD (WINDOWS)
 Let us begin with a customary Hello World
example!
 You will learn how to capture a screenshot of a GUI
element and write a Sikuli Script to do two things:
 1. Click on that element
 2. Type a string in that element
THE GOAL OF THE HELLO WORLD SCRIPT IS TO
AUTOMATICALLY TYPE “HELLO WORLD” INTO THE START
MENU SEARCH BOX, LIKE THIS:
SIKULI SCRIPT
CONTROLLING SIKULI SCRIPTS AND THEIR BEHAVIOR
 setShowActions(False | True)
 If set to True, when a script is run, Sikuli shows a visual effect
(a blinking double lined red circle) on the spot where the action
will take place before executing actions
 exit([value ])
 Stops the script gracefully at this point. The value is returned
to the calling environment.
 Settings.MinSimilarity
 The default minimum similiarty of find operations. Sikuli
searches the region using a default minimum similarity of 0.7.
 Settings.MoveMouseDelay
 Control the time taken for mouse movement to a target
location by setting this value to a decimal value (default 0.5).
The unit is seconds. Setting it to 0 will switch off any
animation.
PROBLEMS
 Poor documentation
 Slightly buggy
 No reports , video or export of results .
KEY METHODS
 Find
 findAll
 exists
 wait
 waitVanish
MOUSE ACTIONS
 Click
 doubleClick
 RightClick
 Hover
 dragDrop
INTERACTING WITH THE USER AND OTHER APPLICATIONS
 PopUps and input
 popup(text[, title ])
 Parameters
 text – text to be displayed as message
 title – optional title for the messagebox (default: Sikuli
Info)
 Example:
 popup("Hello World!nHave fun with Sikuli!")
 popError(text[, title ])
 Same as popup() but with a different title (default Sikuli
Error) and alert icon.
 Example:
 popError("Uuups, this did not work")
 A dialog box that looks like below will popup
 popAsk(text[, title ])
 Returns True if user clicked Yes, False otherwise
 Same as popup() but with a different title (default Sikuli
Decision) and alert icon.
 There are 2 buttons: Yes and No and hence the
message text should be written as an appropriate
question.
 Example:
 answer = popAsk("Should we really continue?")
 if not answer:
 exit(1)
A DIALOG BOX THAT LOOKS LIKE BELOW WILL
POPUP
 input([msg ][, default ][, title ][, hidden ])
 Display a dialog box with an input field, a Cancel button, and
an OK button.
 The script then waits for the user to click either the Cancel
or the OK button.
 Parameters
 msg – text to be displayed as message (default: nothing)
 default – optional preset text for the input field
 title – optional title for the messagebox (default: Sikuli Input)
 hidden – (default: False) if true the entered characters are shown as
asterisks
 Returns
 the text, contained in the input field, when the user clicked
Ok
 None, if the user pressed the Cancel button or closed the
dialog
 Example: plain input:
 name = input("Please enter your name to log in:")
 name = input("Please enter your name to log in:",
"anonymous")
EXAMPLE: INPUT WITH HIDDEN INPUT:
 password = input("please enter your secret",
hidden = True)
 inputText([msg ][, title ][, lines ][, width ])
 Parameters
 msg – text to be displayed as message (default: nothing)
 title – optional title for the messagebox (default: Sikuli Text)
 lines – how many lines the text box should be high (default: 9)
 width – how many characters the box should have as width
(default: 20)
 Returns the possible multiline text entered by the user
(might be empty)
EXAMPLE:
 story = inputText("please give me some lines of
text")
 lines = story.split("n") # split the lines in the list lines
for line in lines:
print line
 select([msg ][, title ][, options ][, default ])
 Parameters
 msg – text to be displayed as message (default:
nothing)
 title – optional title for the messagebox (default: Sikuli
Selection)
 options – a list of text items (default: empty list, nothing
done)
 default – the preselected list item (default: first item)
 Returns the selected item (might be the default)
EXAMPLE:
items = ("nothing selected", "item1", "item2", "item3")
selected = select("Please select an item from the list",
options = items)
if selected == items[0]:
popup("You did not select an item")
exit(1)
STARTING AND STOPPING OTHER APLLICATIONS AND
BRINGING THEIR WINDOWS TO FRONT
 Here we talk about the basic features of opening or
closing other applications and switching to them
(bring their windows to front).
 openApp(application)
 openApp("cmd.exe")
 openApp("c:Program FilesMozilla Firefoxfirefox.exe")
 switchApp(application)
 Switch to the specified application.
 switchApp("cmd.exe")
 switchApp("c:Program FilesMozilla Firefoxfirefox.exe")
 closeApp(application)
 Close the specified application.
 closeApp("cmd.exe")
 closeApp("c:Program FilesMozilla Firefoxfirefox.exe")
 run(command)
 Run command in the command line
 Parameters command – a command that can be run from the
command line.
 This function executes the command and the script waits for its
completion.
EXCEPTION HANDLING
 setThrowException(False | True)
 By using this method you control, how Sikuli should handle not
found situations in this region.
 Parameters
 True – all subsequent find operations (explicit or implicit) will
raise exception FindFailed(which is the default when a script is
started) in case of not found.
 False – all subsequent find operations will not raise exception
FindFailed. Instead, explicit find operations such as
Region.find() will return None. Implicit find operations (action
functions) such as Region.click() will do nothing and return 0.
 getThrowException()
 Returns True or False
 Get the current setting as True or False (after start of
script, this is True by default) in this region.
SPECIAL KEYS
 The methods supporting the use of special keys are
type(), keyDown(), and keyUp().
 String concatenation with with other text or other key constants
is possible using “+”.
 type("some text" + Key.TAB + "more text" + Key.TAB +
Key.ENTER)
or eqivalent
 type("some texttmore textn")
 miscellanous keys
 ENTER, TAB, ESC, BACKSPACE, DELETE, INSERT, SPACE
 function keys
 F1, F2, F3, F4, F5, F6, F7.......
 navigation keys
 HOME, END, LEFT, RIGHT, DOWN, UP, PAGE_DOWN,
PAGE_UP
 special keys
 PRINTSCREEN, PAUSE, CAPS_LOCK, SCROLL_LOCK,
NUM_LOCK
 numpad keys
 NUM0, NUM1, NUM2, NUM3.............
 SEPARATOR, ADD, MINUS, MULTIPLY, DIVIDE
 modifier keys
 ALT, CMD, CTRL, META, SHIFT, WIN
These modifier keys cannot be used as a key modifier with
functions like type(), rightClick(), etc. They can only be used with
keyDown() and keyUp(). If you need key modifiers, use
KeyModifier instead.
 type(Key.ESC, KeyModifier.CTRL + KeyModifier.ALT)
or equivalent
 type(Key.ESC, KeyModifier.CTRL | KeyModifier.ALT)
 They should only be used in the modifiers parameter with
functions like type(), rightClick(), etc.
 They should never be used with keyDown() or keyUp().
KEYBOARD ACTIONS
 Type(text)
 Type(img , text)
 Paste(text)
 Paste(img , text)
CONCLUSION
 Sikuli means “ God’s eye ” in mexican language .
 Sikuli currently uses Python as the scripting
language.
 Sikuli is a visual technology to search and
automates GUI using images (screenshots).
 It automates anything you see on the screen
without internal API ‘s support
REFERENCE
 SikuliX Documentation Release 1.1.0-Beta1 byRaimund
Hocke aka RaiMan ( October 19, 2014 ) .
 Abstracting Perception and Manipulation in End-User Robot
Programming using Sikuli (IEEE) .
 Exploring the Internal State of User Interfaces by Combining
Computer Vision Techniques with Grammatical Inference
(IEEE) .
 Sikuli: Using GUI Screenshots for Search and Automation
(IEEE) .
Exploring the internal state of user interfaces using sikuli

More Related Content

What's hot

What's hot (20)

Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
 
QA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профиQA Fest 2019. Андрей Солнцев. Selenide для профи
QA Fest 2019. Андрей Солнцев. Selenide для профи
 
Try Jetpack Compose
Try Jetpack ComposeTry Jetpack Compose
Try Jetpack Compose
 
Web API testing : A quick glance
Web API testing : A quick glanceWeb API testing : A quick glance
Web API testing : A quick glance
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
Java NIO.2
Java NIO.2Java NIO.2
Java NIO.2
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 
Jetpack compose
Jetpack composeJetpack compose
Jetpack compose
 
Sqlite
SqliteSqlite
Sqlite
 
Deep dive into swift UI
Deep dive into swift UIDeep dive into swift UI
Deep dive into swift UI
 
Gatling
Gatling Gatling
Gatling
 
Mockito
MockitoMockito
Mockito
 
AngularJS
AngularJSAngularJS
AngularJS
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 

Similar to Exploring the internal state of user interfaces using sikuli

Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectures
elliando dias
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
Dao Tung
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
tutorialsruby
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
tutorialsruby
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
pbarasia
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
info_zybotech
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
Aarti P
 

Similar to Exploring the internal state of user interfaces using sikuli (20)

Unity - Essentials of Programming in Unity
Unity - Essentials of Programming in UnityUnity - Essentials of Programming in Unity
Unity - Essentials of Programming in Unity
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Swift
SwiftSwift
Swift
 
High speed script execution for GUI automation using computer vision
High speed script execution for GUI automation using computer visionHigh speed script execution for GUI automation using computer vision
High speed script execution for GUI automation using computer vision
 
Lecture 1 rapid android development
Lecture 1   rapid android developmentLecture 1   rapid android development
Lecture 1 rapid android development
 
Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectures
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
UIAutomation + Mechanic.js
UIAutomation + Mechanic.jsUIAutomation + Mechanic.js
UIAutomation + Mechanic.js
 
Unity 3d scripting tutorial
Unity 3d scripting tutorialUnity 3d scripting tutorial
Unity 3d scripting tutorial
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
 
2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial2%20-%20Scripting%20Tutorial
2%20-%20Scripting%20Tutorial
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
01 Database Management (re-uploaded)
01 Database Management (re-uploaded)01 Database Management (re-uploaded)
01 Database Management (re-uploaded)
 
Ppt on visual basics
Ppt on visual basicsPpt on visual basics
Ppt on visual basics
 
How to create ui using droid draw
How to create ui using droid drawHow to create ui using droid draw
How to create ui using droid draw
 
Extending JS WU2016 Toronto
Extending JS WU2016 TorontoExtending JS WU2016 Toronto
Extending JS WU2016 Toronto
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
 
Om Pawar MP AJP.docx
Om Pawar MP AJP.docxOm Pawar MP AJP.docx
Om Pawar MP AJP.docx
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Exploring the internal state of user interfaces using sikuli

  • 1. EXPLORING THE INTERNAL STATE OF USER INTERFACES BY COMBINING COMPUTER VISION TECHNIQUES USING SIKULI Germiya K Jose 4MCA Christ University Bangalore
  • 2. AGENDA  Introduction  Basics of Python  Sikuli Script  How Sikuli Works  Technical capabilities  Hello world Program  Predefined Functions  Disadvantages  Exception Handling  Special Keys  Conclusion
  • 3. IF YOU .............  Are not good in programming !  Want to avoid Repeating, Boring or Annoying Coding ?  Want to automate something but don’t have an access to its source ?
  • 4. WHAT DOES IT DO ?  Single click to run a series of clicking and typing  Make boring task easier and quicker  Testing
  • 5. WHY SIKULI?  Sikuli automates anything you see on the screen.  It uses image recognition to identify and control GUI components.  It is useful when there is no easy access to a GUI's internal or source code.  Sikuli is an open-source research project originally started at the User Interface Design Group at MIT.
  • 6.  Sikuli visual approach to search and automation of graphical user interfaces using screenshots.  Sikuli allows users to take a screenshot of a GUI element (such as a toolbar button, icon, or dialog box) and query a help system using the screenshot instead of element’s name.  Sikuli also provides a visual scripting API for automating GUI interactions, using screenshot patterns to direct mouse and keyboard events.
  • 7. SIKULI SCRIPT  Sikuli automates the interaction with a GUI by executing it, recognizing widgets .  such as buttons and text fields from their visual appearance on the screen, and interacting with those widgets by simulating mouse pointer or keyboard actions .  Sikuli uses python for scripting
  • 8. PYTHON FEATURES  Easy-to-learn  Easy-to-read  A broad standard library  Interactive Mode  Portable  Databases
  • 9.  Comments  # symbol used  Quoting  single (')  double (")  triple (''' or """') [span the string across multiple lines]  List  Python's compound data type  lists are similar to arrays  list can be of different data type  print (“ ",list[1:3]) or print list[2:] or print list[0] or print list  del lis[2]  Dictionary  kind of hash table type  consist of key-value pairs  tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
  • 10. IF - ELSE if expression1: statement(s) elif expression2: statement(s) else: statement(s)
  • 11.  membership operator  In  Evaluates to true if it finds a variable in the specified sequence and false otherwise.  not in  Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.  identity operator  Is  Evaluates to true if the variables on either side of the operator point to the same object and false otherwise.  is not  Evaluates to false if the variables on either side of the operator point to the same object and true otherwise.
  • 12.  Range()  len keyword  Break  continue  pass
  • 13. LOOPS  while  for  nested loops  loop with else
  • 14. FUNCTIONS def printme( str ): print str; return; Function call printme("I'm first call !");
  • 15. TECHNICAL CAPABILITIES The three core of Sikuli are :  Look  Recognize  Interact
  • 16. LOOK:  Sikuli uses a system API to grab the pixel data from the screen buffer and analyzes it.  This basic system function for screen capture is available on most modern platforms  including Windows, Mac, Linux and Android.
  • 17. RECOGNIZE:  Sikuli “recognizes” widgets on a GUI using pattern matching based on visual appearance.  There are two use cases that must be dealt with separately:  Recognizing a specific widget and recognizing a class of widgets.
  • 18. INTERACT:  Sikuli uses the Java Robot class to simulate mouse and keyboard interaction.  After recognizing a widget, Sikuli knows that widget’s location on the screen, and can move the pointer to that location.  At that location, it can issue a click command which will effectively click on that widget
  • 19. BASIC EXPLORATION STRATEGIES  (a) random exploration first identifies all widgets on the current screen image and interacts with one uniformly at random. The length of each interaction is a user-controlled parameter.  (b) Depthfirst exploration systematically explores all interactions upto a given length, assuming that the system is deterministic.
  • 21. SIKULI SCRIPT  Sikuli Script is a Jython and Java library that automates GUI interaction using image patterns to direct keyboard/mouse events.  The core of Sikuli Script is a Java library that consists of two parts:  java.awt.Robot, which delivers keyboard and mouse events to appropriate locations  C++ engine based on OpenCV, which searches given image patterns on the screen.
  • 22. THE STRUCTURE OF A SIKULI SOURCE/EXECUTABLE SCRIPT (.SIKULI, .SKL)  A Sikuli script (.sikuli) is a directory that consists of a Python source file (.py), and all the image files (.png) used by the source file.  All images used in a Sikuli script are simply a path to the .png file in the .sikuli bundle.  Therefore, the Python source file can also be edited by any text editor.  While saving a script using Sikuli IDE, an extra HTML file is also created in the .sikuli directory so that users can share the scripts on the web easily.
  • 23. SIKULI IDE  Sikuli IDE edits and runs Sikuli source scripts. Sikuli IDE integrates screen capturing and a custom text editor (SikuliPane) to optimize the usability of writing a Sikuli script.  To show embedded images in the SikuliPane, all string literals that ends with ”.png” are replaced by a custom JButton object, ImageButton.  If a user adjusts the image pattern’s similarity, a Pattern() is automatically constructed on top of the image.
  • 25. HELLO WORLD (WINDOWS)  Let us begin with a customary Hello World example!  You will learn how to capture a screenshot of a GUI element and write a Sikuli Script to do two things:  1. Click on that element  2. Type a string in that element
  • 26. THE GOAL OF THE HELLO WORLD SCRIPT IS TO AUTOMATICALLY TYPE “HELLO WORLD” INTO THE START MENU SEARCH BOX, LIKE THIS:
  • 27.
  • 29. CONTROLLING SIKULI SCRIPTS AND THEIR BEHAVIOR  setShowActions(False | True)  If set to True, when a script is run, Sikuli shows a visual effect (a blinking double lined red circle) on the spot where the action will take place before executing actions  exit([value ])  Stops the script gracefully at this point. The value is returned to the calling environment.  Settings.MinSimilarity  The default minimum similiarty of find operations. Sikuli searches the region using a default minimum similarity of 0.7.  Settings.MoveMouseDelay  Control the time taken for mouse movement to a target location by setting this value to a decimal value (default 0.5). The unit is seconds. Setting it to 0 will switch off any animation.
  • 30. PROBLEMS  Poor documentation  Slightly buggy  No reports , video or export of results .
  • 31. KEY METHODS  Find  findAll  exists  wait  waitVanish
  • 32. MOUSE ACTIONS  Click  doubleClick  RightClick  Hover  dragDrop
  • 33. INTERACTING WITH THE USER AND OTHER APPLICATIONS  PopUps and input  popup(text[, title ])  Parameters  text – text to be displayed as message  title – optional title for the messagebox (default: Sikuli Info)  Example:  popup("Hello World!nHave fun with Sikuli!")
  • 34.
  • 35.  popError(text[, title ])  Same as popup() but with a different title (default Sikuli Error) and alert icon.  Example:  popError("Uuups, this did not work")  A dialog box that looks like below will popup
  • 36.  popAsk(text[, title ])  Returns True if user clicked Yes, False otherwise  Same as popup() but with a different title (default Sikuli Decision) and alert icon.  There are 2 buttons: Yes and No and hence the message text should be written as an appropriate question.  Example:  answer = popAsk("Should we really continue?")  if not answer:  exit(1)
  • 37. A DIALOG BOX THAT LOOKS LIKE BELOW WILL POPUP
  • 38.  input([msg ][, default ][, title ][, hidden ])  Display a dialog box with an input field, a Cancel button, and an OK button.  The script then waits for the user to click either the Cancel or the OK button.  Parameters  msg – text to be displayed as message (default: nothing)  default – optional preset text for the input field  title – optional title for the messagebox (default: Sikuli Input)  hidden – (default: False) if true the entered characters are shown as asterisks  Returns  the text, contained in the input field, when the user clicked Ok  None, if the user pressed the Cancel button or closed the dialog
  • 39.  Example: plain input:  name = input("Please enter your name to log in:")
  • 40.  name = input("Please enter your name to log in:", "anonymous")
  • 41. EXAMPLE: INPUT WITH HIDDEN INPUT:  password = input("please enter your secret", hidden = True)
  • 42.  inputText([msg ][, title ][, lines ][, width ])  Parameters  msg – text to be displayed as message (default: nothing)  title – optional title for the messagebox (default: Sikuli Text)  lines – how many lines the text box should be high (default: 9)  width – how many characters the box should have as width (default: 20)  Returns the possible multiline text entered by the user (might be empty)
  • 43. EXAMPLE:  story = inputText("please give me some lines of text")  lines = story.split("n") # split the lines in the list lines for line in lines: print line
  • 44.
  • 45.  select([msg ][, title ][, options ][, default ])  Parameters  msg – text to be displayed as message (default: nothing)  title – optional title for the messagebox (default: Sikuli Selection)  options – a list of text items (default: empty list, nothing done)  default – the preselected list item (default: first item)  Returns the selected item (might be the default)
  • 46. EXAMPLE: items = ("nothing selected", "item1", "item2", "item3") selected = select("Please select an item from the list", options = items) if selected == items[0]: popup("You did not select an item") exit(1)
  • 47.
  • 48. STARTING AND STOPPING OTHER APLLICATIONS AND BRINGING THEIR WINDOWS TO FRONT  Here we talk about the basic features of opening or closing other applications and switching to them (bring their windows to front).  openApp(application)  openApp("cmd.exe")  openApp("c:Program FilesMozilla Firefoxfirefox.exe")
  • 49.  switchApp(application)  Switch to the specified application.  switchApp("cmd.exe")  switchApp("c:Program FilesMozilla Firefoxfirefox.exe")  closeApp(application)  Close the specified application.  closeApp("cmd.exe")  closeApp("c:Program FilesMozilla Firefoxfirefox.exe")  run(command)  Run command in the command line  Parameters command – a command that can be run from the command line.  This function executes the command and the script waits for its completion.
  • 50. EXCEPTION HANDLING  setThrowException(False | True)  By using this method you control, how Sikuli should handle not found situations in this region.  Parameters  True – all subsequent find operations (explicit or implicit) will raise exception FindFailed(which is the default when a script is started) in case of not found.  False – all subsequent find operations will not raise exception FindFailed. Instead, explicit find operations such as Region.find() will return None. Implicit find operations (action functions) such as Region.click() will do nothing and return 0.
  • 51.  getThrowException()  Returns True or False  Get the current setting as True or False (after start of script, this is True by default) in this region.
  • 52. SPECIAL KEYS  The methods supporting the use of special keys are type(), keyDown(), and keyUp().  String concatenation with with other text or other key constants is possible using “+”.  type("some text" + Key.TAB + "more text" + Key.TAB + Key.ENTER) or eqivalent  type("some texttmore textn")
  • 53.  miscellanous keys  ENTER, TAB, ESC, BACKSPACE, DELETE, INSERT, SPACE  function keys  F1, F2, F3, F4, F5, F6, F7.......  navigation keys  HOME, END, LEFT, RIGHT, DOWN, UP, PAGE_DOWN, PAGE_UP  special keys  PRINTSCREEN, PAUSE, CAPS_LOCK, SCROLL_LOCK, NUM_LOCK  numpad keys  NUM0, NUM1, NUM2, NUM3.............  SEPARATOR, ADD, MINUS, MULTIPLY, DIVIDE  modifier keys  ALT, CMD, CTRL, META, SHIFT, WIN These modifier keys cannot be used as a key modifier with functions like type(), rightClick(), etc. They can only be used with keyDown() and keyUp(). If you need key modifiers, use KeyModifier instead.
  • 54.  type(Key.ESC, KeyModifier.CTRL + KeyModifier.ALT) or equivalent  type(Key.ESC, KeyModifier.CTRL | KeyModifier.ALT)  They should only be used in the modifiers parameter with functions like type(), rightClick(), etc.  They should never be used with keyDown() or keyUp().
  • 55. KEYBOARD ACTIONS  Type(text)  Type(img , text)  Paste(text)  Paste(img , text)
  • 56. CONCLUSION  Sikuli means “ God’s eye ” in mexican language .  Sikuli currently uses Python as the scripting language.  Sikuli is a visual technology to search and automates GUI using images (screenshots).  It automates anything you see on the screen without internal API ‘s support
  • 57. REFERENCE  SikuliX Documentation Release 1.1.0-Beta1 byRaimund Hocke aka RaiMan ( October 19, 2014 ) .  Abstracting Perception and Manipulation in End-User Robot Programming using Sikuli (IEEE) .  Exploring the Internal State of User Interfaces by Combining Computer Vision Techniques with Grammatical Inference (IEEE) .  Sikuli: Using GUI Screenshots for Search and Automation (IEEE) .