Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Shortcut for Finish button from UIDocument.Selection.PickObjects()?

Anonymous

Shortcut for Finish button from UIDocument.Selection.PickObjects()?

Anonymous
Not applicable

Hello,

 

As you know there are a couple of buttons(Finish & Cancel) from UIDocument.Selection.PickObjects().

 

I know ESC is for Cancel, however, the shortcut for Finish hasn't been found out yet.

 

Does anyone know if the shortcut exists? Or is there a way to set up?

0 Likes
Reply
Accepted solutions (1)
1,851 Views
5 Replies
Replies (5)

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

HI @Anonymous ,

I think in Revit there is no shortcut option for finish.

You can only finish your selection by clicking the Finish button.

 

If there is a button option for finish then it would have been mentioned here(REFER THE ATTACHED IMAGE)

PickObjects.png

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Thanks naveen.kumar.t!!

 

You are my hero!

 

 

 

0 Likes

jlpgy
Advocate
Advocate

@naveen.kumar.t:

Actually it can be done! But the safety of the following solution is not guaranteed:

// Codes working for this funcion in our product has been highly wrapped with annoying complexity

Let's ask "Spy++" for some help.

This tool should be named as "spyxx.exe" or "spyxx_amd64.exe" if the C++ desktop develop workload has been installed:

2019-12-02_150300.png

Then we can check some detailed infomation of the "Finish" button:

2019-12-02_150912.png2019-12-02_151247.png

Once you have recursively searched all children windows of Revit Windle, and got the Finish Button, send a CLICK message to this button (window):

SendMessage(revitHandle, 0x00F5, new IntPtr(0), IntPtr.Zero);
// revitHandle can be accesed easily in 2019 API

++ This solution works fine from Revit 2016 to 2020 ++

But safety is still not guaranteed 🙂

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes

grubdex
Enthusiast
Enthusiast

I'd also be interested in this solution. Could you provide a bit more context here, i.e. what are SendMessage, revitHandle, etc.?

0 Likes

zefreestijl
Advocate
Advocate

Hi, the following steps work for my project even if I restart the Revit app and open in different files,

 

Firstly, import these functionalities: 

 

[DllImport("user32.dll")] 
private static extern IntPtr GetWindow(IntPtr hwndParent, uint uCmd); 

[DllImport("user32.dll")] 
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 

[DllImport("user32.dll")] 
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); 

[DllImport("user32.dll", CharSet = CharSet.Auto)] 
private static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);

 

then check the structures of handles from the Revit App - current File to the Finish Button as jlpgy mentioned:

 

handle0.png

 

 

for example in the ui of Revit 2024:

 

1. get the main app handle via FindWindow() or simply using the function RevitAPI provided

2. get the control bar handle via FindWindowEX()

3. get the first dialog handle via FindWindowEX() or GetWindow() 

4. repeatedly get the dialog handle via GetWindow() until there's a child handle matches the target button

 

finally use SendMessage() to send BM_CLICK message

 

according to the document of GetWindow() method  

type 5 == GW_CHILD   type 2 == GW_HWNDNEXT 

 

pinvoke.net: GetWindow (user32)