Script pour application en background Topic is solved

Poser vos questions de programmation en AutoHotkey
Blyat

Script pour application en background

14 Dec 2017, 06:58

Bonjour,

Je suis entièrement novice au script et à AHK mais après avoir passé une journée entière sur google je n'arrive pas a trouver mon bonheur

J'ai le même soucis que cette personne : https://autohotkey.com/board/topic/7183 ... ackground/

Pour résumer, je cherche à faire un script qui envoie des touches clavier dans une application seulement en background, opur que je puisse utiliser mon ordinateur normalement. J'ai une macro clavier corsair mais si je la lance, je ne peux plus rien faire d'autre.

Dans le post en haut quelqu'un a suggéré un script mais je n'y comprends pas grand chose ; ou trouver l'id de l'application, etc...

Si quelqu'un pourrait m'aider je lui en serai éternellement reconnaissant :D
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 09:40

ControlSend
Ca c’est définitivement ce qu’on a besoin ici.
Mais tout d’abord, c’est quoi le non de l’application en arrière-plan?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Blyat

Re: Script pour application en background

14 Dec 2017, 10:20

La nom de l'application serai archeage sur ce task maanger, mais qu'une seule fenetre/client, pas les deux

https://gyazo.com/8a48c3835c9d160884c3e867c9c351ff

Est-ce possible ? Merci de votre réponse
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 11:12

C'est un jeu? :0

quelque chose comme ca?

Code: Select all

ControlSend, , {Enter}, ahk_exe ArcheAge.exe
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Blyat

Re: Script pour application en background

14 Dec 2017, 11:33

Oui

Comment marche cette commande, est-ce qu'elle affecte du coup tout les clients ? Si elle affecte tout les clients d'une machine, cela me va aussi

Vu que je ne sais pas écrire en script, comment transcrire une loop infinie de :


clavier layout azerty

Press "ALT"
wait 90ms
Press "é" (ou 2)
wait 160ms
Release "é" (ou 2)
wait 40ms
Release "ALT"
wait 1000ms
HOLD "&" (ou 1) pendant 15500ms
Release "&"
wait 1000ms
Press "F"
wait 170ms
Release "F"
wait 100ms
Press ' (apostrophe, ou 4)
wait 200ms
Release ' (apostrophe ou 4)
wait 3500ms
Press "S"
wait 10ms
Release "S"


répéter à l'infini


Merci beaucoup, je ne sais pas écrire pour AHK ou en aucun langage :s
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 14:57

Remplace "wait 2000ms" par Sleep, 2000
"hold R" par ControlSend, , {R down}, ahk_exe ArcheAge.exe
"release R" par ControlSend, , {R up}, ahk_exe ArcheAge.exe
"press S" par ControlSend, , S, ahk_exe ArcheAge.exe
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Blyat

Re: Script pour application en background

14 Dec 2017, 15:15

Code: Select all

ControlSend, , {Alt down}, ahk_exe ArcheAge.exe
Sleep, 90
ControlSend, , {2 down}, ahk_exe ArcheAge.exe
Sleep, 160
ControlSend, , {2 up}, ahk_exe ArcheAge.exe
Sleep, 40
ControlSend, , {Alt up}, ahk_exe ArcheAge.exe
Sleep, 1000
ControlSend, , {1 down}, ahk_exe ArcheAge.exe
Sleep 15500
ControlSend, , {1 up}, ahk_exe ArcheAge.exe
Sleep 1000
ControlSend, , {F down}, ahk_exe ArcheAge.exe
Sleep, 170
ControlSend, , {F up}, ahk_exe ArcheAge.exe
Sleep 100
ControlSend, , {4 down}, ahk_exe ArcheAge.exe
Sleep 200
ControlSend, , {4 up}, ahk_exe ArcheAge.exe
Sleep 3500
ControlSend, , {S down}, ahk_exe ArcheAge.exe
Sleep 10
ControlSend, , {S up}, ahk_exe ArcheAge.exe

Est-ce que cela semble correct ? Comment le faire tourner en boucle a l'infini ? S'appliquera-t-il a tout les clients ou seulement a un seul ? (Je ne peux pas tester aujourd'hui)

Merci bcp de ton aide
Blyat

Re: Script pour application en background

14 Dec 2017, 15:40

Encore une chose, est-il possible d'utiliser le PID de l'application pour cibler quelle fenêtre recevra la commande ? Et ainsa dédoubler le scirpt a plusieurs clients désirés ? par exemple :

Code: Select all

ControlSend, , {2 down}, ahk_exe ArcheAge.exe//pid-x1
ControlSend, , {2 down}, ahk_exe ArcheAge.exe//pid-x2
Sleep, 160
ControlSend, , {2 up}, ahk_exe ArcheAge.exe//pid-x1
ControlSend, , {2 up}, ahk_exe ArcheAge.exe//pid-x2
Sleep, 40
etc... ?
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 16:02

Des boucles ce fais comme-ci

Code: Select all

Loop 6 {
controlsend,, k, ahk_exe ArchAge.exe
}
ca c 6 fois, mets pas de chiffre pour infini
mais je recommende de mettre un hotkey d'urgence pour arreter le script nimporte quand
Esc::ExitApp
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Guest

Re: Script pour application en background

14 Dec 2017, 16:17

Peux-tu me montrer comment écrire le control send pour le PID d'une application spécifique ? Comme je l'ai formulé plus haut
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 18:05

Tu dois déterminer le pid.... mais disons que tu le sais...
controlsend, , K, ahk_pid 173728
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Guest

Re: Script pour application en background

14 Dec 2017, 18:13

Oui je le sais, merci beaucoup de ton aide je vais voir si j'arrive a faire marcher le bazar je te tiens au courant , Merci énormément !
Guest

Re: Script pour application en background

14 Dec 2017, 19:58

Hmm rien ne se passe ,même en mode fenêtré/DX9

Code: Select all

#NoEnv

F10::ExitApp
Loop {
ControlSend, , {Alt down}, ahk_pid 12912 ArcheAge.exe
Sleep, 90
ControlSend, , {2 down}, ahk_pid 12912 ArcheAge.exe
Sleep, 160
ControlSend, , {2 up}, ahk_pid 12912 ArcheAge.exe
Sleep, 40
ControlSend, , {Alt up}, ahk_pid 12912 ArcheAge.exe
Sleep, 1000
ControlSend, , {1 down}, ahk_pid 12912 ArcheAge.exe
Sleep 15500
ControlSend, , {1 up}, ahk_pid 12912 ArcheAge.exe
Sleep 1000
ControlSend, , {F down}, ahk_pid 12912 ArcheAge.exe
Sleep, 170
ControlSend, , {F up}, ahk_pid 12912 ArcheAge.exe
Sleep 100
ControlSend, , {4 down}, ahk_pid 12912 ArcheAge.exe
Sleep 200
ControlSend, , {4 up}, ahk_pid 12912 ArcheAge.exe
Sleep 3500
ControlSend, , {S down}, ahk_pid 12912 ArcheAge.exe
Sleep 10
ControlSend, , {S up}, ahk_pid 12912 ArcheAge.exe
}
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

14 Dec 2017, 21:55

Essaye avec ca?
SendMode InputThenPlay
defois les jeux sont tenaces :/
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Script pour application en background

14 Dec 2017, 22:18

Ton loop n'est jamais exécuté dans la mesure où:
After the script has been loaded, it begins executing at the top line, continuing until a Return, Exit, hotkey/hotstring label, or the physical end of the script is encountered (whichever comes first).
source: The top of the script (the Auto-excecute section) [je souligne]

Par ailleurs, es-tu certain de la valeur du process ID? Quoi qu'il en soit, tu peux retrouver cette valeur programmatically avec WinGet (cmd PID):

Code: Select all

WinGet, PID, PID, ahk_exe ArcheAge.exe
AHKPID := "ahk_pid " . PID
MsgBox % AHKPID

param := AHKPID . A_Space .  "ahk_exe ArcheAge.exe"

ControlSend, , {ALt Down}, % param
Sleep, 160
ControlSend, , {ALt Up}, % param
; ...
my scripts
Guest

Re: Script pour application en background

14 Dec 2017, 22:28

Toujours, rien, cependant je n'ai pas très bien compris ton message, qu'est-ce que cela veut dire? Comment écrire le top of the line pour que cela marche ?

Je suis plutôt sur pour le PID , voir screenshot ici : https://gyazo.com/5ed5737d784099b67e59d25f8081893b
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Script pour application en background

15 Dec 2017, 09:27

SI t’as le pid, t’as pas besoin d’avoir le nom du processus
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Script pour application en background

15 Dec 2017, 10:56

Hmmm ça ne donne toujours rien :(
Blyat
Posts: 24
Joined: 14 Dec 2017, 22:55

Re: Script pour application en background

15 Dec 2017, 13:18

Code: Select all

#NoEnv
SendMode InputThenPlay


ControlSend, , {Alt down}, ahk_pid 8484
Sleep, 90
ControlSend, , {2 down}, ahk_pid 8484
Sleep, 160
ControlSend, , {2 up}, ahk_pid 8484
Sleep, 40
ControlSend, , {Alt up}, ahk_pid 8484
Sleep, 1000
ControlSend, , {1 down}, ahk_pid 8484
Sleep 15500
ControlSend, , {1 up}, ahk_pid 8484
Sleep 1000
ControlSend, , {F down}, ahk_pid 8484
Sleep, 170
ControlSend, , {F up}, ahk_pid 8484
Sleep 100
ControlSend, , {4 down}, ahk_pid 8484
Sleep 200
ControlSend, , {4 up}, ahk_pid 8484
Sleep 3500
ControlSend, , {S down}, ahk_pid 8484
Sleep 10
ControlSend, , {S up}, ahk_pid 8484
J'ai run ça sans la loop pour voir simplement si ça passe mais rien ne se passe

Return to “J'ai besoin d'aide”

Who is online

Users browsing this forum: No registered users and 23 guests