Sign in to follow this  
Followers 0
xtrm

windows handle and password box problem

8 posts in this topic

#1 ·  Posted (edited)

hello, I have a problem with a password edit box. I can input text into the password box but I cannot delete the text sending "". Seems the password box disables some properties or has different properties than a normal edit box when its focused. The following command did not work for me:

ControlSend("Connecting to **********", "", "Edit3", "")oÝ÷ ÚØb²+&ÉÊ&¦W­zÇ+p'!ëlj§vW­¡¬"Ú0§ʭç(w¶)à¢÷«¶§zÚ+iDzȧZjW¦j)^ÅÈZ¬z»Þ¯brÞªè«zËaz)éºÚ¶©jË0¢·^½êò¶)y²q«jëh×6
$pass = "12345"
$a = ""
;getting focus of active windows by tittle which are hard to be focused
;the script can be improved a lot and there is a bit of garbage, but seems to work nice most of the times :)


;sending the handle of a window and checking if exist

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 1 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

While 1
    $var = WinList() ;needs to be here to refresh each time the array list of windows

    ;loop to check all the active windows
    For $i = 1 to $var[0][0]
        
        ;checking if it is our window
        If ($var[$i][0] == "Credenciales de Microsoft Office Outlook" OR $var[$i][0] == "Conectar a ******") AND IsVisible($var[$i][1]) Then
            
            ;messagebox test to check script errors
            ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) 
            
            ;set the window attribute on top
            WinSetOnTop ("Conectar a ******", "", 1 )
            
            ;show the window in case its hidden
            WinSetState ( "title", "text", @SW_SHOW )
            
            ;while we have focus on the window
            While (WinActivate ( "Conectar a ******", "" ) )
                
                ;if we got focus to the window, then we set focus to the textbox and finally send the text clearing it before.
                If (WinActive ("Conectar a ******", "") ) Then
                    
                    ;setting textbox focus
                    $a = ControlGetText("Conectar a ******", "", "Edit3")
                    MsgBox(0, "Details", "a = " & $a)
                    
                    ;clear textbox if it has something, DOESNT WORK!!!, finds "" everytime maybe because of the password properties 

                    If ($a = "" ) Then ;its already clear
                        ;send text to the textbox identified by Edit3.
                        MsgBox(0, "Details", "no text found, found:" & $a)
                        ControlSend("Conectar a ******", "", "Edit3", $pass)
                        ControlSend("Conectar a ******", "", "Edit3", "")
                         
                        ;alternative method to send text, --less secure.
                        ;Clipput("") ;clean clipboard memory
                        ;ClipPut($pass) ;send text to the clipboard
                        ;Send("^V")
                        ;Send("{ENTER}")
                    Else    ;the textbox if not clear, and we must clear it before sending text. 
                        ;ControlSend must clear the textbox before adding more text.
                        MsgBox(0, "Details", "text found!!")
                        ControlSend("Conectar a ******", "", "Edit3", "")
                        ControlSend("Conectar a ******", "", "Edit3", $pass)    
                    EndIf
                    
                    ;if the window is found and info has been sent to the control, wait more seconds to search for the windows again
                    Sleep(5000)
                    
                EndIf
                
            WEnd
        EndIf
        
        Clipput("") ;clean clipboard memory
    Next
    
    Sleep(3000)
WEnd

(I used ****** instead of my personal info)

Autoit Window Info of the password box (Edit 3):

---------------------------------------------------------

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:  Connecting to ***************
Class:  #32770
Size:   X: 495  Y: 346  W: 326  H: 289

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 665  Y: 517
Cursor ID:  5

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB:    Hex: 0xFFFFFF   Dec: 16777215

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size:       X: 116  Y: 134  W: 169  H: 20
Control ID: 1005
ClassNameNN:    Edit3
Text:       
Style:      0x500100A0
ExStyle:        0x00000204

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<


>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Connecting to  ***************
&User:
***********
??
***********
&...
&Password:
&Remember Password
Aceptar
Cancelar

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

the problem: (Edit3 = password box)

-----------------------

$a = ControlGetText("Conectar a ******", "", "Edit3")

finds everytime "", you can type anything in the password field but only "" will be return

the control E which select all the text doesnt work here.

there could be a fix but i dont like it very much, and its just with ALT C in my case, which will automaticaly set focus to the box because its the predefined key, and then deleting the selection with {BACKSPACE}.

any help is welcome thanks :lmao:

Edited by xtrm

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

well..

ControlSend("Connecting to **********", "", "Edit3", "")
oÝ÷ Ù8^¶«v«jg­z·è®ØZµû§rبÈhºW[y©â× z½tÓ®¶­s`¤6öçG&öÅ6VæBgV÷C´6öææV7FærFò¢¢¢¢¢¢¢¢¢¢gV÷C²ÂgV÷C²gV÷C²ÂRÂgV÷C²gV÷C²

or the INTEGER ID of whatever control you are trying to interact with.

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

well..

ControlSend("Connecting to **********", "", "Edit3", "")
oÝ÷ Ù8^¶«v«jg­z·è®ØZµû§rبÈhºW[y©â× z½tÓ®¶­s`¤6öçG&öÅ6VæBgV÷C´6öææV7FærFò¢¢¢¢¢¢¢¢¢¢gV÷C²ÂgV÷C²gV÷C²ÂRÂgV÷C²gV÷C² oÝ÷ Úíâ
LADèZµëÞ­Ê'¶º%Ê­ëkÊ)ටµêÚrÜ"¶êº^ée !Ñ!+ajy,~ò¢êÚÌ®+pjɲ+-jGË^iШÚè'§t!¢é]më¬x¢{k¢Tµ7±·}÷ÞÚ櫶©jË0¢·[£(®¼jëh×6ControlSetText("Conectar a *****", "", 1005, "") oÝ÷ Û
+Ê^­÷µ©ÝrW®Ëaz¬³
+1)zk¡¹^¬m秭ë(÷nëH²Ø¥¯y«&jYb²Ëëmx-ë^Æا¶©jË0¢·[£"¶®¶­sbb33c¶Ò6öçG&öÄvWEFWBgV÷C´6öæV7F"¢¢¢¢¢gV÷C²ÂgV÷C²gV÷C²ÂR ×6t&÷ÂgV÷C´FWFÇ2gV÷C²ÂgV÷C¶ÒgV÷C²fײb33c¶  ¶6ÆV"FWF&÷bB26öÖWFæp bb33c¶ÒgV÷C²gV÷C²FVâ¶G2Ç&VG6ÆV

Ive tried with $a = and a$ ==

in case it could be a sensitive problem but $a shows "" even when there is text, so i think this time it is a limitation of this password box which doesnt allow checking its content. dunno if this password box could be fully managed directly with a handle and skip its attributes.

Edited by xtrm

Share this post


Link to post
Share on other sites

hello CHRIS, thanks for your answer it was my mistake. Instead

ControlSend I should be using ControlSetText!! to clear the password box, sorry :lmao:

ControlSetText("Conectar a *****", "", 1005, "") oÝ÷ Û
+Ê^­÷µ©ÝrW®Ëaz¬³
+1)zk¡¹^¬m秭ë(÷nëH²Ø¥¯y«&jYb²Ëëmx-ë^Æا¶©jË0¢·[£"¶®¶­sbb33c¶Ò6öçG&öÄvWEFWBgV÷C´6öæV7F"¢¢¢¢¢gV÷C²ÂgV÷C²gV÷C²ÂR ×6t&÷ÂgV÷C´FWFÇ2gV÷C²ÂgV÷C¶ÒgV÷C²fײb33c¶  ¶6ÆV"FWF&÷bB26öÖWFæp bb33c¶ÒgV÷C²gV÷C²FVâ¶G2Ç&VG6ÆVoÝ÷ ÚÇ+vFéÒyÊ'u«­¢+Ø)5Í  ½à À°ÅÕ½ÐìÅÕ½Ðì°
½¹Ñɽ±ÑQáÐ ÅÕ½ÐíQÍÐÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÄÀÀĤ¤(

it will not return anything. But get rid of the password character and it will.

(btw, change the Control ID to whatever your Window Info tool says.)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ive tested the scripts and works as you said, so there seems not to be a directly way to check for the content of a restricted box like a password box.

*btw congrats for your 1000 posts :lmao:

Edited by xtrm

Share this post


Link to post
Share on other sites

So how does the final script look like ? Tried to puzzle it together without success :whistle:

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

;final working script:

;-------------------------

I remember the script can be improved a lot, there are some things which could be skip.

Also make sure you change the **** with the necessary text of your window.

$pass = "123456"   ;your password
$a = ""
;getting focus of active windows by title which are hard to be focused
;script can be improved, seems to work nice most of the times :)
;the script has to be improved


;sending the handle of a window and checking if exist

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 1 ) Then 
    Return 1
  Else
    Return 0
  EndIf
EndFunc

While 1
    $var = WinList() ;needs to be here to refresh each time the array list of windows

    ;loop to check all the active windows
    For $i = 1 to $var[0][0]
        
        ;checking if it is our window, **CHECK YOUR TEXT IN TASKBAR
        If ($var[$i][0] == "Credenciales de Microsoft Office Outlook" OR $var[$i][0] == "Conectar a ****") AND IsVisible($var[$i][1]) Then
            
            ;messagebox test to check script errors
            ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) 
            
            ;set the window attribute on top
            WinSetOnTop ("Conectar a ****", "", 1 )
            
            ;show the window in case its hidden
            WinSetState ( "title", "text", @SW_SHOW )
            
            ;while we have focus on the window
            While (WinActivate ( "Conectar a ****", "" ) )
                
                ;if we got focus to the window, then we set focus to the textbox and finally send the text clearing it before.
                If (WinActive ("Conectar a ****", "") ) Then
                    
                    ;setting textbox focus
                    ;$a = ControlGetText("Conectar a ****", "", 1005)
                    ;MsgBox(0, "Details", "a = " & $a)
                    
                    ;clear textbox if it has something
                    ;If ($a = "" ) Then ;its already clear
                        ;clear and send text to the passwordbox identified by ID (1005).
                        ;MsgBox(0, "Details", "no text found, found:" & $a)
                    
                    ;this password box doesnt allow to check its content so we will have to clear everytime and put the password
                    ControlSetText("Conectar a ****", "", 1005, "") ;clear the text
                    ControlSend("Conectar a ****", "", 1005, $pass & "{ENTER}") ;sending the password
                        
                         
                        ;second alternative method to send text to the password box, --less secure.
                        ;Clipput("") ;clean clipboard memory
                        ;ClipPut($pass) ;send text to the clipboard
                        ;Send("^V")
                        ;Send("{ENTER}")
                    ;Else   ;the textbox if not clear, and we must clear it before sending text. 
                        ;ControlSend must clear the textbox before adding more text.
                        ;MsgBox(0, "Details", "text found!!")
                        ;ControlSetText("Conectar a ****", "", 1005, "")
                        ;ControlSend("Conectar a ****", "", 1005, $pass)    
                    ;EndIf
                    
                    ;if the window is found and info has been sent to the control, wait more seconds to search for the windows again
                    Sleep(20000)
                    
                EndIf
                
            WEnd
        EndIf
        
        ;Clipput("") ;clean clipboard memory if second method has been used
    Next
    
    Sleep(1000)
WEnd
Edited by xtrm

Share this post


Link to post
Share on other sites

if you dont get it to work paste your example and we could look into it :whistle:

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