Sign in to follow this  
Followers 0
Tekkion

Controlsend character switching problem

8 posts in this topic

#1 ·  Posted (edited)

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



#2 ·  Posted (edited)

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

#3 ·  Posted (edited)

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

#5 ·  Posted (edited)

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

.....

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

.....

 

Send("{ALTDOWN}{ALTUP}")


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

ill try this thx

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  
Followers 0

  • Similar Content

    • lganta
      By lganta
      Hello!
      I created some scripts for a simple farming bot a few years ago and they rely on ControlSend.
      A year ago I quit that game and then installed Windows 10 (was using windows 7).
      Recently I installed that game and tried running them again and they seem to work (I have some messages displayed on the screen with the state of the bot ), except for the ControlSend part (which obviously is crucial).
      I started debugging the scripts so I created a basic script that makes use of Send. I tested this with Notepad in focus and works just fine and then with my game window in focus and it didn't work (it's supposed to write that text in an input box from the game).
      #include <MsgBoxConstants.au3> Sleep(3000); Send("some text"); MsgBox($MB_OK, "Notification", "Control was sent!");  
      Is there a way for the creators of the game to create some kind of security system against this? Or something happens because I updated to Windows 10?
      Is there something I'm missing?
      Thank you!
    • Atoxis
      By Atoxis
      Howdy, this is my first post, massive fan of autoit. 
      I've searched and tried and I would just like people who are better at this than me to let me know if this is even a thing.

      I'd like to perform just a variable. For example, it would be. *see inserted code*
      So what i'm wanting is, create the constant $test, and that variable would be what is followed after the = . Then perform the _FileCreate. Then perform the variable.  Logically or in my head rather.. That variable is declared and is equal to what it is set to above, therefore just placing the variable plainly in the script, it should be equal to what it was declared as.  So what am I doing wrong, and or how can I have autoit just perform the variable.  

       
      #include <File.au3> Const $test = FileWriteLine(@DesktopDir & "\Log.txt", @CRLF ) _FileCreate(@DesktopDir & "\Log.txt") $test  
    • ur
      By ur
      I have a script , during compilation and test execution, it worked perfectly but sometimes I am getting error as "Variable used without being declared."
       
      I understood somewhere in the branching logic this is happening.
       
      But not able to find it exactly.
       
      As I am using multiple include statements.the line number is also not giving accurately.
       

       
      Can anyone suggest what is the approach to resolve this?
    • nacerbaaziz
      By nacerbaaziz
      Hi all
      I want a way to get the last key pressed.
      I have a program that works with keyboard shortcuts and I want to  give the permission for the user to edit shortcut keys depending on what suits him
      i  want to make read-only edit box and the program writes the latest shortcut key pressed
      Please help me,
      greetings to all
      And thanks in advance
    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf