Jump to content

ControlSend without any Control Info available


Recommended Posts

Hello all,

I spent almost 2 days looking for a way to use ControlSend on a window not containing any control info, but could not get it to work.

The reason for me to use ControlSend is that I need to work with a locked Workstation (Standard Send function does not work in that case). I have tried many techniques, among them the ControlFocus() command but still no way to have it working.

*********************************************************************************

Please find below the summary window:

>>>> Window <<<<
Title: NX 7.5 - [No Part]
Class: Afx:0000000140000000:b:0000000000000000:0000000000000000:FFFFFFFFFE141E3D
Position: 145, 129
Size: 1260, 767
Style: 0x148F0000
ExStyle: 0x00000100
Handle: 0x00210126

>>>> Control <<<<
Class: 
Instance: 
ClassnameNN: 
Name: 
Advanced (Class): 
ID: 
Text: 
Position: 
Size: 
ControlClick Coords: 
Style: 
ExStyle: 
Handle: 

>>>> Mouse <<<<
Position: 801, 144
Cursor ID: 0
Color: 0x1C1C1C

>>>> StatusBar <<<<
1: Use Open or New in File Menu
2: 
3: 
4: 

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Teamcenter Navigator
Teamcenter Navigator
TreeLayout
no name
Tree
PanelLayout
Manufacturing Activities
Search
Browse Filter
Assembly Load Options
Preview
Assembly Navigator

*********************************************************************************

I feel like if you have no control info, it is simply not possible to use ControlSend ...

$ret=ControlFocus("[TITLE:NX 7.5 - [No Part];CLASS:Afx:0000000140000000:b:0000000000000000:0000000000000000:FFFFFFFFFE141E3D]", "", "")
ConsoleWrite(@CR & @CR & "ControlFocus returned " & $ret & @CR & @CR)
$ret=ControlSend("[TITLE:NX 7.5 - [No Part];CLASS:Afx:0000000140000000:b:0000000000000000:0000000000000000:FFFFFFFFFE141E3D]", "", "", "^o")
ConsoleWrite(@CR & @CR & "ControlSend returned " & $ret & @CR & @CR)

ControlFocus returned 1

ControlSend returned 1

I manage to have the focus but the command is not happening "^o"

Any idea of what I could be missing? Or even a workaround solution?

I have been checking most of topics on this subject but could not find a solution.

I thank you in advance for any support or help.

Regards,

Marc.

 

Link to comment
Share on other sites

Thanks for your comment. I tried your proposal but it was still not sending the command to the desired window.

Using ControlFocus like this with the text title is working:

ControlFocus("NX 7.5 - [No Part]", "", "")

So I am sure I am not doing any error on the window title. When I try this command then:

ControlSend ("NX 7.5 - [No Part]", "", "","^u")  it does not work anymore.

Can't see why ControlFocus is working and not ControlSend ...

 

Link to comment
Share on other sites

By the way, I have also tried to use the trick here :

But I received an important amount of information using the mentioned function to get the window's control information but it is very difficult to know to what they correspond ...

Link to comment
Share on other sites

12 hours ago, junkew said:

 

Hello Junkew,

Thanks for your link and work. I have downloaded the zip files in the link you shared, but could not run simplespy.au3 because it was asking me admin access which I unfortunately do not have. I have downloaded from GiThub folder au3_uiautomation-master and launched simplesply.au3 giving me this: Please see attached

Unfortunately I am not able to copy paste this data or even use ctrl+w it is copying nothing. Maybe you could tell me which line I should be checking?

Inside of the downloaded folder I found a tool called Inspect.exe that I used to inspect the window I need to drive through controlSend. I found a lot of data but nothing telling me what I should give in argument of the ControlSend function of AutoIT:

*********************************************************

How found: Mouse move (504,156)

hwnd=0x00000000000E07D2 64bit class="Afx:0000000140000000:b:0000000000000000:0000000000000000:0000000004F70E81" style=0x148F000RuntimeId: "[42.919506.1.-2147483647.919506.-2.0]"

ProcessId: 9088

ControlType: UIA_TitleBarControlTypeId (0xC375)

LocalizedControlType: "title bar"

HasKeyboardFocus: false

IsKeyboardFocusable: false

IsEnabled: true

IsContentElement: false

IsPassword: false

IsOffscreen: true

ProviderDescription: "[pid:8176,hwnd:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"

Value.IsReadOnly: false

Value.Value: "NX 7.5 - "

IsDockPatternAvailable: false

IsExpandCollapsePatternAvailable: false

IsGridItemPatternAvailable: false

IsGridPatternAvailable: false

IsInvokePatternAvailable: false

IsMultipleViewPatternAvailable: false

IsRangeValuePatternAvailable: false

IsScrollPatternAvailable: false

IsScrollItemPatternAvailable: false

IsSelectionItemPatternAvailable: false

IsSelectionPatternAvailable: false

IsTablePatternAvailable: false

IsTableItemPatternAvailable: false

IsTextPatternAvailable: false

IsTogglePatternAvailable: false

IsTransformPatternAvailable: false

IsValuePatternAvailable: true

IsWindowPatternAvailable: false

IsItemContainerPatternAvailable: false

IsVirtualizedItemPatternAvailable: false

FirstChild: "System" menu bar

LastChild: "System" menu bar

Next: [null]

Previous: "" pane

Other Props: Object has no additional properties

Children: "System" menu bar

Ancestors: "NX 7.5 - " window

"Desktop" pane

[ No Parent ]

**********************************************************

For information, I am just trying to launch a simple command like ctrl+o on this window to open a part on a locked workstation.

I have tried to use ControlViewer as well but it did not find any Control information on the window.

Could you please suggest any other steps I may have missed?

Thanks again for your help and support.

Output.png

Edited by Marco57
Attached Picture
Link to comment
Share on other sites

IUIAutomation is a different solution and not compatibel with controlsend. 

In the simple spy you see some "standard code" which you can try. 

But as you are talking about a locked workstation you most likely are not getting thru. 

Whats your goal? there are options to make sure your workstation keeps awake (and not getting locked) by just sending numlock twice every n seconds/minute.

google: locked workstation / sendkeys  will give you many directions

maybe (i certainly doubt) its possible with send / post message like this

non working examples
  $pass="secret password" 
  SendMessage hWnd, WM_SETTEXT, 0&, ByVal $sPass
  SendMessage hWnd, EM_SETSEL, Len($sPass), 0&
  #enter/return key
  PostMessage hWnd, WM_KEYDOWN, &HD&, &H1C0001

 

Link to comment
Share on other sites

56 minutes ago, junkew said:

IUIAutomation is a different solution and not compatibel with controlsend. 

In the simple spy you see some "standard code" which you can try. 

But as you are talking about a locked workstation you most likely are not getting thru. 

Whats your goal? there are options to make sure your workstation keeps awake (and not getting locked) by just sending numlock twice every n seconds/minute.

google: locked workstation / sendkeys  will give you many directions

maybe (i certainly doubt) its possible with send / post message like this

non working examples
  $pass="secret password" 
  SendMessage hWnd, WM_SETTEXT, 0&, ByVal $sPass
  SendMessage hWnd, EM_SETSEL, Len($sPass), 0&
  #enter/return key
  PostMessage hWnd, WM_KEYDOWN, &HD&, &H1C0001

 

My goal is to be able to launch command ctrl+o in a specific window or even try to use File .. Open .. (see attached)

It is not a possible solution to keep the workstation unlocked for security reasons. I can't believe this window cannot be accessed at all ...

What do you suggest to use from simple spy "standard code"?

 

Output 2.png

Link to comment
Share on other sites

Please find below the information I got from info tool on the window.

I took the Title and class info from the "Basic Window Info" and put them as 1st argument of ControlSend function but this was not working as well

ControlSend("[TITLE:NX 7.5 -  ;CLASS:Afx:0000000140000000:b:0000000000000000:0000000000000000:0000000000310F51]","","","^o")

 

Output 3.png

Link to comment
Share on other sites

you seem to be having 2 questions

1. control that menu?
2.  What do you suggest to use from simple spy "standard code"?
3. control the (un)lock screen of your workstation?

answer  1

you go with simplespy to the element you want then press ctrl+w and you see your element highlighting.

answer 2

If it highlighted you see in the output example source code which you can use for starting. so you should use all sample code as given by the spy

answer 3 

I am a google believer so please let me know if you have a sendkeys solution found by google that works

 regarding "I can't believe this window cannot be accessed at all "  which window you talk about? if you read the whole iuiautomation thread you have all references to handle all kinds of windows and worst case you have to go to optical character recognisiton. see frequently asked questions FAQ 31

  • And I see you try to do things thru the GUI but isn't there an API / ActiveX dll to control teamcenter?
Link to comment
Share on other sites

48 minutes ago, junkew said:

you seem to be having 2 questions

1. control that menu?
2.  What do you suggest to use from simple spy "standard code"?
3. control the (un)lock screen of your workstation?

answer  1

you go with simplespy to the element you want then press ctrl+w and you see your element highlighting.

answer 2

If it highlighted you see in the output example source code which you can use for starting. so you should use all sample code as given by the spy

answer 3 

I am a google believer so please let me know if you have a sendkeys solution found by google that works

 regarding "I can't believe this window cannot be accessed at all "  which window you talk about? if you read the whole iuiautomation thread you have all references to handle all kinds of windows and worst case you have to go to optical character recognisiton. see frequently asked questions FAQ 31

  • And I see you try to do things thru the GUI but isn't there an API / ActiveX dll to control teamcenter?

Please find my comments below:

answer 1 :

Simplespy seems to require Admin access to work correctly because in my case it is stopping windows explorer and not possible to copy anything from the generated txt (ctrl+w) nothing is then highlighted. Inspect.exe is the only one I get to run.

answer 2

As it is not running, I have then no source code to run, but I guess it should provide similar information as the one available in Inspect.exe right? (please see attached)

answer 3

I spent almost one week trying to find how to control this window. I am speaking about NX 7.5 window. If it is not possible to sendkey to this window, I hope at least it is possible to go into File menu + Open part for instance. But even using WinMenuSelectItem did not work ... Looking at the info coming from Inspect, could you please suggest a way to call WinMenuSelectItem to do File-> Open... just in case I would be calling it the wrong way?

 

I can access teamcenter easily because I have control ID on them but to run a given .dll program I need to launch it from NX window itself.

Thanks for your continuous help and support.

 

Output 4.png

Edited by Marco57
attachment
Link to comment
Share on other sites

14 hours ago, junkew said:

Remove requireadmin in source of simplespy to be no.

If inspect.exe works simplespy should work without admin

Is this the product you try to control

https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_api/#uid:index

Api is better then sendkeys

 

It still do not allow me to copy any code from simplespy but this I guess is coming from my configuration (I think AutoIT itself is also asking for admin access to perform well with simplespy)

I do not have any access to NXOpen API, so I can only use NX through it's interface to launch .dll files.

I managed to copy code from simplespy by taking print screen and using ROC but the following code (given by simplespy) is doing nothing on NX window :

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)
Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=NX 7.5 -  ;controltype:=UIA_WindowControlTypeId;class:=Afx:0000000140000000:b:0000000000000000:0000000000000000:0000000000090A1D",$treescope_children)
_UIA_Action($oP0,"setfocus")

;  First find the object in the parent before you can do something
;~ $oUIElement=_UIA_getObjectByFindAll(".mainwindow", "title:=;ControlType:=UIA_TitleBarControlTypeId", $treescope_subtree)

Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=;ControlType:=UIA_TitleBarControlTypeId", $treescope_subtree)
_UIA_action($oUIElement,"click")

I really start to loose hope on driving this window by anyway ...

Could you please suggest  what I should retrieve from simplespy to at least for instance try to use ControlFocus and have the NX window getting the focus for instance?

This would be something to start with already.

Thanks

Link to comment
Share on other sites

I am not saying its easy if you have not much experience

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)
Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=NX 7.5.*",$treescope_children)
_UIA_Action($oP0,"highlight")
_UIA_Action($oP0,"setfocus")
_UIA_Action($oP0,"sendkeys","FO")

open the menu and press ctrl+w in the simplespy and you get again some code

open the submenu and press ctrl+w in the simplespy and you get again some code

I never heard copy/paste problems from simplespy as its just an edit control its straight forward copy/paste

Link to comment
Share on other sites

2 hours ago, junkew said:

I am not saying its easy if you have not much experience

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)
Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=NX 7.5.*",$treescope_children)
_UIA_Action($oP0,"highlight")
_UIA_Action($oP0,"setfocus")
_UIA_Action($oP0,"sendkeys","FO")

open the menu and press ctrl+w in the simplespy and you get again some code

open the submenu and press ctrl+w in the simplespy and you get again some code

I never heard copy/paste problems from simplespy as its just an edit control its straight forward copy/paste

Many thanks for those lines Junkew, it in fact worked but unfortunately not with a workstation being locked :(:( This is because it used sendkeys right?

Link to comment
Share on other sites

Its not due to sendkeys or sendinput its about desktops 

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682573(v=vs.85).aspx

Where the desktop your app runs gets disconnected from mouse and keyboardfunctions and the security window is part of a different desktop and thread. But anyway no easy way around which i am aware of,

Link to comment
Share on other sites

13 hours ago, junkew said:

Its not due to sendkeys or sendinput its about desktops 

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682573(v=vs.85).aspx

Where the desktop your app runs gets disconnected from mouse and keyboardfunctions and the security window is part of a different desktop and thread. But anyway no easy way around which i am aware of,

Oh I see ... Then I will just drop down the idea I guess. Many thanks for your support and help on this topic ! I definitely hate windows without control IDs !!

Link to comment
Share on other sites

The general way I circumvent this (but I am admin on my machine) to have a virtual machine (or remote desktop in our datacenter) running where I can keep the screen unlocked and if my laptop gets locked the virtual machine keeps running indepently.

Link to comment
Share on other sites

It is a pretty good idea, but how would you launch the autoit script on virtual machine while having the main workstation locked? I was able to launch Virtual Machine from a locked machine but still struggling to launch the script itself on the virtual machine automatically.

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...