SagePourpre Posted July 13, 2008 Posted July 13, 2008 Hi. Does someone knows a way to solve this ? Func wa($snd = "") $snd = StringSplit($snd, "|") $t = $snd[1] $tt = $snd[2] For $i = 4 To $snd[0] $cs = "cs" if $snd[$i] = $cs Then ElseIf $snd[$i] = $cs Then ElseIf $snd[$i-1] = $cs Then ElseIf $snd[$i-2] = $cs Then ElseIf $snd[$i-3] = $cs Then ElseIf $snd[$i-4] = $cs Then EndIf Next EndFunc Like that it's working but how am I supposed to do if, instead of For $i = 4 To $snd[0], i want to put For $i = 3 To $snd[0] I've got the following message . : Array Badly formatted ( because when $i = 3 thent 3 - 4 = -1 ) Got any idea of how to solve this ?
Malkey Posted July 13, 2008 Posted July 13, 2008 Hi. Does someone knows a way to solve this ? Func wa($snd = "") $snd = StringSplit($snd, "|") $t = $snd[1] $tt = $snd[2] For $i = 4 To $snd[0] $cs = "cs" if $snd[$i] = $cs Then ElseIf $snd[$i] = $cs Then ElseIf $snd[$i-1] = $cs Then ElseIf $snd[$i-2] = $cs Then ElseIf $snd[$i-3] = $cs Then ElseIf $snd[$i-4] = $cs Then EndIf Next EndFunc Like that it's working but how am I supposed to do if, instead of For $i = 4 To $snd[0], i want to put For $i = 3 To $snd[0] I've got the following message . : Array Badly formatted ( because when $i = 3 thent 3 - 4 = -1 ) Got any idea of how to solve this ?I am not sure what the objective of your script is. I had a play with it. Hope it helps. wa("aa|cd|bb|cc") Func wa($snd = "") Local $cs, $asndIndex = 0 $asnd = StringSplit($snd, "|") ; $cs = "cs" For $i = 1 To UBound($snd) - 1 ; or For $i = 1 To $asnd[0] If $asnd[$i] = $cs Then $asndIndex = $i ; Remember in which $asnd[$asndIndex] "cs" was found. Next If $asndIndex > 0 Then MsgBox(0, "", "cs exist in $snd[" & $asndIndex & "]") Else MsgBox(0, "", '"' & "|cs|" & '"' & " does not exist in " & $snd) EndIf Return EndFunc ;==>wa Change the first line wa("aa|cd|bb|cc") to wa("aa|cs|bb|cc") for a positive result.
SagePourpre Posted July 13, 2008 Author Posted July 13, 2008 I am not sure what the objective of your script is. I had a play with it. Hope it helps. wa("aa|cd|bb|cc") Func wa($snd = "") Local $cs, $asndIndex = 0 $asnd = StringSplit($snd, "|") ; $cs = "cs" For $i = 1 To UBound($snd) - 1 ; or For $i = 1 To $asnd[0] If $asnd[$i] = $cs Then $asndIndex = $i ; Remember in which $asnd[$asndIndex] "cs" was found. Next If $asndIndex > 0 Then MsgBox(0, "", "cs exist in $snd[" & $asndIndex & "]") Else MsgBox(0, "", '"' & "|cs|" & '"' & " does not exist in " & $snd) EndIf Return EndFunc ;==>wa Change the first line wa("aa|cd|bb|cc") to wa("aa|cs|bb|cc") for a positive result. Thank you ... I should have posted all my function for a better look but I resolved the problem ... here is my function #include-once expandcollapse popupFunc wa($snd = "",$sleep = 300) ; FONCTION ; déclaration des variables ... vous pouvez changer aisément les valeurs de ses variables pour les adapter à vos préférences. ;si une valeur des variable est détecté entre deux séparateurs "|" , les prochains paramètres seront ;réservé pour l'exécution de cette fonction. Si rien n'est détecté, la commande send enverra le texte entre les séparateurs. ;Le premier paramètres est toujours réservé pour définir le titre de la fenêtre à activer et le deuxième pour du texte ; présent à l'intérieur de celle-ci ; déclaration des variables ... vous pouvez changer aisément les valeurs de ses variables pour les adapter à vos préférences. $cs ="#" ; ControlID, Send ControlSend $cs2 = "##" ; ControlID, Send1, Send2 ControlSend 2 strings $cs3 = "###" ; ControlID, Send1, Send2, Send3 ControlSend 3 strings $d = "S" ; Sleep delay Ajout d'un délai d'éxécution avant la suite du script $msg = "MSG" ; Titre, Texte Msgbox $dmsg = "DMSG" ; Titre, Texte Msgbox se fermant après 5 secondes $tmsg = "TMSG" ; Titre, Texte, Temps avant fermeture Msgbox fermant après X secondes (définit par le param 3) $cc = "CC" ; ControlID du bouton ControlClick sur le bouton spécifié $ccxy = "CCXY" ; ControlID, X, Y ControlClick sur le bouton spécifié au coordonnées X, Y $ccrxy = "ccrxy" ; ControlID, X, Y ControlClick (bouton droit) sur le bouton spécifié au coordonnées X, Y $mc = "MC" ; X, Y MouseClick au coordonnées X, Y. $mc2 = "MC2" ; X, Y MouseClick (2X) au coordonnées X, Y. $md = "MD" ; Bouton MouseDown ( Right, left ou Middle ) $mu = "MU" ; Bouton MouseUp ( Right, left ou Middle ) $mcr = "MCR" ; X, Y MouseClick ( bouton droit ) au coordonnées X, Y $mm = "MM" ; X, Y MouseMove au coordonnées X,Y $mw = "MW" ; Direction ( up ou Down ), Nb de clics MouseWheel $snd = StringSplit($snd, "|") $t = $snd[1] $tt = $snd[2] WinWait($t,$tt) IF Not WinActive($t, $tt) Then WinActivate($t, $tt) WinWaitActive($t, $tt) For $i = 3 To $snd[0] ; Évite une erreur si $i = 3 pour $i - 4 à la ligne 79 if $i - 4 < 0 Then $n4 = 0 Else $n4 = 4 EndIf ; CONTROL SEND if $snd[$i] = $cs Then ElseIf $snd[$i-1] = $cs Then ElseIf $snd[$i-2] = $cs Then Sleep($sleep) ControlSend($t,$tt,$snd[$i-1],$snd[$i]) ; Control Send 2 string au même ControlID ElseIf $snd[$i] = $cs2 Then ElseIf $snd[$i-1] = $cs2 Then ElseIf $snd[$i-2] = $cs2 Then ElseIf $snd[$i-3] = $cs2 Then Sleep($sleep) ControlSend($t,$tt,$snd[$i-2],$snd[$i-1]) Sleep($sleep) ControlSend($t,$tt,$snd[$i-2],$snd[$i]) ; Control Send 3 string au même control id ElseIf $snd[$i] = $cs3 Then ElseIf $snd[$i-1] = $cs3 Then ElseIf $snd[$i-2] = $cs3 Then ElseIf $snd[$i-3] = $cs3 Then ElseIf $snd[$i-$n4] = $cs3 Then Sleep($sleep) ControlSend($t,$tt,$snd[$i-3],$snd[$i-2]) Sleep($sleep) ControlSend($t,$tt,$snd[$i-3],$snd[$i-1]) Sleep($sleep) ControlSend($t,$tt,$snd[$i-3],$snd[$i]) ; DÉLAI SUPPLÉMENTAIRE ElseIf $snd[$i] = $d Then ElseIf $snd[$i-1] = $d Then Sleep($snd[$i]) ; MESSAGE ElseIf $snd[$i] = $msg Then ElseIf $snd[$i-1] = $msg Then ElseIf $snd[$i-2] = $msg Then Sleep($sleep) MsgBox(0,$snd[$i-1],$snd[$i]) ; Message se fermant après 5 secondes ElseIf $snd[$i] = $dmsg Then ElseIf $snd[$i-1] = $dmsg Then ElseIf $snd[$i-2] = $dmsg Then Sleep($sleep) MsgBox(0,$snd[$i-1],$snd[$i],"5") ; Message se fermant après "X" secondes ElseIf $snd[$i] = $tmsg Then ElseIf $snd[$i-1] = $tmsg Then ElseIf $snd[$i-2] = $tmsg Then ElseIf $snd[$i-3] = $tmsg Then Sleep($sleep) MsgBox(0,$snd[$i-2],$snd[$i-1],$snd[$i]) ; Control Click sur Bouton ElseIf $snd[$i] = $cc Then ElseIf $snd[$i-1] = $cc Then Sleep($sleep) ControlClick($t,$tt,$snd[$i]) ; Control Click sur coordonnées ElseIf $snd[$i] = $ccxy Then ElseIf $snd[$i-1] = $ccxy Then ElseIf $snd[$i-2] = $ccxy Then ElseIf $snd[$i-3] = $ccxy Then Sleep($sleep) ControlClick($t,$tt,$snd[$i-2],"","",$snd[$i-1],$snd[$i]) ; Control Click avec bouton droit sur coordonnées ElseIf $snd[$i] = $ccrxy Then ElseIf $snd[$i-1] = $ccrxy Then ElseIf $snd[$i-2] = $ccrxy Then ElseIf $snd[$i-3] = $ccrxy Then Sleep($sleep) ControlClick($t,$tt,$snd[$i-2],"right","",$snd[$i-1],$snd[$i]) ; Mouse Click ElseIf $snd[$i] = $mc Then ElseIf $snd[$i-1] = $mc Then ElseIf $snd[$i-2] = $mc Then Sleep($sleep) MouseClick("left",$snd[$i-1],$snd[$i]) ; Mouse Click 2 X ElseIf $snd[$i] = $mc2 Then ElseIf $snd[$i-1] = $mc2 Then ElseIf $snd[$i-2] = $mc2 Then Sleep($sleep) MouseClick("left",$snd[$i-1],$snd[$i],2) ; Mouse Down ElseIf $snd[$i] = $md Then ElseIf $snd[$i-1] = $md Then Sleep($sleep) MouseDown($snd[$i]) ; Mouse Up ElseIf $snd[$i] = $md Then ElseIf $snd[$i-1] = $md Then Sleep($sleep) MouseUp($snd[$i]) ; Mouse Click Right ElseIf $snd[$i] = $mcr Then ElseIf $snd[$i-1] = $mcr Then ElseIf $snd[$i-2] = $mcr Then Sleep($sleep) MouseClick("right",$snd[$i-1],$snd[$i]) ; Mouse Move ElseIf $snd[$i] = $mm Then ElseIf $snd[$i-1] = $mm Then ElseIf $snd[$i-2] = $mm Then Sleep($sleep) MouseMove($snd[$i-1],$snd[$i]) ; Mouse Wheel ElseIf $snd[$i] = $mw Then ElseIf $snd[$i-1] = $mw Then ElseIf $snd[$i-2] = $mw Then Sleep($sleep) MouseWheel($snd[$i-1],$snd[$i]) ; SEND Else Sleep($sleep) Send($snd[$i]) EndIf Next EndFunc Func _Opt () Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) EndFunc I resolved my impossible negative array by putting another condition For $i = 3 To $snd[0] if $i - 4 < 0 Then $n4 = 0 Else $n4 = 4 so later, instead of If $snd[$i-4] = $cs Then I've put If $snd[$i-$n4] = $cs Then and my problem was resolved. It's a part of my "easy installation" project. So, I can perform a windows activation and send anything I like through one line of code. If I got 7 windows to install Nero, then my code will be 7 line long (8 if you count the #include myfunction.au3) Ex : Wa("Nero|installation|!N|S|5000|msg|Title|text|S",400) In this line alone, i'm doing WinWait(Nero,installation) IF Not WinActive(Nero, installation) Then WinActivate(Nero,installation) WinWaitActive(Nero,installation) Sleep(400) Send("!N") Sleep(5000) Sleep(400) Msgbox(0,"Title","text")
SagePourpre Posted July 13, 2008 Author Posted July 13, 2008 oops... some problems not resolved but nearly fonctionnal
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now