Hello
This button pins the thread only for yourself. Pin for all users is a function only for moderators or administrators.
In Inventor 2022 it seems to make a difference where mouse cursor is positioned when hitting shortcut key. If it is above model browser, it works. So I thought of moving mouse to model browser in macro and back to original position. Can you give it a try?
Option Explicit
Private Declare PtrSafe Function SetCursorPos Lib "user32.dll" (ByVal X As Integer, ByVal Y As Integer) As Integer
Private Declare PtrSafe Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long
Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_MOVE = &H1
Private Type POINTAPI
X_Pos As Long
Y_Pos As Long
End Type
Private Sub MoveMouse()
Dim X As Integer
X = ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Left + ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Width - 50
Dim Y As Integer
Y = ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Top + ThisApplication.UserInterfaceManager.DockableWindows.Item(1).Height - 50
Dim i As Integer
i = SetCursorPos(X, Y)
Call mouse_event(MOUSEEVENTF_MOVE, -100, -100, 0, 100)
End Sub
Public Sub CollapseAll() 'Set ShortCut Key = 4
Dim Coords As POINTAPI
Call GetCursorPos(Coords)
Call MoveMouse
DoEvents
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
Dim oControlDef As ControlDefinition
Set oControlDef = oCommandMgr.ControlDefinitions.Item("AppBrowserCollapseAllCmd")
Call oControlDef.Execute
Call SetCursorPos(Coords.X_Pos, Coords.Y_Pos)
End Sub
Public Sub ExpandAll() 'Set ShortCut Key = 5
Dim Coords As POINTAPI
Call GetCursorPos(Coords)
Call MoveMouse
DoEvents
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager
Dim oControlDef As ControlDefinition
Set oControlDef = oCommandMgr.ControlDefinitions.Item("AppBrowserExpandAllCmd")
Call oControlDef.Execute
Call SetCursorPos(Coords.X_Pos, Coords.Y_Pos)
End Sub
R. Krieg
RKW Solutions
www.rkw-solutions.com