Page 1 of 2

Script complexe pour 2 touches

Posted: 31 Jan 2023, 18:02
by 6zerox
Bonjour
J'essaie de réaliser un script mais il me parait complexe alors j'en appelle a vos compétences qui seront bien plus élevées que les miennes

Je souhaiterai réaliser un script qui lorsque j'appuie sur F par exemple cela appuie sur P (un appuie simple sur P) puis appuie sur M (appuie qui reste enfoncé sur M)
Et lorsque je rappuierai sur la touche F cela rappuiera sur P cela relèvera la touche M
Je ne sais pas si je me suis bien exprimé n'hésitez pas si vous avez des questions
Pour le moment j'en suis à

Code: Select all

 f::

Send, {P}
Sleep, 10
Send, {M down}
Send, {P}
Send, {M up}
Ce qui ne semble pas fonctionner du tout comme je le souhaiterai,
Je pense que je ne m'y prends pas de la bonne manière et qu'il faudrait que je découpe en gros en 2 morceaux mon script comme
Partie 1 : j'appuie sur F donc ça appuie sur P et ça reste appuyé sur M
Partie 2 : Si un nouvel appuie sur F existe alors appuyer de nouveau sur P et relâcher M

En espérant pouvoir vous aider un jour en retour
Merci :)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 09:37
by DuckingQuack
J'utilise Google translate donc il pourrait y avoir des malentendus. J'ai créé un script qui correspond peut-être à ce que vous demandez, mais je suis au travail et incapable de le tester.
Il vérifie l'état de m lorsque vous appuyez sur f et envoie une commande basée sur l'état actuel de m.

Code: Select all

AHKv1
f::
	if getkeystate(m, t){
		send, p
		send, {m up}
	}
	else{
		send, p
		sleep, 10
		send, {m down}
	}
return

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 10:22
by 6zerox
Hello :)
Thanks you for answer but doesn't work like i want : You do a script when i press F that press P and M but release M i think because if i press F that do "PM"

Thanks you for help and sorry for my english xD
Tu peux essayer sur un word tu verras que quand tu appuies sur F il y a qu'un seul appuie sur P et un seul sur M alors que je voudrai que le bouton M reste enfoncé jusqu'à ce que j'appuie de nouveau sur F
En attente d'autres aides :)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 10:49
by DuckingQuack
À partir de Google Translate : Je serai en mesure de créer un meilleur script dans environ 8 heures lorsque je pourrai enfin m'asseoir devant mon PC.
Votre désir est d'utiliser "F" comme raccourci clavier qui, à la première pression, envoie un "P" suivi de l'activation de "M". Ensuite, à la deuxième pression sur "F", vous souhaitez envoyer "P" suivi de la désactivation de "M" ?

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 11:09
by 6zerox
Exactly :)
Thanks you for help

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 11:14
by DuckingQuack
I can fix that, virtual keys don’t continuously send their key as if you were holding the button down because the keyboard does that. So I’ll add a repeated “m” to the script.

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 11:26
by DuckingQuack
Test this and let me know how it goes.

Code: Select all

#Requires AutoHotkey v1.1.33
F1::
If on := !on {
	Send, p
 	SetTimer timer, 10
	} Else {
	Send, p
 	SetTimer timer, Off
	}
Return

timer(){
	Send, m
}

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 12:20
by 6zerox
said me an error in script

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 12:38
by DuckingQuack
I corrected some syntax mistakes, thank you for your patience. I’m doing this from my phone. Please test this one and let me know how it goes.

Code: Select all

f::
If on := !on {
	Send, p
 	SetTimer, timer, 10
	} Else {
	Send, p
 	SetTimer timer, Off
	}
Return

timer()
{
	Send, m
}
Return

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 12:42
by 6zerox
An new error :p

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 12:48
by DuckingQuack
@6zerox I may have gotten it right this time.

Code: Select all

f::
If on := !on {
	Send, p
 	SetTimer, timer, 10
	} Else {
	Send, pm
 	SetTimer, timer, Off
	}
Return

timer()
{
	Send, m
}
Return

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 13:26
by 6zerox
A new error :)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 13:31
by 6zerox
OH may be because i have version 1.XX ?

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 13:36
by DuckingQuack
This is a script for AHKv1… I’m more accustomed to writing in AHKv2, which is why I’m having problems, but I’ll test it when I get home. I need to know what the errors are to fix them.

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 14:22
by 6zerox
DuckingQuack wrote:
01 Feb 2023, 11:14
I can fix that, virtual keys don’t continuously send their key as if you were holding the button down because the keyboard does that. So I’ll add a repeated “m” to the script.
Hum sorry but i really need that is only one M on continue and not a lot of M like : if press F press P and release and push M and if press F Again so press P and release and up M
I sais it’s difficult macro for 2 touch xD

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 14:31
by 6zerox
DuckingQuack wrote:
01 Feb 2023, 11:14
I can fix that, virtual keys don’t continuously send their key as if you were holding the button down because the keyboard does that. So I’ll add a repeated “m” to the script.
I’ m sorry but i really need it’s only one M continue and not a lot of M :D
I said it’s difficult script for two keys 😂
So to imagine it i can say
If first press F -> Press P and push M (maybe with delay for M but not sur)
If second press F -> press P and up M

Les modérateurs n’hésitez pas à dire si on doit bouger de topic car on parle anglais dans le topic fr désolé
Thanks a lot for your Time :)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 18:24
by DuckingQuack
Google Translation in parentheses (Google Traduction entre parenthèses)
@6zerox I've tested each script I've provided and have no errors. Depending on what the error is that you get, it could be an issue on your side. (J'ai testé chaque script que j'ai fourni et je n'ai aucune erreur. Selon l'erreur que vous obtenez, cela pourrait être un problème de votre côté.)

The output of this script when you press "f" and wait a few seconds and press "f" again is:
(La sortie de ce script lorsque vous appuyez sur "f" et attendez quelques secondes et appuyez à nouveau sur "f" est) :
pmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmp

Code: Select all

#Requires AutoHotkey v1.1.33
Esc::ExitApp
f::
If on := !on {
	Send, p
 	SetTimer, timer, 10
	} Else {
	Send, p
 	SetTimer, timer, Off
	}
Return

timer(){
	Send, m
}

If you require a different output result from pressing a single button, please describe it as I have done above. If this was the desired output, then I wish you good luck in resolving your error codes. (Si vous avez besoin d'un résultat de sortie différent en appuyant sur un seul bouton, veuillez le décrire comme je l'ai fait ci-dessus. S'il s'agissait de la sortie souhaitée, je vous souhaite bonne chance pour résoudre vos codes d'erreur.)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 18:56
by 6zerox
oh my bad i didnt see i can scroll so i dont take the bottom
Thats work you are great ! :)

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 19:04
by DuckingQuack
6zerox wrote:
01 Feb 2023, 18:56
oh my bad i didnt see i can scroll so i dont take the bottom
Thats work you are great ! :)
:lol: :crazy: :headwall:
You had me very confused all day! lol

Re: Script complexe pour 2 touches

Posted: 01 Feb 2023, 19:40
by 6zerox
Really sory you spend time for nothing because you was in good way (sory again for english)
But you are genius to do it on tel xD