Jump to content

Control* problems


 Share

Recommended Posts

Hi I am trying to automate a GUI form which is developed in C#......Autoit standard functions like "ControlSend ","ControlSetText" are not working properly on the window. When i tried to spy objects it is showing as"WindowsForms10.EDIT.app".......Can you please help me out

Link to comment
Share on other sites

  • Moderators

Ankit0607,

Welcome to the AutoIt forums. :)

But please start a new thread like this in future rather then hijacking an old one. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Here is code......
 
There is edit box called 'Database IP' on GUI....i spied the same....please see attachment.......

I have tried different way to enter value in same edit box ...below is code

 
WinActivate("CPACS Connector Configuration Tool")
 
 
;First way with and without window Title
ControlSetText("CPACS Connector Configuration Tool","","[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]","11")
ControlSetText("","","[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]","11")
 
;Second Way with or without title
ControlSetText("CPACS Connector Configuration Tool","","[ClassnameNN:WindowsForms10.EDIT.app.0.378734a15]","11")
ControlSetText("","","[ClassnameNN:WindowsForms10.EDIT.app.0.378734a15]","11")
 
;Third way with or without title
ControlSetText("CPACS Connector Configuration Tool","","[iD:262810]","11")
ControlSetText("","","[iD:262810]","11")
 
;Fourth way with or without title
ControlSend("CPACS Connector Configuration Tool","","[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]","11")
ControlSend("","","[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]","11")
 
;Fifth way with or without title
ControlSend("CPACS Connector Configuration Tool","","[ClassnameNN:WindowsForms10.EDIT.app.0.378734a15]","11")
ControlSend("","","[ClassnameNN:WindowsForms10.EDIT.app.0.378734a15]","11")
 
;Sixth way with or without title
ControlSend("CPACS Connector Configuration Tool","","[iD:262810]","11")
ControlSend("","","[iD:262810]","11")
 
 
 
 
 

post-87331-0-04597600-1410244811_thumb.p

Link to comment
Share on other sites

I presume that your post was connected to post i replied to so that is why you pm-ed me with link.

So im gonna tell you something similar to what i told him.

Use ControlFocus and ControlGetFocus to confirm that you can set focus to the control.
if it did not work first time, try WinActivate and WinWaitActive with some sleep before ControlFocus and ControlGetFocus.
post heare what happend after that test.

If you can set focus try to set focus and after that use ControlSend and ControlSetText to see can you use Control*(commands) only on Controls that have focus.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

try to run this from scite and copy paste console output for us to see

test('[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]', 1)
test('[CLASSNN:WindowsForms10.EDIT.app.0.378734a15]', 2)
test('[INSTANCE:15]', 3)

Func test($data, $try)
    ConsoleWrite('!> ---------------test:' & $try & ':' & $data & @CRLF)
    Local $winHwnd = WinGetHandle("CPACS Connector Configuration Tool")
    If IsHWnd($winHwnd) Then
        WinActivate($winHwnd)
        WinWaitActive($winHwnd)
        Sleep(1000)
        If ControlFocus($winHwnd, '', $data) Then
            Sleep(1000)
            Local $focus = ControlGetFocus($winHwnd)
            If @error Then
                ConsoleWrite('!> ' & "ControlGetFocus error!" & @CRLF)
            Else
                ConsoleWrite('!> ' & $focus & @CRLF)
                If $focus == 'WindowsForms10.EDIT.app.0.378734a15' Then
                    ConsoleWrite('!> ' & 'Looks ok from heare.' & @CRLF)
                    Sleep(1000)
                    ControlSend($winHwnd, '', $data, '11')
                    If @error Then ConsoleWrite('!> ' & "ControlSend error!" & @CRLF)
                    Sleep(1000)
                    Local $text = ControlGetText($winHwnd, '', $data)
                    If @error Then
                        ConsoleWrite('!> ' & "ControlGetText error!" & @CRLF)
                        Exit
                    EndIf
                    ConsoleWrite('!> ControlGetText:' & $text & @CRLF)
                Else
                    ConsoleWrite('!> ' & ControlGetFocus($winHwnd) & ' VS WindowsForms10.EDIT.app.0.378734a15' & @CRLF)
                EndIf
            EndIf
        Else
            ConsoleWrite('!> ' & "ControlFocus error!" & @CRLF)
        EndIf
    Else
        ConsoleWrite('!> ' & "CPACS win error!" & @CRLF)
    EndIf
EndFunc   ;==>test
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

my bad, edited upper code, can you retry updated code one more time?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

edit forth edit, so many mistakes when typing >_< try now

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

O/p 

 

!> ---------------test:1:[CLASSNN:WindowsForms10.EDIT.app.0.378734a; INSTANCE:15]
!> ControlFocus error!
!> ---------------test:2:[CLASS:WindowsForms10.EDIT.app.0.378734a15]
!> ControlFocus error!
!> ---------------test:3:[iNSTANCE:15]
!> ControlFocus error!
Link to comment
Share on other sites

yea i know, i mesed up NN and with no NN :) you get the point try to test to see if you get the focus, try ids and what ever you have

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...