Jump to content
Sign in to follow this  
Tekkion

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

Share this post


Link to post
Share on other sites

I think this is connected to the send im using before. After I put a sleep right before the send with the path string it seems to be working.

Edited by Tekkion

Share this post


Link to post
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

Share this post


Link to post
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?


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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

also the strange thing is im trying this script on 4 different vms and this problem is only occuring on my win7 32bit machine :/

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • By ThePoro
      I have this code 
      It gets variable input from GUI to run a loop and write to a text file then copy it to the clipboard
      But the thing is code runs normally with $px and $py <100 or both > 100 or with $px <10 and $py>100 but It's wrong with 10<$px <100 and $py >100
      Can anyone tell me why?
      Func clone() Local $px = GUICtrlRead($input1) Local $py = GUICtrlRead($input2) Local $temp = "C:\temp.csv" FileDelete($temp) While $px <= $py Local $name = "P"&$px FileWrite($temp, " & $name & ""& @CRLF) $px+= 1 WEnd $a=FileRead($temp) ClipPut($a) MsgBox($MB_ICONINFORMATION,"","Copied to Clipboard") EndFunc  
    • By Htps
      1. How do I make a multiple minimized windows at once believe I am holding down a key for like 5 seconds?
      I know I can send minimized windows a key press with ControlSend.
      What hat would be the way to simulate a 'humanly' held down key to a few minimized windows? 
       
      2. How come: if I compare a handle's hexa value and the actual handler, I get false
      For example: when the Notepad's handler value is 0x00000000000CFFFF, I always get the message box.
       
      if(NOT(0x00000000000C0664 == WinGetHandle("Untitled - Notepad"))) Then MsgBox(0,"swi","0x00000000000CFFFF" & @CRLF & "lmao" & @CRLF & WinGetHandle("Untitled - Notepad")) EndIf  
      Why does that happen? also I can't use hexadecimal value as a handler when I use the ControlSend function.
    • By SkysLastChance
      I must be missing something. I have had this problem multiple times. Why does F6 key not send 6 times?  
      Not working 
      ControlSend("[CLASS:#32770]", "", "", ("{F6 6}")) Working
      ControlSend("[CLASS:#32770]", "", "", ("{F6}")) ControlSend("[CLASS:#32770]", "", "", ("{F6}")) ControlSend("[CLASS:#32770]", "", "", ("{F6}")) ControlSend("[CLASS:#32770]", "", "", ("{F6}")) ControlSend("[CLASS:#32770]", "", "", ("{F6}")) ControlSend("[CLASS:#32770]", "", "", ("{F6}"))  
    • By faustf
      hi guys
      i have a script  like this,  in windows 7 work perfect , in windows 10 not  work  , some one can explain me  why ??'
      #include <Array.au3> #include <MsgBoxConstants.au3> Global $aGPathFoto= FileReadToArray (@ScriptDir & "\TEMP\PathFoto.txt") Local $ctrl = 0 While 1 Local $hWnd = WinWait("[CLASS:#32770]", "", 10) If WinExists("[CLASS:#32770]") Then If $ctrl < 2 Then ControlSend($hWnd, "Choose File to Upload", "[CLASS:Edit; INSTANCE:1]", $aGPathFoto[0]&"{Enter}") Exit $ctrl += 1 Else ExitLoop EndIf EndIf WEnd $aGpathfoto = C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
    • By Skeletor
      Hi Guys,
      Is it possible to get a variable on your For..Next loop? 
       
      Local $Lines1 = _FileCountLines(C:\temp\test.txt) Local $linesToCount2 = $Lines1 + 2 $var = Number($linesToCount2) For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = $var To $count Next ;Code does stuff here Next Somehow my code doesn't work even though I thought I could convert the variable to a Integer / Number.
      This code I posted above does not move to the next value.
      But the code below does... why is that?
      For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = 2 To $count Next ;Code does stuff here Next  
      Why is the For loop resetting itself?
      Is it because the program does not cache the variable and needs to keep on acquiring this variable each time?
      If so , how would you make this variable static?

       
×
×
  • Create New...