How to rightclick at current mouse position & Right click Context menu keyboard button constant help

Asked by Learner

When i use rightClick on a particular region/button image its working fine . but

1. How to RightClick at current mouse cursor position . If i do RightClick() without any parameter then its randomly rightclicking somewhere.
2. How to get current coordinates of mouse cursor
3. Also there is a button in Keyboard to get RightClick context menu , how can i call that [ Key.RightContextButton.... ] .

Above questions are some what related

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

- a click(whatever) always click on whatever
- if whatever is an image or a pattern, this is first searched in the given region (the whole screen with just click and the region reg in case of reg.click(image or pattern)
- if whatever is not given at all (click()) clicks on the centre of the given region (screen center in this case, center of reg in case of reg.click()
- if in the respective region (screen with click() and reg in case of reg.click()) something was searched before (either explicitly with find/wait/exists or implicitly with click(image or pattern) then this last match is clicked (hence in this case click() is equivalent to click(getLastMatch()), and reg.click() is equivalent to reg.click(getLastMatch())

this all applies to rightClick(), doubleClick(), hover() as well

- click(mouseAt()) clicks at the current mouse position

- to produce any key combination use type()

the docs know more: http://doc.sikuli.org

Revision history for this message
RaiMan (raimund-hocke) said :
#2

correction:
.....
then this last match is clicked (hence in this case click() is equivalent to click(getLastMatch()), and reg.click() is equivalent to reg.click(reg.getLastMatch())

Revision history for this message
Learner (gopikrish2000) said :
#3

Thanks RaiMan for the reply but i'm still confused .

1. click(mouseAt()) , mouseAt() is not defined error is coming , did you imply to hardcode the coordinates like click(Location(x,y)) that will work but don't want to HardCode coordinates nor give image at that place nor match a pattern , Instead i want clicks to happen at the current mouse position [ get current mouse position while its executing and perform click .. ]

2. Also regarding Keys , there will be one key in laptop which just generates RightClick Menu ( beside the right side of Alt Key for most laptops ) . How to use that key as i'm not able to find it in Key Constants section .

See my requirement is I need to right click on a any image/folder and perform some actions like check properties . For this i want to write the generic script ( so that i don't have to change script every time to right click that particular image or pattern , instead i will select the item which i want and run that script without changing the script at all , it should click in runtime where mouse pointer is located )

Revision history for this message
Best RaiMan (raimund-hocke) said :
#4

at 1: sorry for confusion - it is atMouse()

so if you already have moved the mouse pointer to the right location (e.g. using hover)

rightClick(atMouse())

should do what you want.

--- RightClick Menu key
… if this is a special key, that is not available on a standard US PC keyboard, then you will not be able to use it with type().
you need a valid key combination from the available key constants and a normal key.

Revision history for this message
Learner (gopikrish2000) said :
#5

Thanks RaiMan , atMouse() working well .

One thing the documentation for sikuli should be better ( should be updated to include all functions , keys etc ) or also SikuliIDE doesn't have all available functions/ autocompletion available , so that it will be easy for new guys like me , thanks anyway.

Revision history for this message
Learner (gopikrish2000) said :
#6

Thanks RaiMan, that solved my question.