PDA

View Full Version : FoldAll !!!


martroyx
05-03-2009, 02:48 AM
I don't know if it just me or what but the foldall function of the max editor have never worked the way it should be , I mean it fold the first level but leave the inner bracket open...
is there a way to close all the bracket in one time or do I have to make a script that click every + it encounter from the bottom ???

every time max crash I've got to close the bracket manually... please fix this somebody :-)

Martin

JHN
05-03-2009, 07:55 PM
Yes, this bothers/annoys me very much too. Notepad++ which also uses SciTe as editor does have this stuff working. If you find a way around it, please post it here!

-Johan

diffx
05-04-2009, 08:12 AM
I usually delete my first bracket (sometimes the 2nd bracket too), fold all, and then undo. Annoying, but it works for me.

JHN
05-04-2009, 08:26 AM
What I really would like is that you can collapse a selection, like in flash actionscript editor (and that's really the only cool function in that editor!)
But thanks for that suggestion, gonna work it out...
...
Commenting out (CTRL+Q) seems to work too!

At least that's something!
Thanks,

-Johan

martroyx
05-04-2009, 04:51 PM
Hi guy, I've managed to do this witch is funny but not quite what we want , I'm unable to send the ALT+V,C command that toggle the current fold ...maybe someone can come up with something :-)

you'll need this library : http://mwinapi.sourceforge.net/


try (destroydialog SpyMtx)catch()
(
dotNet.loadAssembly "$scripts\\ManagedWinapi.dll"
--//--
global SpyMtx
global keyhook_P = dotnetobject "ManagedWinapi.Hotkey"
--//--
local MaxHwnd = windows.getMAXHWND()as integer
local MaxChild = UIAccessor.GetChildWindows MaxHwnd
local MaxIntptr = dotnetobject "system.intptr" MaxHwnd
local Syswin = dotnetobject "ManagedWinapi.Windows.SystemWindow" MaxIntptr
local MaxEditor = undefined
local Xhwnd = undefined
--//--
local VK_0 = 0x30
local VK_LEFT = 0x25
local VK_UP = 0x26
local VK_RIGHT = 0x27
local VK_DOWN = 0x28
local VK_RETURN = 0x0D
local WM_SETREDRAW = 0xB
local WM_RBUTTONDOWN = 0x204
local WM_LBUTTONDOWN = 0x201
local WM_KEYDOWN = 0x100
local WM_KEYUP = 0x101
local WM_CHAR = 0x102
local VK_CONTROL = 0x11
local VK_ALT = 56
local VK_V = 0x56
local VK_C = 0x43
local VK_LMENU = 0xA4
local VK_MENU = 0x12
local WM_SYSCHAR = 0x106
local WM_SYSKEYDOWN = 0x104
local WM_SYSKEYUP = 0x105
--//--
fn Sendkey Handle keycode IntRepeat =
(
for i in 1 to IntRepeat do
(
Windows.sendMessage Handle WM_KEYDOWN keycode 0
Windows.sendMessage Handle WM_KEYUP keycode 1
)
)
--//--
fn FoldAllSequence =
(
if MaxEditor == undefined then
(
Mpos = mouse.screenpos
MaxEditor = Syswin.FromPointEx Mpos.x Mpos.y true false
Xhwnd = MaxEditor.AllChildWindows[2].AllChildWindows[1].HWnd
)
--//--
if MaxEditor != undefined then
(
Sendkey Xhwnd VK_UP 1
Windows.sendMessage Xhwnd WM_CHAR VK_V 0

)
--//--
)
--//--
fn keyhook_P_HotkeyPressed s e =
(
if SpyMtx.SpyHeart.active then
(
SpyMtx.SpyHeart.active = false
)
else
(
--enableAccelerators = false
SpyMtx.SpyHeart.active = true
)
)
--//--
rollout SpyMtx "FoldAll" height:290 width:200
(
label Null_0 "Make sure the caret is at the end of"
label Null_1 "your script and that your mouse "
label Null_2 "cursor is located within the Scite Editor."
label Null_3 ""
label Null_4 "-Once your ready Press the -P- key!"
label Null_5 "-Press the -P- key again to stop"
label Null_6 ""
label Null_7 "*** Warning ***"
label Null_8 "Pressing the -P- key can be dangerous"
label Null_9 "Save your work first!!!"
label Null_10 ""
checkbutton chk_switch "Enable -P- Key"
label Null_11 ""
label Null_12 "Martin Dufour"
label Null_13 "Quebec 2009"
--//--
on chk_switch changed state do
(
if state then keyhook_P.enabled = true
else keyhook_P.enabled = false
)
--//--
timer SpyHeart active:false interval:1
--//--
on SpyHeart tick do FoldAllSequence()
--//--
on SpyMtx close do
(
keyhook_P.enabled = false
keyhook_P = undefined
SpyMtx = undefined
gc()
)
)
--//--
createdialog SpyMtx bgcolor:(color 220 220 220) fgcolor:(color 0 0 0) style:#(#style_sysmenu,#style_toolwindow)
--//--
keyhook_P.KeyCode = keyhook_P.KeyCode.P
dotnet.addEventHandler keyhook_P "HotkeyPressed" keyhook_P_HotkeyPressed
--//--
ok
)



Martin

martroyx
05-04-2009, 05:40 PM
this one is way better :-)
cheer !


try (destroydialog SpyMtx)catch()
(
dotNet.loadAssembly "$scripts\\ManagedWinapi.dll"
--//--
global SpyMtx
global keyhook_P = dotnetobject "ManagedWinapi.Hotkey"
--//--
local MaxHwnd = windows.getMAXHWND()as integer
local MaxChild = UIAccessor.GetChildWindows MaxHwnd
local MaxIntptr = dotnetobject "system.intptr" MaxHwnd
local Syswin = dotnetobject "ManagedWinapi.Windows.SystemWindow" MaxIntptr
local MaxEditor = undefined
local Xhwnd = undefined
--//--
local VK_0 = 0x30
local VK_LEFT = 0x25
local VK_UP = 0x26
local VK_RIGHT = 0x27
local VK_DOWN = 0x28
local VK_RETURN = 0x0D
local WM_SETREDRAW = 0xB
local WM_RBUTTONDOWN = 0x204
local WM_LBUTTONDOWN = 0x201
local WM_KEYDOWN = 0x100
local WM_KEYUP = 0x101
local WM_CHAR = 0x102
local VK_CONTROL = 0x11
local VK_ALT = 56
local VK_V = 0x56
local VK_C = 0x43
local VK_LMENU = 0xA4
local VK_MENU = 0x12
local WM_SYSCHAR = 0x106
local WM_SYSKEYDOWN = 0x104
local WM_SYSKEYUP = 0x105
--//--
fn Sendkey Handle keycode IntRepeat =
(
for i in 1 to IntRepeat do
(
Windows.sendMessage Handle WM_KEYDOWN keycode 0
Windows.sendMessage Handle WM_KEYUP keycode 1
)
)
--//--
fn FoldAllSequence =
(
if MaxEditor == undefined then
(
Mpos = mouse.screenpos
MaxEditor = Syswin.FromPointEx Mpos.x Mpos.y true false
Xhwnd = MaxEditor.AllChildWindows[2].AllChildWindows[1].HWnd
)
--//--
if MaxEditor != undefined then
(
sx = random 1 2
fx = random 1 20

case sx of
(
1:(Sendkey Xhwnd VK_UP 1)
2:(Sendkey Xhwnd VK_DOWN 1)
)

if fx == 20 then (Sendkey Xhwnd VK_RETURN 1)

Windows.sendMessage Xhwnd WM_CHAR VK_V 0
)
--//--
)
--//--
fn keyhook_P_HotkeyPressed s e =
(
if SpyMtx.SpyHeart.active then
(
SpyMtx.SpyHeart.active = false
)
else
(
--enableAccelerators = false
SpyMtx.SpyHeart.active = true
)
)
--//--
rollout SpyMtx "FoldAll" height:290 width:200
(
label Null_0 "Make sure the caret is at the end of"
label Null_1 "your script and that your mouse "
label Null_2 "cursor is located within the Scite Editor."
label Null_3 ""
label Null_4 "-Once your ready Press the -P- key!"
label Null_5 "-Press the -P- key again to stop"
label Null_6 ""
label Null_7 "*** Warning ***"
label Null_8 "Pressing the -P- key can be dangerous"
label Null_9 "Save your work first!!!"
label Null_10 ""
checkbutton chk_switch "Enable -P- Key"
label Null_11 ""
label Null_12 "Martin Dufour"
label Null_13 "Quebec 2009"
--//--
on chk_switch changed state do
(
if state then keyhook_P.enabled = true
else keyhook_P.enabled = false
)
--//--
timer SpyHeart active:false interval:1
--//--
on SpyHeart tick do FoldAllSequence()
--//--
on SpyMtx close do
(
keyhook_P.enabled = false
keyhook_P = undefined
SpyMtx = undefined
gc()
)
)
--//--
createdialog SpyMtx bgcolor:(color 220 220 220) fgcolor:(color 0 0 0) style:#(#style_sysmenu,#style_toolwindow)
--//--
keyhook_P.KeyCode = keyhook_P.KeyCode.P
dotnet.addEventHandler keyhook_P "HotkeyPressed" keyhook_P_HotkeyPressed
--//--
ok
)

martroyx
05-05-2009, 06:12 AM
here's a working version now ,

you need to place caret at the end of the document,
then position your mouse cursor over the first +
sign and hit P on your keyboard.

I included an additional need library.
if someone know how to do this without using external
library be sure to let me know :-)

cheer !!
Martin

JHN
05-05-2009, 09:16 AM
-- Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2009\Scripts\foldAll\Foldall_fix_01.ms; position: 89
-- Runtime error: dotNet runtime exception: Invalid directory on URL.

The managed dll loaded ok, yours didn't... can't really figure out why, naming is ok, I coded the complete path still error.

-Johan

martroyx
05-09-2009, 03:06 AM
ho sorry didn't receive the auto message from the forum :-(

I'm using XP64 and sharpdevelop won't allow me to compile in 32bit for
some raison, so here's the code if you want to try , you'll may also need
to mess with the first index of this line:

Xhwnd = MaxEditor.AllChildWindows[2].AllChildWindows[1].HWnd

Best regard,
Martin


using System;
using System.Collections;
using System.Runtime.InteropServices;

namespace TestClass_019_02
{
public class MyClass
{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;

public void MouseLeftClick(int posx, int posy)
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, posx, posy, 0, 0);
}

public void MouseRightClick(int posx, int posy)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, posx, posy, 0, 0);
}

}

}

martroyx
05-09-2009, 07:14 AM
it was a 32bit build in fact, sorry ...so maybe it's because your using max64....

CGTalk Moderation
05-09-2009, 07:14 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.