【Sikuli】 sikuli常用函数、简单事件操作 键盘操作 个人总结笔记

sikuli函数、简单事件操作个人总结笔记

 

作者:stormwy

网址:http://blog.csdn.net/stormwy/article/details/7955137


其实sikuli的语法跟python的语法是一样的,大家在学习sikuli时,要看看python的语法,这样就能有更多样的方法来实现丰富的功能。

由于关于sikuli的中文资料实在太少了,我在学习使用sikuli的过程中,记录下下面一些常用操作,以供sikuli学习者参考!

1findAll(图片)

findAll() searches the entire screen for all the matchingvisual patterns and returns a list of locations of those similar patterns. Thiscapability allows us to obtain all the checked items are on the screen. Then,we can simply write a for loop in standard Python syntax and call click() oneach element in the list.

典型例子:Uncheck AllCheckboxes

2、点击操作

click(x)

左键点击元素x

rightClick(x)

右键点击元素x


3below()


4dragDrop()

This function takes two images asarguments. The first image describes the source GUI object to drag and thesecond image describes the appearance of the destination location where the GUIobject should be dragged to and dropped.


典型例子:Working with Sliders


5right()

表示在右边


6popup(string)

弹出一个提示框
例:
popup("Obama has updated his message")
运行:


7、键盘操作:


8Resizinga Window

This tutorial demonstrates how to use Sikuli script to resize a window by dragging its bottom-right corner.
 In order to do so, you have to evaluate the current position of this corner on the screen, 
move the mouse pointer to the applicable click point and then perform one or more drag actions.


9、表示方位的词:

Nearby(number)、above()、below()、left()、right()、getCenter()


10、位置偏移

Location(t.x-30,t.y+30)

其实用图形法会方便和舒服:点击图片,进入设置界面,点击偏移选项卡,然后可以用鼠标设置偏移量,点到哪就偏移到哪,如果想偏移到更远的地方,就滚动鼠标滑轮,可以放大缩小页面,选择偏移点。


11、屏幕翻页


其他键盘操作类型参数见Key (built-in class)


12、读写文件(其实就是python的语法)

#打开 写文件

f=open('c:/wy.txt','a')

t="hello\n"

f . write(t)

f.close()

 

#打开 读文件

f=open('c:/wy.txt','r')

t=f.read()

popup(t)


#open(路径+文件名,读写模式)

#读写模式:r只读,r+读写,w新建(会覆盖原有文件),a追加,b二进制文件.常用模式


13input(“字符串”)

显示一个输入框,以供输入。要输入中文应该在前面加u

input(u“字符串”),不然会乱码


14if语句

If 条件 and 条件:#(注意有冒号,‘#’号表示注释)

       语句


15openApp(应用程序路径名)    

打开应用程序,注意应用程序的路径名里的斜杠“\”要改为双斜杠“\\”。


16、复制、粘贴操作

type("c",KEY_CTRL)  #复制

type("v",KEY_CTRL)  #粘贴


17waitVanish("20120902172907.png",300)

waitVanish()最好带时间,不然还没消失就返回消失的信息了。

我觉得用下面的代替好些

while exists("image.png"):
     wait(1)   
#ifthe image exist it will wait until the image disappear


18sikuli输入中文

input(u"请输入想要获取并下载多少个页面的App资源:")

popup(u”chinese”)

在前面加‘u’避免乱码,‘u’是unicode还是utf8,我就不清楚了。


19、设定循环次数

for x inrange(10): #循环10次,x不用预先定义

       循环体


20、编程小经验

1、用sikuli编程的时候,最好是保存为可执行文件来测试,因为有些功能直接测试是测试不出来的,比如type("c",KEY_CTRL)  #复制,直接运行测试(好像)是无效的,当时我还困惑了很久。后来无意中保存为可执行文件后才发现是可以的。

 

2、用sikuli编程时,多用wait()语句,因为很多时候没有给它一定的识别时间,就容易出错。

还有的就是,进行复制粘贴操作时,如果需要切换到另外一个页面粘贴,再切回来,如果中间不wait一段时间,等粘贴完成,很可能就没有粘贴成功。

 

以上是个人的经验之谈,希望对大家有所帮助!

附录是sikuli官网上http://sikuli.org/docx/的函数检索Index,很多新学习者不知道,所以在这里贴出来。

如果想要知道更多sikuli的详情,我推荐你到官网http://sikuli.org/

因为中文的关于sikuli的编程资料太少了。


附录:sikuli函数检索

Sikuli Funtions Index

Symbols|A |B |C |D |E |F |G |H |I |K |L |M |N |O |P |R |S |T |W

Symbols

--args <arguments>

command line option

-h,--help

command line option

-i

command line option

-r,--run <sikuli-file>

command line option

-s,--stderr

command line option

-t,--test <sikuli-file>

command line option

A

above() (Location method)

(Region method)

ActionLogs (Settings attribute)

addHotkey() (Env method)

addImagePath() (built-in function)

ALT (built-in variable)

App (built-in class)[1]

B

below() (Location method)

(Region method)

Bundle Path

C

capture() (Screen method)

changes (SikuliEvent attribute)

circle() (in module guide)

click() (Region method)

clickable() (in module guide)

close() (App class method)

(App method)

closeApp() (built-in function)

CMD (built-in variable)

command line option

--args <arguments>

-h,--help

-i

-r,--run <sikuli-file>

-s,--stderr

-t,--test <sikuli-file>

CTRL (built-in variable)

D

DebugLogs (Settings attribute)

DelayAfterDrag (Settings attribute)

DelayBeforeDrop (Settings attribute)

dialog() (in module guide)

doubleClick() (Region method)

drag() (Region method)

dragDrop() (Region method)

dropAt() (Region method)

E

exact() (Pattern method)

exists() (Region method)

exit() (built-in function)

F

find() (Finder method)

(Region method)

findAll() (Region method)

Finder (built-in class),[1]

Finder() (Finder method)

focus() (App class method)

(App method)

focusedWindow() (App class method)

G

getAutoWaitTimeout() (Region method)

getBottomLeft() (Region method)

getBottomRight() (Region method)

getBounds() (Screen method)

getBundlePath() (built-in function)

getCenter() (Region method)

getClipboard() (Env method)

getFilename() (Pattern method)

getFindFailedResponse() (Region method)

getH() (Region method)

getImagePath() (built-in function)

getLastMatch() (Region method)

getLastMatches() (Region method)

getLocationFromPSRML() (Region method)

getMouseLocation() (Env method)

getNumberScreens() (Screen method)

getOS() (Env method)

getOSVersion() (Env method)

getParameter() (Vision method)

getRegionFromPSRM() (Region method)

getScore() (Match method)

getScreen() (Region method)

getSikuliVersion() (Env method)

getTarget() (Match method)

getTargetOffset() (Pattern method)

getThrowException() (Region method)

getTopLeft() (Region method)

getTopRight() (Region method)

getW() (Region method)

getX() (Location method)

(Region method)

getY() (Location method)

(Region method)

guide (module)

H

hasNext() (Finder method)

highlight() (Region method)

hover() (Region method)

I

Image Search Path

SIKULI_IMAGE_PATH

import .sikuli

InfoLogs (Settings attribute)

input() (built-in function)

inside() (Region method)

isLockOn() (Env method)

K

Key (built-in class)

keyDown() (Region method)

KeyModifier (built-in class)

keyUp() (Region method)

L

left() (Location method)

(Region method)

load() (built-in function)

Location (built-in class)

Location() (Location method)

M

Match (built-in class)[1]

match (SikuliEvent attribute)

META (built-in variable)

MinSimilarity (Settings attribute)

morphTo() (Region method)

mouseDown() (Region method)

mouseMove() (Region method)

mouseUp() (Region method)

MoveMouseDelay (Settings attribute)

moveTo() (Region method)

N

nearby() (Region method)

next() (Finder method)

O

observe() (Region method)

ObserveMinChangedPixels (Settings attribute)

ObserveScanRate (Settings attribute)

offset() (Location method)

(Region method)

onAppear() (Region method)

onChange() (Region method)

onVanish() (Region method)

open() (App class method)

(App method)

openApp() (built-in function)

P

paste() (Region method)

Pattern (built-in class),[1]

pattern (SikuliEvent attribute)

Pattern() (Pattern method)

popup() (built-in function)

R

rectangle() (in module guide)

Region (built-in class),[1],[2],[3][4][5][6][7][8][9]

region (SikuliEvent attribute)

Region() (Region method)

removeHotkey() (Env method)

removeImagePath() (built-in function)

right() (Location method)

(Region method)

rightClick() (Region method)

run() (built-in function)

S

Screen (built-in class),[1],[2]

Screen() (Screen method)

selectRegion() (Screen method)

setAutoWaitTimeout() (Region method)

setBundlePath() (built-in function)

setFindFailedResponse() (Region method)

setH() (Region method)

setLocation() (Location method)

setParameter() (Vision method)

setRect() (Region method)

setROI() (Region method)

setShowActions() (built-in function)

setThrowException() (Region method)

Settings (built-in class)

setW() (Region method)

setX() (Region method)

setY() (Region method)

SHIFT (built-in variable)

show() (in module guide)

SIKULI_IMAGE_PATH

Image Search Path

SikuliEvent (built-in class)

similar() (Pattern method)

SlowMotionDelay (Settings attribute)

stopObserver() (Region method)

switchApp() (built-in function)

T

targetOffset() (Pattern method)

text() (in module guide)

(Region method)

tooltip() (in module guide)

type (SikuliEvent attribute)

type() (Region method)

W

wait() (Region method)

WaitScanRate (Settings attribute)

waitVanish() (Region method)

wheel() (Region method)

WIN (built-in variable)

window() (App method)

 

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Excel是一款功能强大的电子表格软件,其中内置了众多常用函数公式,能够帮助用户实现各种简单操作。下面是一些常用函数公式大全: 1. SUM函数:用于求一组数据的总和。例如,=SUM(A1:A10)表示求A1到A10单元格范围内的数据总和。 2. AVERAGE函数:用于求一组数据的平均值。例如,=AVERAGE(A1:A10)表示求A1到A10单元格范围内数据的平均值。 3. MAX和MIN函数:分别用于求一组数据的最大值和最小值。例如,=MAX(A1:A10)表示求A1到A10单元格范围内数据的最大值。 4. COUNT函数:用于统计一组数据中的非空单元格数量。例如,=COUNT(A1:A10)表示统计A1到A10单元格范围内的非空单元格数量。 5. IF函数:用于根据特定条件判断返回不同结果。例如,=IF(A1>5,"通过","不通过")表示如果A1大于5,则返回“通过”,否则返回“不通过”。 6. VLOOKUP函数:用于在一个范围内查找特定值,并返回该值所在单元格的对应值。例如,=VLOOKUP(A1,A:B,2,FALSE)表示在A列中查找A1的值,并返回该值所在B列的对应值。 7. CONCATENATE函数:用于将多个单元格的内容合并在一起。例如,=CONCATENATE(A1," ",B1)表示将A1单元格和B1单元格的内容合并在一起。 8. DATE函数:用于生成一个指定日期的日期值。例如,=DATE(2022,1,1)表示生成2022年1月1日的日期值。 9. TEXT函数:用于将数值格式化为指定的文本格式。例如,=TEXT(A1,"0.00%")表示将A1单元格的数值转换为百分比形式,并保留两位小数。 10. RANK函数:用于计算一组数据在排序过程中的排名。例如,=RANK(A1,A1:A10,1)表示计算A1在A1到A10单元格范围内数据的排序排名。 通过利用这些常用函数公式,用户可以实现Excel中的各种简单操作,提高数据处理效率和准确性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值