Hi,
I have something… but it does not work and I need Help:
Thanks to the one and only DenisT, and his dotnet Magic,
I can retreive the word at the carret position in the editor.
But I can’t get the parameters to work with “ShellLaunch”
it only opens the index.html file (and NOT the ‘?query=MySearch’
Any ideas ?
here is the script so far:
(click a word in MXS editor and evaluate)
/*
MaxScript Local Help
*/
(
global Win32Assembly
local MXS_HELP_DIR="D:/3D/3dsmax2012/maxscript-doc-2012/"
fn CreateWin32Assembly forceRecompile:on =
(
if forceRecompile or not iskindof ::Win32Assembly dotnetobject or (::Win32Assembly.GetType()).name != "Assembly" do
(
source = "using System;
"
source += "using System.Runtime.InteropServices;
"
source += "using System.Text;
"
source += "class Win32
"
source += "{
"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]
"
source += " public static extern Int32 SetFocus(Int32 hWnd);
"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]
"
source += " internal static extern int GetWindowTextLength(Int32 hWnd);
"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]
"
source += " internal static extern int GetWindowText(Int32 hWnd, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpString, int nMaxCount);
"
source += " public static string GetWindowText(Int32 hWnd)
"
source += " {
"
source += " int length = GetWindowTextLength(hWnd);
"
source += " StringBuilder sb = new StringBuilder(length + 1);
"
source += " GetWindowText(hWnd, sb, sb.Capacity);
"
source += " return sb.ToString();
"
source += " }
"
source += "}
"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add "System.dll"
compilerParams.ReferencedAssemblies.Add "System.Drawing.dll"
compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
Win32Assembly = compilerResults.CompiledAssembly
Win32Assembly.CreateInstance "Win32"
)
)
global Win32 = CreateWin32Assembly()
fn isStopChar s =
(
local valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"
local i = findstring valid s
if i == undefined then true else false
)
fn GetWord txt pos =
(
local start = for i = pos to 1 by -1 do if (isStopChar txt[i]) do exit with (i+1)
local end = for i = pos to txt.count do if (isStopChar txt[i]) do exit with i
trimright(substring txt start (end-start))
)
fn LaunchHelp str =
(
url="file:///"+MXS_HELP_DIR+"index.html?query=" + str
format "URL:%
" url
ShellLaunch url ""
)
fn GetWordatCarretPos =
(
fn _mxs_Textbox =
(
tb = for c in (windows.getchildrenhwnd 0) where c[4] == "MXS_SciTEWindow" do exit with
(
for t in (windows.getchildrenhwnd c[1]) where t[4] == "MXS_Scintilla" do exit with t[1]
)
if tb != ok then tb else undefined
)
val=0
EM_GETSEL = 0x00B0
tb = _mxs_Textbox()
tx = Win32.GetWindowText tb
CarretPos = (windows.sendmessage tb EM_GETSEL val val)/65535
--print CarretPos
--Win32.SetFocus tb
GetWord tx CarretPos
)
LaunchHelp (GetWordatCarretPos())
)