Jump to content
Sign in to follow this  
Tekkion

Controlsend character switching problem

Recommended Posts

Tekkion

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
Tekkion

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
Tekkion

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
Chimp

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
Tekkion

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
Tekkion

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
Chimp

.....

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
Tekkion

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  

  • Similar Content

    • xiantez
      By xiantez
      This script used to work on an older version of AutoIT. Currently I am running AutoIT v3.3.14.5 and it's failing.
      Func PublicIP() ;Post public facing IP address Local $url = 'https://www.google.com/search?client=opera&q=what+is+my+ip&sourceid=opera&ie=UTF-8&oe=UTF-8' Local $getIPaddress = BinaryToString(InetRead($url)) Local $sStart = 'clamp:2">' Local $sEnd = '</div>' Local $ipaddress = _StringBetween($getIPaddress, $sStart, $sEnd For $i In $ipaddress MsgBox(0, 'External IP', "Your public IP address is " & $i) Next EndFunc ;==>PublicIP The console output shows:
      "C:\Users\user\Documents\AutoIT\Scripts\WSI Tools.au3" (197) : ==> Variable must be of type "Object".: For $i In $ipaddress For $i In $ipaddress^ ERROR ->14:12:16 AutoIt3.exe ended.rc:1 +>14:12:16 AutoIt3Wrapper Finished. >Exit code: 1 Time: 9.811
    • California
      By California
      Hello,
      I wrote a benchmark script to measure variable declarations
      to find out whether you should focus more on static or global variables
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 #ce ---------------------------------------------------------------------------- #Region Pre-Setting Local $iTally1 = 0 Local $iTally2 = 0 Local $iTally3 = 0 Local $iTally4 = 0 Local $iTally5 = 0 Local $iTally6 = 0 Local $iTally7 = 0 Global $GLOBALCONST1 = 1 Global $GLOBALCONST2 = 1 Global $GLOBALCONST3 = 1 Global $GLOBALCONST4 = 1 Global $GLOBALCONST5 = 1 #EndRegion Pre-Setting #Region Test Functions Func s1() Static $i = $GLOBALCONST1 Return $i EndFunc Func g2() Return $GLOBALCONST2 EndFunc Func g3() Static $i7 = "gsdgdfegbgbrwefw" Return $GLOBALCONST3 EndFunc Func g4() Static $i1 = 1 Static $i2 = "asd" Static $i3 = 234 Static $i4 = True Static $i5 = [0] Static $i6 = "hgsdg" Static $i7 = 1 Static $i8 = 1 Static $i9 = 1 Static $i0 = 1 Return $GLOBALCONST4 EndFunc Func g5() Local $i = $GLOBALCONST5 Return $i EndFunc Func g6() Local $i = 1 Return $i EndFunc Func g7() Return 1 EndFunc #EndRegion Test Functions #Region Benchmark Loop For $i = 0 To 15 Local $tDelta = TimerInit() Do $iTally1 += s1() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally2 += g2() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally3 += g3() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally4 += g4() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally5 += g5() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally6 += g6() Until TimerDiff($tDelta) >= 1000 Local $tDelta = TimerInit() Do $iTally7 += g7() Until TimerDiff($tDelta) >= 1000 Next #EndRegion Benchmark Loop ConsoleWrite(@CRLF&"Static1: "&$iTally1&" pkt"&@CRLF&"Global2: "&$iTally2&" pkt"&@CRLF&"Global3: "&$iTally3&" pkt"&@CRLF&"Global4: "&$iTally4&" pkt"&@CRLF&"Local5: "&$iTally5&" pkt"&@CRLF&"Local6: "&$iTally6&" pkt"&@CRLF&"Hardcode7:"&$iTally7&" pkt"&@CRLF) #cs Result Static1: 10291881 pkt global to static Global2: 13977324 pkt only global Global3: 9886169 pkt global and static Global4: 2933051 pkt global and many statics Local5: 9937314 pkt global to local Local6: 10306484 pkt only local Hardcode7: 14835319 pkt no variable #ce Result:
      100% no variable, hardcore value
      94% only global variable use
      69% only local variable use with hardcore value set
      69% only static variable use with global variable value set
      67% declaration of local variable with global variable value set
      66% only global variable use with one static variable beside
      20% only global variable use with ten static variables beside
      My thesis of the result:
      Be careful with declarations, whether local, global or static Note: in my test the global variable performance was better than the local one, but in practice the global one would lose performance due to multiple operations
       
      What is your best practice sharing data between multiple functions?
    • SkysLastChance
      By SkysLastChance
      Run("notepad.exe") GLOBAL $One = ('Line1' & _ 'Line2' & _ 'Line3' & _ 'Line4' & _ 'Line5') ClipPut($One) $Notepad = WinWait("[CLASS:Notepad]", "", 10) ControlSend("Untitled - Notepad", "", "", ("^v")) Instead of having this paste as Line1Line2Line3Line4Line5
      How can I make it paste it into notepad as (without double spacing.)
      Line1
      Line2
      Line3
      Line4
      Line5
    • WoodGrain
      By WoodGrain
      Hi All,
      I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.
      I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.
      The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:
      $keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
    • TheAutomator
      By TheAutomator
      Is this better to check a variable before you assign it to a value that could be the same?
      for example:
      local $EmptyLog = false func WriteLog($text) _guictrledit_appendtext($log, ($EmptyLog ? @CRLF : $empty) & $text) If $EmptyLog Then $EmptyLog = False endfunc or does AutoIt behind the scenes already check this?
      i guess overwriting memory with the same value over and over again is not good if you can prevent this with a check?
×