Advertisement
littlebelialskey

getMousePosOnClick.ahk

Jul 25th, 2024 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; 20240714
  2. ; getMousePosOnClick_1.2.ahk
  3. ; 1) SHIFT + MOUSE1 : Afficher la dernière position du pointeur sur l ecran
  4. ; 2) CTRL  + MOUSE1 : Remplacer le contenu du clipboard par la position
  5. ; 3) ALT  + MOUSE1 : Enregistre la position dans un fichier, comme ça on peut bombarder
  6.  
  7. ; ==========================================  ___   _  _   ___   _____   ==========================================
  8. ; ========================================== |_ _| | \| | |_ _| |_   _|  ==========================================
  9. ; ==========================================  | |  | .` |  | |    | |    ====small=================================
  10. ; ========================================== |___| |_|\_| |___|   |_|    ==========================================
  11. ; ==========================================                             ==========================================
  12.  
  13. #NoEnv  
  14. SendMode Input  
  15. SetWorkingDir %A_ScriptDir%  
  16. #SingleInstance Force
  17.  
  18. global logfile_path:="D:\SCRIPTS\AHK\getMousePosOnClick.log"
  19. verbose:=0
  20. log_datetime:=0 ; BUG : toujours true
  21.  
  22. ; ==========================================   ___    ___    _  _    ___   _____   ___    ___    _  _   ___  ==========================================
  23. ; ==========================================  | __|  / _ \  | \| |  / __| |_   _| |_ _|  / _ \  | \| | / __| ==========================================
  24. ; ==========================================  | _|  | (_) | | .` | | (__    | |    | |  | (_) | | .` | \__ \ ================small=====================
  25. ; ==========================================  |_|    \___/  |_|\_|  \___|   |_|   |___|  \___/  |_|\_| |___/ ==========================================
  26. ; ==========================================                                                                 ==========================================
  27.  
  28. WriteLog(text) {
  29.     if(StrLen(logfile_path) > 0){
  30.         if(log_datetime is true){
  31.             ; MsgBox log_datime VRAI
  32.             FileAppend, `n(%A_YYYY%%A_MM%%A_DD% %A_Hour%%A_Min%%A_Sec% %A_MSec%) %text%, logfile_%A_YYYY%%A_MM%%A_DD%.txt
  33.         } else {
  34.             ; MsgBox log_datime FAUX OK ca marche
  35.             FileAppend, `n%text%, logfile_%A_YYYY%%A_MM%%A_DD%.txt
  36.         }
  37.     } else {
  38.         MsgBox "Error : fichier invalide"
  39.     }
  40. }
  41.  
  42. msgMousePos(){ ; SHIFT + mouse1 : popup
  43.     MouseGetPos, xpos, ypos
  44.     MsgBox, Mousepos : X=%xpos% Y=%ypos%.  
  45. }
  46.  
  47. getMouseXpos(){ ; CTRL + mouse 1 : copy to clipboard
  48.     MouseGetPos, xpos
  49.     return xpos
  50. }
  51.  
  52.  
  53.  ; ALT + mouse1 writes in a logfile the X,Y so you can do it in game
  54.  ; example : (20240725 192256 005) 1139:393
  55. getMouseYpos(){ ; ALT + mouse1
  56.     MouseGetPos, irrelevantshitwedontcare, ypos
  57.     return ypos
  58. }
  59.  
  60. ; ==========================================   ___    ___   ___   ___   ___   _____   ==========================================
  61. ; ==========================================  / __|  / __| | _ \ |_ _| | _ \ |_   _|  ==small===================================
  62. ; ==========================================  \__ \ | (__  |   /  | |  |  _/   | |    ==========================================
  63. ; ==========================================  |___/  \___| |_|_\ |___| |_|     |_|    ==========================================
  64. ; ==========================================                                          ==========================================
  65.  
  66. CoordMode, mouse, Screen
  67.  
  68. ; -------------------------------------------- SHIFT + CLIC : display (ok marche )
  69. +LButton::
  70.     MouseGetPos, x, y
  71.     MsgBox (SHIFT + Mouse1) MOUSE POS = %x%:%y%
  72. return
  73.  
  74. ; -------------------------------------------- CTRL + CLIC : press-papiers (ok marche )
  75.  
  76. ^LBUtton::
  77.     MouseGetPos, x, y
  78.     clipboard := x ";" y
  79.     MsgBox (CTRL + Mouse1) CLIPBOARD COPY = %clipboard%
  80. return
  81.  
  82. ; -------------------------------------------- ALT + CLIC : append la position à un fichier
  83. !LButton::
  84.     MouseGetPos, x, y
  85.     if(verbose){
  86.         MsgBox (ALT + Mouse1) ADDED TO LOGFILE = %x%:%y%
  87.     }
  88.     writeLog(x ":" y)
  89. return
  90.  
  91.  
  92. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KILL F12    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  93. F12::
  94.     MsgBox "Script interrompu"
  95. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement