Transféré de l'ancien fofo By Spark
Voici un tutoriel sur le déplacement des maps, en premier l'enregistrement, puis le déplacement dans un sens, puis dans un autre.
Tout d'abord je vais utiliser la fonction _ispressed(num_de_touche)
Voici une liste des touches :
Cliquez pour révéler
Cliquez pour masquer
01 Left mouse button
02 Right mouse button
04 Middle mouse button (three-button mouse)
05 Windows 2000/XP: X1 mouse button
06 Windows 2000/XP: X2 mouse button
08 BACKSPACE key
09 TAB key
0C CLEAR key
0D ENTER key
10 SHIFT key
11 CTRL key
12 ALT key
13 PAUSE key
14 CAPS LOCK key
1B ESC key
20 SPACEBAR
21 PAGE UP key
22 PAGE DOWN key
23 END key
24 HOME key
25 LEFT ARROW key
26 UP ARROW key
27 RIGHT ARROW key
28 DOWN ARROW key
29 SELECT key
2A PRINT key
2B EXECUTE key
2C PRINT SCREEN key
2D INS key
2E DEL key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
5B Left Windows key
5C Right Windows key
60 Numeric keypad 0 key
61 Numeric keypad 1 key
62 Numeric keypad 2 key
63 Numeric keypad 3 key
64 Numeric keypad 4 key
65 Numeric keypad 5 key
66 Numeric keypad 6 key
67 Numeric keypad 7 key
68 Numeric keypad 8 key
69 Numeric keypad 9 key
6A Multiply key
6B Add key
6C Separator key
6D Subtract key
6E Decimal key
6F Divide key
70 F1 key
71 F2 key
72 F3 key
73 F4 key
74 F5 key
75 F6 key
76 F7 key
77 F8 key
78 F9 key
79 F10 key
7A F11 key
7B F12 key
7C-7F F13 key - F16 key
80H-87H F17 key - F24 key
90 NUM LOCK key
91 SCROLL LOCK key
A0 Left SHIFT key
A1 Right SHIFT key
A2 Left CONTROL key
A3 Right CONTROL key
A4 Left MENU key
A5 Right MENU key
En premier
On va faire une boucle de détection de touche afin que lorsque l'on appuis sur F2 cela enregistre la position et quand on appuis sur F3 on est arrivé au bout du chemin et quand on rappuis sur F2 cela réenregistre les positions des plots de retour.
Cliquez pour révéler
Cliquez pour masquer
#include <Misc.au3>
Dim $cpt = 0 , $cpt2 = 0 , $case[90][2][2] , $pos[2] , $fin = 0
While 1
If _ispressed(71) then
enregistre($cpt , $cpt2)
sleep(1000)
if $cpt2 = 0 then $cpt = $cpt + 1
if $cpt2 = 1 then $cpt = $cpt - 1
EndIf
If _ispressed(72) then
If $cpt2=0 then
$fin = $cpt
$cpt -= 1
EndIf
$cpt2 += 1
sleep(1000)
EndIf
If $cpt < 0 and $fin <> 0 then ExitLoop
Wend
Donc on fait appel à une fonction quand on appuis sur F2 et quand on fait F3 on rajoute une valeur dans le cpt2 pour indiquer que c'est pour le retour, on enregistre dans $case jusque 90 cases à l'aller et 90 au retour.
Maintenant la fonction.
Cliquez pour révéler
Cliquez pour masquer
Func enregistre($cpt, $cpt2)
$pos = MouseGetPos()
$case[$cpt][$cpt2][0] = $pos[0]
$case[$cpt][$cpt2][1] = $pos[1]
MouseMove( $case[$cpt][$cpt2][0] , $case[$cpt][$cpt2][1] )
MouseClick("left")
EndFunc
Bin nous reste plus qu'a l'intégrer dans un bot.
Quand $cpt = 0 on sort de la boucle donc on a fait tous les plots.
La fonction
Je vais juste faire le cheminement, à vous de l'intégrer comme bon vous semble.
Cliquez pour révéler
Cliquez pour masquer
$cpt = 0
$cpt2 = 0
While 1
MouseMove( $case[$cpt][$cpt2][0] , $case[$cpt][$cpt2][1] )
MouseClick("left")
sleep(4000)
If $cpt2 = 0 then $cpt += 1
If $cpt2 = 1 then $cpt -= 1
If $cpt = $fin or $cpt < 0 then
If $cpt2 = 0 then
$cpt2 = 1
$cpt -= 1
Else
$cpt2 = 0
$cpt += 1
EndIf
EndIf
Wend
Ce qui nous donne au final
Cliquez pour révéler
Cliquez pour masquer
; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
; Options
;Variables
;;;; Body of program would go here ;;;
#include <Misc.au3>
Dim $cpt = 0 , $cpt2 = 0 , $case[90][2][2] , $pos[2] , $fin = 0
While 1
If _ispressed(71) then
enregistre($cpt , $cpt2)
sleep(1000)
if $cpt2 = 0 then $cpt = $cpt + 1
if $cpt2 = 1 then $cpt = $cpt - 1
EndIf
If _ispressed(72) then
If $cpt2=0 then
$fin = $cpt
$cpt -= 1
EndIf
$cpt2 += 1
sleep(1000)
EndIf
If $cpt < 0 and $fin <> 0 then ExitLoop
Wend
$cpt = 0
$cpt2 = 0
While 1
MouseMove( $case[$cpt][$cpt2][0] , $case[$cpt][$cpt2][1] )
MouseClick("left")
sleep(4000)
If $cpt2 = 0 then $cpt += 1
If $cpt2 = 1 then $cpt -= 1
If $cpt = $fin or $cpt < 0 then
If $cpt2 = 0 then
$cpt2 = 1
$cpt -= 1
Else
$cpt2 = 0
$cpt += 1
EndIf
EndIf
Wend
Func enregistre($cpt, $cpt2)
$pos = MouseGetPos()
$case[$cpt][$cpt2][0] = $pos[0]
$case[$cpt][$cpt2][1] = $pos[1]
MouseMove( $case[$cpt][$cpt2][0] , $case[$cpt][$cpt2][1] )
MouseClick("left")
EndFunc
;;;;;;;;
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"_______http://cadernis.free.fr/',0,0)
WEnd
ToolTip("")
EndFunc
Func Terminate()
Exit 0
EndFunc
Func ShowMessage()
MsgBox(4096,"","http://cadernis.free.fr/")
EndFunc
Quand on fait une boucle avec détection de touche, il faut toujours mettre un timer sachez que l'ordinateur effectue les opérations en quelques milisecondes et que vous pouvez rester appuyer jusque 500 milisecondes sur une touche, cela fausserais la manip.