Skip to content

Instantly share code, notes, and snippets.

@romichi
Created June 17, 2012 10:13
Show Gist options
  • Select an option

  • Save romichi/2944112 to your computer and use it in GitHub Desktop.

Select an option

Save romichi/2944112 to your computer and use it in GitHub Desktop.
メモ帳にキーを送る
# -*- coding:utf-8 -*-
import time
import win32gui
import win32com.client
shell = win32com.client.Dispatch('WScript.Shell')
shell.Run('Notepad') #メモ帳の起動
time.sleep(1)
windowHandle = win32gui.FindWindow('notePad', None) #メモ帳のウィンドウハンドルを取得
win32gui.SetForegroundWindow(windowHandle) #メモ帳をアクティブにする
shell.SendKeys('abcdefg') #keyを送る
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment