fork(3) download
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # untitled.py
  5. #
  6. # 遊園地
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. # MA 02110-1301, USA.
  22. #
  23. #
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. import pyautogui
  31. from time import sleep
  32. from pynput.keyboard import Key, Listener
  33.  
  34.  
  35.  
  36.  
  37. r=[]
  38. R=[]
  39. rR=[]
  40.  
  41. def on_press(key):
  42. try:
  43. r.append(key.char)
  44. except AttributeError:
  45. print(key)
  46.  
  47.  
  48. def on_release(key):
  49. R.append(key)
  50. if key == Key.esc:
  51. return False
  52.  
  53.  
  54. # 押した時のみ
  55. def When_pushed():
  56. with Listener(on_press= on_press) as listener:listener.join()
  57. # 離した時のみ
  58. def When_released():
  59. with Listener(on_release= on_release) as listener:listener.join()
  60. # 押して離した時
  61. def Pushed_away():
  62. with Listener(on_press = on_press,on_release= on_release) as listener:listener.join()
  63.  
  64.  
  65.  
  66.  
  67. #When_pushed()
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. # マウス
  76. class Mouse_operation:
  77.  
  78. i=0
  79. l=[] #マウス座標用
  80.  
  81. # 初期処理で現状の座標を追加
  82. T=[list(pyautogui.position())]*2
  83.  
  84.  
  85. # 終了ボタンが押されたら
  86. def AAA():
  87. Mouse_operation.i=1
  88.  
  89.  
  90. # マウス移動の記録
  91. def Move_mouse():
  92. while Mouse_operation.i==0:
  93. sleep(0.01)
  94. Mouse_operation.T+=[list(pyautogui.position())]
  95.  
  96. # 前回の座標と更新された座標が同じ
  97. if Mouse_operation.T[-2]==Mouse_operation.T[-1]:
  98. pass
  99. # 座標が違うならl配列に追加
  100. else:
  101. Mouse_operation.l+=[list(pyautogui.position())]
  102. print(Mouse_operation.l[-1]) # 最新の座標を確認
  103.  
  104. # 終了
  105. if Mouse_operation.i==1:
  106. break
  107.  
  108. # マウスの再生
  109. def Mouse_move_playback():
  110. [pyautogui.moveTo(i[0], i[1], time) for i in l]
  111.  
  112.  
  113.  
  114. #Mouse_operation.Move_mouse()
  115.  
  116.  
  117.  
Runtime error #stdin #stdout #stderr 0.04s 9376KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 30, in <module>
ImportError: No module named 'pyautogui'