Bonjour
Ybasthis DofusForm est une API en AutoIt permettant d'avoir des infos sur les processus DOFUS.
Cette API est fournit sous licence EPL:
http://fr.wikipedia.org/wiki/Eclipse_Public_License
http://www.eclipse.org/org/documents/epl-v10.php
Fonctionnalités de l'API:
Client Dofus:
[tab][/tab]-bDofusProcessExist
[tab][/tab]Description: Retourne True si un processus Dofus est en cours de fonctionnement
[tab][/tab]-bIsDofusClientName
[tab][/tab]Description: Retourne True si le nom correspond à une instance de Dofus
[tab][/tab]-bCloseDofusClient
[tab][/tab]Description: Ferme le(s) processus(s) Dofus sélectionné ou tous.
[tab][/tab]-aiListDofusClientPID
[tab][/tab]Description: Retourne un tableau contenant les PIDs de chaques client Dofus
[tab][/tab]-awhndListHWndDofusClient
[tab][/tab]Description : Retourne un tableau contenant les HWnd de chaques client Dofus
[tab][/tab]-asListNamesWindowDofusClient
[tab][/tab]Description : Retourne un tableau contenant les noms de chaques client Dofus
[tab][/tab]-bIsDofusClientPID
[tab][/tab]Description : Retourne True si le PID appartient à une instance de Dofus
UpLauncher Dofus:
[tab][/tab]-bUpLauncherExist
[tab][/tab]Description: Retourne True si un processus UpLauncher est en cours de fonctionnement
[tab][/tab]-bCloseUpLauncher
[tab][/tab]Description : Ferme le processus UP Launcher Dofus
Pour utiliser une fonction il faut inclure l'API puis appeler la fonction comme suit:
DofusForm("nomDeLaFonction", "paramètre")
Le code source est commenté, de type camelCase et chaques variables & fonctions suit une convention de typage:
Int-> i
String -> s
Hex-> h
Bool-> b
Unknow-> u
Void-> v
Array-> a + type of Array
Exemple d'utilisation
Code pour modifier la taille de chaque fenêtre Dofus et les déplacer en haut à gauche.
If DofusForm("bDofusProcessExist") Then ; Si au moins un processus Dofus existe
Local $ahwndDofusWindows = DofusForm("awhndListHWndDofusClient") ; HWnd nécessaire au déplacement d'une fenêtre avec WinMove()
For $i = 0 to $ahwndDofusWindows[0] Step 1 ; De 1 au nombre de HWnd, incrémentation de 1
WinMove($ahwndDofusWindows[$i], "", 0, 0, 250 ,250) ; Déplacement + Modification de la taille de la fenêtre ciblé avec le HWnd
Next
EndIf
Code source
Cliquez pour révéler
Cliquez pour masquer
#include <Process.au3>
#include <Array.au3>
;Function for getting HWND from PID
;Is not the property of Ybasthis
Func _GetHwndFromPID($PID)
Local $hWnd = 0
Local $winlist = WinList()
Do
For $i = 1 To $winlist[0][0] Step 1
If $winlist[$i][0] <> "" Then
$iPID2 = WinGetProcess($winlist[$i][1])
If $iPID2 = $PID Then
$hWnd = $winlist[$i][1]
ExitLoop
EndIf
EndIf
Next
Until $hWnd <> 0
Return $hWnd
EndFunc ;==>_GetHwndFromPID
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Fonction: DofusForm ;;;
;;;; Utilité: Package DofusForm ;;;
;;;; Licence: EPL ;;;
;;;; Paramètre: ;;;
;;;; $sFunction: Le nom de la fonction du package à utiliser ;;;
;;;; $uArg: Argument utilisé par les méthodes pour recevoir des valeurs. Se référer à la doc de chaque fonction ; Défaut False ;;;
;;;; Crédit: ;;;
;;;; Ybasthis ;;;
;;;; Version: 0.0.1 ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Fonction:
; Client Dofus
; bDofusProcessExist
; Description: Retourne True si un processus Dofus est en cours de fonctionnement
;
; bIsDofusClientName
; Description: Retourne True si le nom correspond à une instance de Dofus
; @error
; -1 : $uArg n'est pas de type string
; -2 : Aucun processus Dofus en cours de fonctionnement
; -3 : Aucune fenêtre avec le nom $sNameOfDofusClientToTest n'existe
; -4 : Le PID n'apartient pas à une fenêtre Dofus
;
; bCloseDofusClient
; Description: Ferme le(s) processus(s) Dofus sélectionné ou tous.
; Paramètre:
; $uArg:
; *indéfini:Ferme toutes les instances de Dofus; Par défaut
; *string:Le nom du processus dofus à fermer
; @error
; -1 : Aucun processus Dofus en cours de fonctionnement
; -2 : Erreur lors de la tentative de fermeture de l'instance
; -3 : $uArg n'est pas de type string
; -4 : $uArg n'est pas le nom d'une instance de Dofus
;
; aiListDofusClientPID
; Description: Retourne un tableau contenant les PIDs de chaques client Dofus
; Valeur de retour:
; case 0 : Le nombre de client Dofus
; False : Il n'y à pas de client Dofus en cours de fonctionnement
;
; awhndListHWndDofusClient
; Description: Retourne un tableau contenant les HWnd de chaques client Dofus
; Valeur de retour:
; case 0 : Le nombre de client Dofus
; False : Il n'y à pas de client Dofus en cours de fonctionnement
;
; bIsDofusClientPID
; Description : Retourne True si le PID appartient à une instance de Dofus
; Paramètre:
; $uArg:
; int: Le PID à tester
; @error
; -1 : $uArg n'est pas définit
; -2 : $uArg n'est pas de type int
; -3 : Aucune instance Dofus n'est en cours de fonctionnement
; -4 : Le PID ne correspond pas à une instance de Dofus
;
; asListNamesWindowDofusClient
; Description : Retourne un tableau contenant les noms de chaques client Dofus
; Valeur de retour:
; case 0 : Le nombre de client Dofus
; False : Il n'y à pas de client Dofus en cours de fonctionnement
;
; UpLauncher Dofus
; bUpLauncherExist
; Description: Retourne True si un processus UpLauncher est en cours de fonctionnement
;
; iUpLauncherPID
; Description: Retourne le PID de l'Up Launcher, False si l'UpLauncher n'est pas en cours de fonctionnement
;
; bCloseUpLauncher
; Description : Ferme le processus UP Launcher Dofus
; @error
; 1 : OpenProcess failed
; 2 : AdjustTokenPrivileges Failed
; 3 : TerminateProcess Failed
; 4 : Cannot verify if process exists
; 5 : Aucun processus UpLauncher en cours de fonctionnement
;
;;;;Fonction-fin
Func DofusForm($sFunction, $uArg = False)
Local $sNameOfDofusProcess = "Dofus.exe"
Local $sNameOfDofusProcessStartedWithUpLauncher = "DofusMod.exe"
Local $sNameOfDofusUpLauncherProcess = "UpLauncher.exe"
Switch $sFunction
;::::::::::::::::::::::
;:: Dofus Client
;::::::::::::::::::::::
Case "bDofusProcessExist" ; Valide
If Not ProcessExists($sNameOfDofusProcess) And Not ProcessExists($sNameOfDofusProcessStartedWithUpLauncher) Then ; Si aucun processus Dofus n'est en cours de fonctionnement
Return False
EndIf
Return True
;------------------
;------------------
Case "bIsDofusClientName" ; Valide
If Not IsString($uArg) Then ; Si $uArg n'est pas de type string
SetError(-1)
Return False
EndIf
If Not DofusForm("bDofusProcessExist") Then ; Si aucun processus Dofus n'est en cours de fonctionnement
SetError(-2)
Return False
EndIf
Local $sNameOfDofusClientToTest = $uArg
If Not WinExists($sNameOfDofusClientToTest) Then ; Si aucune fenêtre avec le nom $sNameOfDofusClientToTest n'existe
SetError(-3)
Return False
EndIf
Local $iPIDOfDofusClientToTest = WinGetProcess($sNameOfDofusClientToTest)
If DofusForm("bIsDofusClientPID", $iPIDOfDofusClientToTest) Then ; Si le PID correspond à un PID d'une instance de Dofus
Return True
Else
SetError(-4)
Return False
EndIf
;------------------
;------------------
Case "bCloseDofusClient"
Local $bCloseAllDofusClient
If Not DofusForm("bDofusProcessExist") Then ; Si aucun processus Dofus existe
SetError(-1)
Return False
EndIf
If Not $uArg Then ; Si Action: Fermer toutes les instances
ProcessClose($sNameOfDofusProcess)
ProcessClose($sNameOfDofusProcessStartedWithUpLauncher)
If Not DofusForm("bDofusProcessExist") Then ; Si aucun processus Dofus existe
Return True
Else
SetError(-2)
Return False
EndIf
Else ; Si Action: Fermer une instance particulière
If Not IsString($uArg) Then ; Si $uArg n'est pas de type string
SetError(-3)
Return False
EndIf
Local $sNameOfDofusClientToClose = $uArg
If Not DofusForm("bIsDofusClientName", $sNameOfDofusClientToClose) Then ; Si $uArg n'est pas le nom d'une instance de Dofus
SetError(-4)
Return False
EndIf
Local $iPIDOfDofusProcessToClose = WinGetProcess($sNameOfDofusClientToClose)
ProcessClose($iPIDOfDofusProcessToClose)
EndIf
;------------------
;------------------
Case "aiListDofusClientPID" ; Valide
If DofusForm("bDofusProcessExist") == False Then ; Si aucun processus Dofus n'est en cours de fonctionnement
Return False
EndIf
Local $sPIDProcess ; Contient les PIDs de chaques client séparé par une virgule ,
;
; Liste les PIDs appartenant à $sNameOfDofusProcess
;
Local $aProcessList = ProcessList($sNameOfDofusProcess)
If IsArray($aProcessList) And $aProcessList[0][0] Then ; Si il existe au moins une instance de type $sNameOfDofusProcess
Local $iNbOfProcess = $aProcessList[0][0]
$sPIDProcess = $aProcessList[1][1]
If $sPIDProcess > 1 Then
For $i = 2 To $iNbOfProcess Step 1
$sPIDProcess &= "," & $aProcessList[$i][1]
Next
EndIf
EndIf
;
; Liste les PIDs appartenant à $sNameOfDofusProcessStartedWithUpLauncher
;
$aProcessList = ProcessList($sNameOfDofusProcessStartedWithUpLauncher)
If IsArray($aProcessList) And $aProcessList[0][0] Then ; Si il exite au moins une instance de type $sNameOfDofusProcessStartedWithUpLauncher
Local $iNbOfProcess = $aProcessList[0][0]
For $i = 1 To $iNbOfProcess Step 1
If Not $sPIDProcess Then ; Si il n'y a pas encore de PID d'écrit
$sPIDProcess = $aProcessList[$i][1]
Else
$sPIDProcess &= "," & $aProcessList[$i][1]
EndIf
Next
EndIf
Return StringSplit( $sPIDProcess, ",")
;------------------
;------------------
Case "awhndListHWndDofusClient" ; Valide
Local $aiListDofusClientPID = DofusForm("aiListDofusClientPID")
If Not $aiListDofusClientPID[0] Then ; Si aucune fenêtre Dofus n'est présente
Return False
EndIf
Local $iNbOfWindow = $aiListDofusClientPID[0]
Local $sHwndWindow = _GetHwndFromPID($aiListDofusClientPID[1])
If $iNbOfWindow > 1 Then
For $i = 2 To $iNbOfWindow Step 1
$sHwndWindow &= "," & _GetHwndFromPID($aiListDofusClientPID[$i])
Next
EndIf
Local $ahwndWindow = StringSplit($sHwndWindow, ",")
For $i = 1 To $ahwndWindow[0] Step 1
$ahwndWindow[$i] = HWnd($ahwndWindow[$i])
Next
Return $ahwndWindow
;------------------
;------------------
Case "asListNamesWindowDofusClient" ; Valide
Local $aiListDofusClientHWnd = DofusForm("awhndListHWndDofusClient")
If Not $aiListDofusClientHWnd[0] Then ; Si aucune fenêtre Dofus n'est présente
Return False
EndIf
Local $sNameWindow = WinGetTitle($aiListDofusClientHWnd[1])
If $aiListDofusClientHWnd[0] > 1 Then
For $i = 2 To $aiListDofusClientHWnd[0] Step 1
$sNameWindow &= "," & WinGetTitle($aiListDofusClientHWnd[$i])
Next
EndIf
Return StringSplit($sNameWindow, ",")
;------------------
;------------------
Case "bIsDofusClientPID" ; Valide
If Not $uArg Then ; Si $uArg n'est pas définit
SetError(-1)
Return False
ElseIf Not IsInt($uArg) Then ; Ou Si $uArg n'est pas de type int
SetError(-2) ;
Return False
EndIf
If Not DofusForm("bDofusProcessExist") Then ; Si aucune instance Dofus n'est en cours de fonctionnement
SetError(-3)
Return False
EndIf
Local $iPIDToTest = $uArg
Local $aiListDofusClientPID = DofusForm("aiListDofusClientPID") ; Récupération de la liste des PIDs appartenant à une instance de Dofus
For $i = 1 To $aiListDofusClientPID[0] Step 1 ; De 1 aux nombres des PID des instances Dofus
If $iPIDToTest == $aiListDofusClientPID[$i] Then ; Si le PID correspond à une instance Dofus
Return True
EndIf
Next
SetError(-4) ; Le PID ne correspond pas à une instance de Dofus
Return False
;::::::::::::::::::::::
;:: Dofus UP Launcher
;::::::::::::::::::::::
Case "bUpLauncherExist"
If ProcessExists($sNameOfDofusUpLauncherProcess) > 0 Then
Return True
Else
Return False
EndIf
;------------------
;------------------
Case "iUpLauncherPID"
If Not DofusForm("bUpLauncherExist") Then
Return False
EndIf
Local $iUpLauncherPID = ProcessList($sNameOfDofusUpLauncherProcess)
Return $iUpLauncherPID[1][1]
;------------------
;------------------
Case "bCloseUpLauncher" ; Valide
If DofusForm("bUpLauncherExist") Then ; Si un processus UpLauncher est en cours de fonctionnement
If ProcessClose($sNameOfDofusUpLauncherProcess) == 1 Then
Return True
Else
SetError(@error)
Return False
EndIf
Else
SetError(-1)
Return False
EndIf
EndSwitch
MsgBox(1, "Erreur", "Si vous voyez ce message c'est que vous appellez une fonction qui n'existe pas!")
MsgBox(1, "Error", "If you see this message is that you call a function that does not exist.")
EndFunc
ChangeLog
Cliquez pour révéler
Cliquez pour masquer
version 0.0.1
[tab]-Ajout de la fonction: awhndListHWndDofusClient[/tab]
[tab]-Ajout de la fonction: iUpLauncherPID[/tab]
[tab]-Corrections de nombreux bogues[/tab]
[tab]-Optimisation de la stabilité[/tab]
Pour toutes demandes d'aides ou bogue veuillez me contacter par MP sur ce forum.
Si vous avez des idées d'améliorations, des correctifs et autres je suis preneur.
Cordialement