Reproduce One-Touch Search on Python 3.7.3. (Windows 10)

What is One-Touch Search?

It is a function that google searches the highlighted character string with one click of a button. This is a convenient function installed in Logitech's M950 mouse. The reason I reproduced it in Python this time is that this useful feature has disappeared from the next generation of mice.

As an aside, I've been using the M950 for nearly nine years because this feature is so convenient that I can't leave it. I was troubled by chattering on the way, but it is a convenient function that I disassemble, repair and continue to use.

Program outline

  1. Write a script in Python.
  2. Allow 1 to be started with a bat file.
  3. Create the shortcut of 2 and start it with the shortcut key.

1. Python script

import webbrowser
import pyautogui
import pyperclip
import time

pyautogui.hotkey('alt', 'tab')
time.sleep(0.03)
pyautogui.hotkey('ctrl', 'c')
time.sleep(0.03)
clipboard = pyperclip.paste()
url = 'https://www.google.co.jp/search?hl=ja&q=' + clipboard

webbrowser.open(url)

As a flow,

  1. Make keyboard input with pyautogui and copy the highlighted character string.
  2. Read the contents of the clipboard with pyperclip'clipboard'.
  3. Create a'url' for google search on the'url ='line.
  4. Access'url' with a standard browser with webbrowser is. In the part of time.sleep (), I added it because I couldn't copy it well in my environment without it.

2. Create bat file

Create a bat file in any location. First, right-click> New> Text Document. The content of the text is

Path to python.exe (half-width space) Path to .py created in 1

is. Then change the extension of this text file from .txt to .bat. You can ignore the warning that appears at that time.

3. Create a shortcut for bat so that it can be executed with hotkeys.

Right-click the .bat file created in 1.2 and select "Create Shortcut". 2. Right-click on the created shortcut and select "Properties". 3. Select the "Shortcuts" tab, select "Shortcut Keys", and then press any key combination *. 4. Set "Runtime size" to "Minimize" to improve the appearance. プロパティ.jpg

That's it. In the example, I created a file called onetouch.bat and set the shortcut key with "Ctl + Shift + Alt + K". Highlight any character string and press the shortcut key set in 3. Hopefully you should be able to do a google search. If you assign this shortcut key to a mouse button, you can search by simply pressing the mouse button.

problem

--If the highlighted character string starts with "#", you cannot search well. --Slightly slower than the genuine One-Touch Search.

Recommended Posts

Reproduce One-Touch Search on Python 3.7.3. (Windows 10)
Python on Windows
python basic on windows ②
Install python on windows
Set-enable Python virtualenv on Windows
Run Openpose on Python (Windows)
Install watchdog on Windows + Python 3.3
Python + Kivy development on Windows
Sphinx-autobuild (0.5.2) on Windows7, Python 3.5.1, Sphinx 1.3.5
Fastest Python installation on Windows
Build Python environment on Windows
I ran python on windows
[Python] [Chainer] [Windows] Install Chainer on Windows
Use Python on Windows (PyCharm)
Python environment construction memo on Windows 10
Python 3.6 on Windows ... and to Xamarin.
Installing Kivy on Windows10 64bit Python3.5
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Install Pytorch on Blender 2.90 python on Windows
Integrate Modelica and Python on Windows
Installing Kivy-Designer on Windows10 64bit Python3.5
Mecab / Cabocha / KNP on Python + Windows
Install Python development environment on Windows 10
Python CGI file created on Windows
Getting started with Python 3.8 on Windows
Notes for using OpenCV on Windows10 Python 3.8.3.
Run servo with Python on ESP32 (Windows)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Virtualenv does not work on Python3.5 (Windows)
Creating a python virtual environment on Windows
Use without installing python 2.x on Windows
twitter on python3
python windows environment
Python installation (Windows)
python on mac
Python on Windbg
Install and run Python3.5 + NumPy + SciPy on Windows 10
Put MicroPython on Windows to run ESP32 on Python
Install Python3, numpy, pandas, matplotlib, etc. on Windows
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Simply build a Python 3 execution environment on Windows
Notes on installing Python3 and using pip on Windows7
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
[Python] How to install OpenCV on Anaconda [Windows]
[Note] Installing Python 3.6 + α on Windows and RHEL
Installing TensorFlow on Windows Easy for Python beginners
Create a Python virtual development environment on Windows
Install ZIP version Python and pip on Windows 10
Python conda on cygwin
Install python on WSL
Sequential search with Python
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
PyOpenGL setup on Python 3
Install Python on Pidora.
How to embed mod_wsgi into Apache on Python Windows
Problems with windows python being called on pipenv on WSL
Install Scrapy on python3
[Python] This is easy! Search for tweets on Twitter