Problème de boucle sur un script

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Problème de boucle sur un script

Re: Problème de boucle sur un script

Post by flyingDman » 25 Nov 2022, 16:32

Quel est le rôle des b ?

Code: Select all

[b] .... [/b]
S'il y en a pas, enlevez.

Re: Problème de boucle sur un script

Post by joedf » 25 Nov 2022, 11:11

Essayez ceci?
J'ai ajouté un Loop, %UserInput% et arrangé les { et }

Code: Select all

^j::   ;Lorsque la commande CTRL + J est envoyée le logiciel va changer le pays du conducteur sur France, sauvegarder et passer au suivant.
InputBox, UserInput, Hackoscan, Renseignez le nombre de conducteurs., , 300, 200
if ErrorLevel
{
	MsgBox, A bientôt.
}
else
{
	MsgBox, Vous avez déclaré "%UserInput%" conducteur(s)
}

if (UserInput = 1)  ; Etape 1
{
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Return
}
else if (UserInput = 2)  ; Etape 2
{
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
	Send, {down}
	Send, +{Click, 55 56} 
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Return
}
else if (UserInput > 2)
{
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
	Send, {down}
	Send, +{Click, 55 56} 
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
	Loop, %UserInput%
	{
		Send, {down [b]%A_Index%[/b]} ; Ici la variable i doit s'incrémenter de 1 à chaque boucle tant que UserInput n'est pas atteint
		Send, +{Click, 55 56} 
		Send, +{Click, 700 192}
		Send, f r
		Send, {Enter}
		Send, +{Click, 140 60}
		Sleep, 7000
		Send, +{Click, 100 195}
		Send, {PgUp 10}
	}
	
	Return
}
Return

Problème de boucle sur un script

Post by raidgo » 25 Nov 2022, 07:06

Bonjour à toute la communauté.

Je débute avec AHK et la programmation en général, donc s'il vous plait soyez indulgents ;)

Pour mon boulot, j'ai commencé à écrire un script me permettant d'automatiser une tâche pénible.

Ce script ouvre une boite de dialogue me demandant combien de chauffeurs ils doit traiter. S'en suit des déplacements à la souris et des envois de clavier. Jusque là tout fonctionne.

C'est fonctionnel pour le premier conducteur. Donc si ma valeur tapée en boîte de dialogue est 1, le script est fonctionnel. Pareil pour 2.

Le problème c'est que j'aimerai faire une boucle si UserInput > 2 et qu'il s'incrémente automatiquement en fonction de la saisie de UserInput. (Admettons je lui déclare 30 chauffeurs, il effectue l'opétation 30x en incrémentant une variable appelée i plus bas de 1.

Je ne suis pas sur d'être clair dans mes propos...

Code: Select all

^j::   ;Lorsque la commande CTRL + J est envoyée le logiciel va changer le pays du conducteur sur France, sauvegarder et passer au suivant.
InputBox, UserInput, Hackoscan, Renseignez le nombre de conducteurs., , 300, 200
if ErrorLevel
    
	{
	
	MsgBox, A bientôt.
	
	}
	
else
    {
	
	MsgBox, Vous avez déclaré "%UserInput%" conducteur(s)

if (UserInput = 1)  ; Etape 1
	
	{
	
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Return
	
	}

else if (UserInput = 2)  ; Etape 2
	
	{
	
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
	Send, {down}
	Send, +{Click, 55 56} 
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Return
	
	}

else if (UserInput > 2)

	{

	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Send, +{Click, 100 195, 2}
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
	Send, {down}
	Send, +{Click, 55 56} 
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	
[b]Que renseigner ici pour démarrer la boucle?	[/b]
	
	{
	Send, {down [b]i[/b]} ; Ici la variable i doit s'incrémenter de 1 à chaque boucle tant que UserInput n'est pas atteint
	Send, +{Click, 55 56} 
	Send, +{Click, 700 192}
	Send, f r
	Send, {Enter}
	Send, +{Click, 140 60}
	Sleep, 7000
	Send, +{Click, 100 195}
	Send, {PgUp 10}
	Return

	}
	
Return
	
	}

	}
	
Return
[Mod edit: + [code][/code] tags.]

Top