Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/benjaminguinaudeau/selinput

R wrapper for pytautogui python library
https://github.com/benjaminguinaudeau/selinput

Last synced: 15 days ago
JSON representation

R wrapper for pytautogui python library

Awesome Lists containing this project

README

        

---
output: github_document
---

# selinput

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
eval = F,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)

```

```{r, echo = FALSE, results='asis', eval = T}

library(badger)

git_repo <- "benjaminguinaudeau/tidyweb"

cat(
badge_lifecycle(),
badge_code_size(git_repo),
badge_last_commit(git_repo)
)
```

# selinput

Selinput is a wrapper for the python API pyautogui, which allows to simulate input from a real mouse and keyboard in a Docker container.

# Installation

```{r, eval = F}
devtools::install_github("benjaminguinaudeau/selinput")
```

```{r}
library(selinput)
```

# Usage

Get a few more libraries

```{r}
#devtools::install_github("benjaminguinaudeau/tidyweb")

pacman::p_load(tidyverse, selinput, dockeR, tidyselenium)
```

Start a container and a browser

```{r, eval = F}
# First Container
chrome_container <- docker$new(
image_src = "selenium/standalone-chrome-debug", #Image to be used (model for the container)
container_name = "chrome",
other_arguments = "-p 4446:4444 -p 4447:5900"

# Name you want to use
)

```

```{r}
chrome <- tidyselenium::get_driver(4446)

chrome$open()
```

If you don't have `pyautoguy` installed yet, run the following:

```{r, eval = F}
selinput::doc_init_pyautogui(chrome)
```

This should return `TRUE`

```{r, eval = F}
selinput::is_pyautogui_installed(chrome)
```

Get a screenshot (currently broken?)

```{r, eval = F}
chrome %>%
go("https://news.google.com/") %>%
selinput::doc_screenshot(file = "screenie.png")

```

List of hotkeys that can be pressed:

```{r, eval = F}

hot_keys %>% sample(10) %>% glimpse

## press tab
chrome %>%
selinput::doc_hot_keys(key = hot_keys$tab)

## press enter
chrome %>%
selinput::doc_hot_keys(key = hot_keys$enter)

```
Type on keyboard:

```{r, eval = F}
## Type on Keyboard
chrome %>%
selinput::doc_type(key = "Hello! My name is Fitzgerald.")

```

## Thanks

A huge thank you to [Favstats](https://github.com/favstats) for designing each of the hex-stickers.