Notifications
Clear all
[Closed] Findout if trackview has focus
Feb 27, 2014 9:44 am
I need to detect if an object is transformed directly in the viewport or if it’s done via the trackview. I’m planning on checking if trackview window has focus or not from within the ‘when transform’ context… anyone get a (better) solution?
5 Replies
Feb 27, 2014 9:44 am
for future reference:
global _user32 =
(
source = "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "class User32
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern IntPtr GetActiveWindow();
"
source += "}
"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly.CreateInstance "User32"
)
--code below could be placed in a 'when transform' context
hwnd=_user32.GetActiveWindow()
check=UIAccessor.GetWindowText hwnd
if (check=="Track View - Curve Editor") then
(
print "modified by trackview"
) else
(
print "modified by something else"
)
The above does not account for internationalization where the window lable might be spelled differently.
Feb 27, 2014 9:44 am
global _user32 =
(
source = "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "class User32
"
source += "{
"
source += " [DllImport(\"user32.dll\")]
"
source += " public static extern IntPtr GetActiveWindow();
"
source += "}
"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.GenerateInMemory = on
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
compilerResults.CompiledAssembly.CreateInstance "User32"
)
fn isTkackviewActive = (tv = trackviews.current) != undefined and
(
tv.ui.hwnd == user32.GetActiveWindow()
)
fn setTkackviewActive = if (tv = trackviews.current) != undefined do
(
WM_SETFOCUS = 0x7
windows.sendmessage tv.ui.hwnd WM_SETFOCUS 0 0
ok
)
Feb 27, 2014 9:44 am
Don’t want to start new thread… just a question
I can setfocus to another application but can I send text (hotkey) to it?
seems like I should add to user32 func something lke
source += ” public static extern IntPtr SendMessage();
“
but I don’t know exactly…
Any Help?
Thanks.
Feb 27, 2014 9:44 am
it would be probably better to open a new thread. you look pretty far from a solution…