Jump to content

Recommended Posts

JNutt

 

image.png.f92c51932f7b4a0db5ba644a6f1e08be.png

 

 

I'm trying to use mouseclick in a panel above.  I want to click on a list item, such as 'Estimated'.  (I've given up on trying to use control click for this).  I'm using window info coordinates from 'Control' tab.

image.png.250ef461ba8ed00b3bee2ba87390272c.png

; click 'Columns'
WinActivate("Innovaya Studio with Sage (Archtectural 2017_V1.invx")
MouseClick("primary", 292, 88, 1, 1)
WinActivate("Select Browsing Properties")
Sleep(1000)
MouseClick("primary", 27, 70, 0,0)
Sleep(2000)
Send("{TAB}{TAB}{TAB}{TAB}{TAB}")
Sleep(1000)
Send("{ENTER}")


ControlClick(

But when I used the code Autoit doesn't click where the coordinates are.  In the scipts it is the second MouseClick that won't work.  Any ideas?

Edited by JNutt

Share this post


Link to post
Share on other sites
Danp2
13 minutes ago, JNutt said:

I've given up on trying to use control click for this

Some additional background details might help here. Also, there are other built-in functions for dealing with listboxes. Have you tried _GUICtrlListBox_SelectString along with _GUICtrlListBox_ClickItem or _GUICtrlListView_SetItemSelected?

  • Thanks 1

Share this post


Link to post
Share on other sites
JNutt

No, I have not tried those.  I'm new to AutoIT so thanks, I'll look at those.

Share this post


Link to post
Share on other sites
JNutt

The app is windows desktop .net.  Someone mentioned before that it may contains a lot of custom widgets, so it seems getting info is difficult.  What other details would be helpful? Like I said I'm a noob here.  Thanks for your help.

I have info from inspect.exe also:

How found:    Focus
RuntimeId:    "[42.3477674.2.2]"
BoundingRectangle:    {l:469 t:404 r:669 b:421}
ProcessId:    11556
ControlType:    UIA_ListItemControlTypeId (0xC357)
LocalizedControlType:    "list item"
Name:    "Estimated"
HasKeyboardFocus:    true
IsKeyboardFocusable:    true
IsEnabled:    true
IsOffscreen:    false
FrameworkId:    "WinForm"
ProviderDescription:    "[pid:11556,hwnd:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:UIAutomationCore.dll); Main(parent link):Microsoft: ListView Item Proxy (unmanaged:UIAutomationCore.dll)]"
SelectionItem.IsSelected:    true
 

 

Share this post


Link to post
Share on other sites
jdelaney

I'd suggest to not use ui automation efl.  people are too quick to suggest that when the controls are standard ones.   use the ones dan recommended.  use controlgethandle to set the variable to pass into them.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Earthshine

your code does not even compile. I don't see correct ControlClick parameters either. Also, WinForms are not so AutoIt friendly which is precisely why IUIAutomation is useful.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
jdelaney

Identifying controls is more complex, but once found, the standard and _gui functions are going to save a ton of time relative the IUIAutomation.  When you can consistently determine the control handles to manipulate in a winform, then you can automate most any application easily.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Danyfirex

Hello I did something similar time ago. You could do something like this.

#include <GuiListView.au3>
#include <WinAPISysWin.au3>


Local $sItemTextToSelect="Luis" ;set item's text to search
Local $sWindowTitle="Form1"     ;set your correct windows title

Local $hWindow = WinActivate($sWindowTitle) ;activate the window
Local $sListViewClassNN = _MakeNetClassNN($hWindow, "SysListView32", "1") ;get Control classNN Make sure set correct list view Instance Index
ConsoleWrite("$sListViewClassNN: " & $sListViewClassNN & @CRLF)

Local $hListView = ControlGetHandle($hWindow, "", $sListViewClassNN) ;get control handle
ConsoleWrite("$hListView: " & $hListView & @CRLF)

Local $iCount = _GUICtrlListView_GetItemCount($hListView) ;get item count (just for testing)
ConsoleWrite("$iCount: " & $iCount & @CRLF)

Local $iFoundItem = _GUICtrlListView_FindText($hListView, $sItemTextToSelect) ;search/match item text
If $iFoundItem > -1 Then
    ConsoleWrite("Item Found Index: " & $iFoundItem & @CRLF)
    _GUICtrlListView_SetItemSelected($hListView, $iFoundItem) ;select the item
EndIf



Func _MakeNetClassNN($hWnd, $sControlType, $sIndexNN)
    Local $iLess = (StringRegExp($sControlType, "STATIC|EDIT|BUTTON|b|Window.b|SysListView32")) ? 0 : 2
    Local $sStringClass = _WinAPI_GetClassName($hWnd)
    Local $sStringWin = StringMid($sStringClass, 1, StringInStr($sStringClass, "."))
    Return $sStringWin & $sControlType & StringMid($sStringClass, StringInStr($sStringClass, ".app") - $iLess) & $sIndexNN
EndFunc   ;==>_MakeNetClassNN

Saludos

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

  • Similar Content

    • MaximusCZ
      By MaximusCZ
      Hello, and apologies if this have been discussed before, but I googled and couldnt find anything relevant.
      I have a problem where I try to send a control clink into to a window. 
      Part of window I try to send clicks to looks like this . The black border is showing when I mouse over it Au3Info, I get following information:

      I am testing its interaction with code

      The result I get is that it makes control clicks trough first line, opens and closes menus, as expected.
      When It gets to second line, it does not click a single icon. I can tell that coords are correct as the dropdown menus (No view active) gets focused(altough not rolled out). Same behaviour happens if roughly 40<y<60, so I know I am hitting good height. You can look at how it behaves here: output.webm 
      Dropdown 1 focuses at around 8 sec mark, and 13 sec mark it changes to second dropdown, defocusing first one, seemingly not registering any clinks inbetween.
       
      Have you ever encountered similar behaviour? I need to click the Key button, first on second line, with controlclick (or any other way not hijacking the mouse). I cant trigger that button by keyboard and There is no other control having control over it.
      Help
       
    • Skysnake
      By Skysnake
      I need to automate a specific GUI from a legacy system written in C.
      The spy tool gives me this

      I use this code
      Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
      I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
      I also tried the control ID as text "404" - same result
      What am I missing?
      Skysnake
       
    • Miliardsto
      By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
    • ur
      By ur
      I am clicking on a button on to submit o form UI.
      Problem is, the code working on windows 10,7, server 2012 r2 but not on windows server 2008.
      I checked the IDs also on that OS, they didn't change.
      Even the ControlClick is returning the status as success only but button is not getting clicked.
      But controlsettext on other fields are working.
      ;$MartConfigWindow is window object ControlClick($MartConfigWindow, "", "[CLASS:WindowsForms10.BUTTON.app.0.378734a; INSTANCE:2]")  
    • lattey
      By lattey
      I used the window info tool to get what I've got below, but it just doesn't click the button. I run the script, nothing happens. 
      WinActivate("SELECTION") Sleep(200) ControlClick("SELECTION", "", "[CLASS:Button;INSTANCE:2]") i think maybe the autoit cannot detect the windows. So what i do:
       
      MouseClick( "", 503, 500) local $blanktitle = WinGetTitle("[ACTIVE]") If StringInStr($blanktitle, "SELECTION") Then msgbox("","", "got") WinActivate($blanktitle) ControlClick($blanktitle, "", "[CLASS:Button;INSTANCE:2]") Endif The script can detect the windows as the it is prompt "got" message. But it just doesn't click the button.
      Please help.
      Thanks for any help you can offer.
×