Jump to content

Controlsend character switching problem


Recommended Posts

Hi there,

the title says it all. My problem here is: im starting the autoit compiled .exes from a cmd window. So im also passing needed parameters there. These parameters are in this case paths to files, and sometimes some slashes within these paths got switched with the german "ß" character which lies on the same key as the backslash. After checking the cmd window the .exe call with the parameter includes the correct path. For some odd reason its only happening sometimes and also only in the license_A_Prof_Sec function. So any hints what could cause this problem?

Here is my code:

#RequireAdmin
run("C:\Program Files (x86)\Avira\AntiVir Desktop\avcenter.exe")

sleep(2000)

$aWins=WinList("Avira")

For $i = 1 To $aWins[0][0]
   Switch $aWins[$i][0]
      case "Avira Professional Security"
         license_A_Prof_Sec($aWins[$i][1])
      Case "Avira Free Antivirus"
         license_A_Free_AV($aWins[$i][1])
   EndSwitch
Next



func license_A_Free_AV($handle)

   WinActivate($handle)
   sleep(3000)
   Send("!H")
   Send("m")
   $whnd=winwait("Avira Free Antivirus","Lizenz",60)
   ControlClick($whnd,"","[CLASS:Static; INSTANCE:4]")
   $whnd=winwait("Öffnen")
   ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$CMDLine[1])
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   $whnd=WinWait("Avira Free Antivirus","Lizenz ist bereits vorhanden",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   $whnd=WinWait("Avira Free Antivirus","Die Lizenzdatei wurde aktualisiert",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   $whnd=WinWait("Avira Free Antivirus","Lizenzinformationen",60)
   sleep(500)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:8]")
   winclose("Avira Free Antivirus")

EndFunc

func license_A_Prof_Sec($handle)

   WinActivate($handle)
   sleep(3000)
   Send("!H")
   Send("l")
   $whnd=winwait("Öffnen","",60)
   ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$CMDLine[1])
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   $whnd=WinWait("Avira Professional Security","Die Lizenzdatei wurde aktualisiert",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   winclose("Avira Professional Security")

EndFunc
Edited by Tekkion
Link to comment
Share on other sites

still having the problem....

problem occuring in line 62.

here's my new code:

#RequireAdmin
sleep(2000)
global $return=4
$aWins=WinList("Avira")

For $i = 1 To $aWins[0][0]
   Switch $aWins[$i][0]
      case "Avira Professional Security"
         license_A_Prof_Sec($aWins[$i][1])
      Case "Avira Free Antivirus"
         license_A_Free_AV($aWins[$i][1])
   EndSwitch
Next



func license_A_Free_AV($handle)

   WinActivate($handle)
   sleep(3000)
   Send("!H")
   Send("m")
   $whnd=winwait("Avira Free Antivirus","Lizenz",60)
   ControlClick($whnd,"","[CLASS:Static; INSTANCE:4]")
   $whnd=winwait("Öffnen","",60)
   $path = StringReplace($CMDLine[1],"ß","\")
   sleep(3000)
   ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$path)
   sleep(3000)
   $whnd=winwait("Öffnen","",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   sleep(500)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:2]")
   $whnd=WinWait("Avira Free Antivirus","Lizenz ist bereits vorhanden",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   $whnd=WinWait("Avira Free Antivirus","wird nicht installiert",60)
   if $whnd=0 then
      $whnd=WinWait("Avira Free Antivirus","Die Lizenzdatei wurde aktualisiert",60)
      if $whnd <> 0 Then
         $return=0
      endif
      ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
      $whnd=WinWait("Avira Free Antivirus","Lizenzinformationen",60)
      sleep(500)
      ControlClick($whnd,"","[CLASS:Button; INSTANCE:8]")
      winclose("Avira Free Antivirus")
   Else
      $return=3
   endif

EndFunc

func license_A_Prof_Sec($handle)

   WinActivate($handle)
   sleep(3000)
   Send("!H")
   Send("l")
   $whnd=winwait("Öffnen","",60)
   $path = StringReplace($CMDLine[1],"ß","\")
   sleep(3000)
   ControlSend($whnd,"","[CLASS:Edit; INSTANCE:1]",$path)
   sleep(3000)
   $whnd=winwait("Öffnen","",60)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
   sleep(500)
   ControlClick($whnd,"","[CLASS:Button; INSTANCE:2]")
   $whnd=WinWait("Avira Professional Security","wird nicht kopiert",60)
   if $whnd=0 then
      $whnd=WinWait("Avira Professional Security","Die Lizenzdatei wurde aktualisiert",60)
      if $whnd <> 0 Then
         $return=0
      endif
      ControlClick($whnd,"","[CLASS:Button; INSTANCE:1]")
      winclose("Avira Professional Security")
   Else
      $return=3
   EndIf
EndFunc

exit($return)
Edited by Tekkion
Link to comment
Share on other sites

still having the problem....

 

problem occuring in line 62.

 

here's my new code:

. . .

   $path = StringReplace($CMDLine[1],"ß","\")
  
. . .

 

that line should replace the letter "ß" with the backslash ""

What happens instead of wrong for you?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Its working well but I don't think that thats the problem, cause the path is correctly passed to the autoit file I checked it even before I use the controlsend command and it shows me the correct path. So I think thats some kind of bug that the ALT key is still pressed from the send before and so its negating the backslashes im trying to send.

The question is now is there anyway to control if the ALT key is still pressed and if so reset him.

What I will try now is to send a the path to a "dummy control" to negate this ALT key.

edit: didnt help

Edited by Tekkion
Link to comment
Share on other sites

.....

The question is now is there anyway to control if the ALT key is still pressed and if so reset him.

.....

 

Send("{ALTDOWN}{ALTUP}")

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...