Skip to content

Commit

Permalink
Merge pull request #136 from lohvht/master
Browse files Browse the repository at this point in the history
#78 - add right-click step by @lohvht (as part of internship interview)
  • Loading branch information
kensoh authored Apr 16, 2018
2 parents ab86ffd + 7644045 commit c008798
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tagui.sikuli/tagui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def tap_intent ( raw_intent ):
else:
return 0

# function for rtap / rclick step
def rtap_intent ( raw_intent ):
params = (raw_intent + ' ')[1+(raw_intent + ' ').find(' '):].strip()
print '[tagui] ACTION - rclick ' + params
if exists(params):
return rightClick(params)
else:
return 0

# function for dtap / dclick step
def dtap_intent ( raw_intent ):
params = (raw_intent + ' ')[1+(raw_intent + ' ').find(' '):].strip()
Expand Down Expand Up @@ -142,6 +151,8 @@ def vision_intent ( raw_intent ):
def get_intent ( raw_intent ):
if raw_intent[:4].lower() == 'tap ' or raw_intent[:6].lower() == 'click ':
return 'tap'
if raw_intent[:5].lower() == 'rtap ' or raw_intent[:7].lower() == 'rclick ':
return 'rtap'
if raw_intent[:5].lower() == 'dtap ' or raw_intent[:7].lower() == 'dclick ':
return 'dtap'
if raw_intent[:6].lower() == 'hover ' or raw_intent[:5].lower() == 'move ':
Expand All @@ -167,6 +178,8 @@ def parse_intent ( script_line ):
intent_type = get_intent(script_line)
if intent_type == 'tap':
return tap_intent(script_line)
elif intent_type == 'rtap':
return rtap_intent(script_line)
elif intent_type == 'dtap':
return dtap_intent(script_line)
elif intent_type == 'hover':
Expand Down
10 changes: 10 additions & 0 deletions src/tagui_parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function parse_intent($script_line) {$GLOBALS['line_number']++; $GLOBALS['real_l
switch (get_intent($script_line)) {
case "url": return url_intent($script_line); break;
case "tap": return tap_intent($script_line); break;
case "rtap": return rtap_intent($script_line); break;
case "dtap": return dtap_intent($script_line); break;
case "hover": return hover_intent($script_line); break;
case "type": return type_intent($script_line); break;
Expand Down Expand Up @@ -248,6 +249,7 @@ function get_intent($raw_intent) {$lc_raw_intent = strtolower($raw_intent);

// first set of conditions check for valid keywords with their parameters
if ((substr($lc_raw_intent,0,4)=="tap ") or (substr($lc_raw_intent,0,6)=="click ")) return "tap";
if ((substr($lc_raw_intent,0,5)=="rtap ") or (substr($lc_raw_intent,0,7)=="rclick ")) return "rtap";
if ((substr($lc_raw_intent,0,5)=="dtap ") or (substr($lc_raw_intent,0,7)=="dclick ")) return "dtap";
if ((substr($lc_raw_intent,0,6)=="hover ")or(substr($lc_raw_intent,0,5)=="move ")) return "hover";
if ((substr($lc_raw_intent,0,5)=="type ") or (substr($lc_raw_intent,0,6)=="enter ")) return "type";
Expand Down Expand Up @@ -282,6 +284,7 @@ function get_intent($raw_intent) {$lc_raw_intent = strtolower($raw_intent);

// second set of conditions check for valid keywords with missing parameters
if (($lc_raw_intent=="tap") or ($lc_raw_intent=="click")) return "tap";
if (($lc_raw_intent=="rtap") or ($lc_raw_intent=="rclick")) return "rtap";
if (($lc_raw_intent=="dtap") or ($lc_raw_intent=="dclick")) return "dtap";
if (($lc_raw_intent=="hover") or ($lc_raw_intent=="move")) return "hover";
if (($lc_raw_intent=="type") or ($lc_raw_intent=="enter")) return "type";
Expand Down Expand Up @@ -439,6 +442,13 @@ function tap_intent($raw_intent) {$twb = $GLOBALS['tagui_web_browser'];
if ($params == "") echo "ERROR - " . current_line() . " target missing for " . $raw_intent . "\n"; else
return "{techo('".$raw_intent."');".beg_tx($params).$twb.".click(tx('" . $params . "'));".end_tx($params);}

function rtap_intent($raw_intent) {$twb = $GLOBALS['tagui_web_browser'];
$params = trim(substr($raw_intent." ",1+strpos($raw_intent." "," ")));
if (is_sikuli($params)) {$abs_params = abs_file($params); $abs_intent = str_replace($params,$abs_params,$raw_intent);
return call_sikuli($abs_intent,$abs_params);} // use sikuli visual automation as needed
if ($params == "") echo "ERROR - " . current_line() . " target missing for " . $raw_intent . "\n"; else
return "{techo('".$raw_intent."');".beg_tx($params).$twb.".mouse.rightclick(tx('" . $params . "'));".end_tx($params);}

function dtap_intent($raw_intent) {$twb = $GLOBALS['tagui_web_browser'];
$params = trim(substr($raw_intent." ",1+strpos($raw_intent." "," ")));
if (is_sikuli($params)) {$abs_params = abs_file($params); $abs_intent = str_replace($params,$abs_params,$raw_intent);
Expand Down

0 comments on commit c008798

Please sign in to comment.