added functionality for key presses
This commit is contained in:
		
							parent
							
								
									76e7826b60
								
							
						
					
					
						commit
						fb5054c7f7
					
				
					 2 changed files with 25 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -23,6 +23,21 @@ function injectjscript($main, $control, $options)
 | 
			
		|||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * press given key
 | 
			
		||||
 *
 | 
			
		||||
 * @param \ScriptedBrowser\Main $main
 | 
			
		||||
 * @param \ScriptedBrowser\Control $control
 | 
			
		||||
 * @param array<string,mixed> $options options
 | 
			
		||||
 * @return bool always true
 | 
			
		||||
 */
 | 
			
		||||
function key($main, $control, $options)
 | 
			
		||||
{
 | 
			
		||||
    $key = $main->vars($options['parameter']);
 | 
			
		||||
    $control->key($key);
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * do mouse left click
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -184,6 +184,16 @@ class Control
 | 
			
		|||
        return $this->executeScript('return [window.pageXOffset, window.pageYOffset];');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * press given key (combination)
 | 
			
		||||
     *
 | 
			
		||||
     * @param string $key key to press
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function key($key)
 | 
			
		||||
    {
 | 
			
		||||
        fwrite($this->xdotool, "key $key\n");
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * move mouse to absolute position
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue