[Closed] How to press the OK button in JPEG IMAGE CONTROL window?
The title says the problem.
Here is the code:
(
function FindVFBrollout titlePattern: =
(
myDialogs = UIAccessor.getChildWindows 0
maxVFB = undefined
stopLoop = false
for dlg in myDialogs while stopLoop == false do
(
dialogTitle = UIAccessor.getWindowText dlg
if dialogTitle != undefined do
(
if (matchpattern dialogTitle pattern:titlePattern) then
(
maxVFB = dlg
stopLoop = true
)
)
)
maxVFB
)
maxVFB = FindVFBrollout titlePattern:"*, frame * (*:*)"
if (maxVFB != undefined) do
(
vfb_children = UIAccessor.getChildWindows maxVFB
vfb_saveButton = undefined
stopLoop = false
for vfb_child in vfb_children while stopLoop == false do
(
if (uiaccessor.getWindowResourceID vfb_child == 261) then
(
vfb_saveButton = vfb_child
stopLoop = true
)
)
if vfb_saveButton != undefined do
(
DialogMonitorOPS.unRegisterNotification id:#dmoVFBSaveButton
function DMONotification =
(
windowHandle = DialogMonitorOPS.GetWindowHandle()
dn = (UIAccessor.GetWindowText windowHandle) as string
if dn == " Save Image " do
(
children = UIAccessor.getChildWindows windowHandle
stopLoop = false
for vfb_child in children while stopLoop == false do
(
if (uiaccessor.getWindowResourceID vfb_child == 1148) then
(
uiaccessor.setWindowText vfb_child "D:\\Just testing.jpg"
stopLoop = true
)
)
-- Press the Save As button
UIAccessor.PressDefaultButton()
-- "how to press the OK button in "JPEG IMAGE CONTROL" rollout?"
)
true
)
DialogMonitorOPS.RegisterNotification DMONotification id:#dmoVFBSaveButton
DialogMonitorOPS.Enabled = true
UIAccessor.pressButton vfb_saveButton
DialogMonitorOPS.ShowNotification()
)
)
)
Render any image and while the virtual frame buffer is visible execute the code. The VFB window will be found, the Save Image button will be pressed, the path where to save the image(with jpg extension) will be typed(in the File Name: field), the Save button will be pressed and JPEG Image Controll window will pops up. Now, how to press the OK button so the image to be saved?
works for 2014 max
function DMONotification =
(
windowHandle = DialogMonitorOPS.GetWindowHandle()
if windowHandle != undefined do
(
data = windows.getHWNDData windowHandle
format "window: % \n" data
case data[5] of
(
" Save Image ":
(
children = UIAccessor.getChildWindows windowHandle
searching = true
for vfb_child in children while searching do
(
if (uiaccessor.getWindowResourceID vfb_child == 1148) then
(
uiaccessor.setWindowText vfb_child "D:\\Just_testing.jpg"
searching = false
)
)
-- Press the Save As button
UIAccessor.PressDefaultButton()
)
"JPEG Image Control":
(
-- print (windows.getChildrenHWND windowHandle)
UIAccessor.PressButton (UIAccessor.GetFirstChildWindow windowHandle) -- OK
DialogMonitorOPS.unRegisterNotification id:#dmoVFBSaveButton
DialogMonitorOPS.Enabled = false
)
)
)
true
)
I know this does not answer your question, but can’t you just save the rendered bitmap and avoid the use of UIAccessor?
(
image = getlastrenderedimage copy:false
image.filename = "D:\\Just testing.jpg"
save image
)
Serejah, thank you. I was on wrong direction whole day.
Jorge, the script will work in version of 3ds max lower than 2014. The problem is the gama when the image is saved. The getlastrenderedimage
gives the image with wrong gama.
First I tried the code that I have posted here, but this JPEG Image Control was the problem.
Then I wrote a script that press the Copy Image button on the VFB and then saves it using dotNet(to avoid gamma issue) but I found that the copied image don’t have the size of the rendered image.
I have tried to lower the output gamma to 1.0 but this aslo not soves the problem.
Then I have started to think how I can use nested DialogMonitorOps to catch the JPEG Image Control window.
And everything was so easy.
In max2014+ we can use save image gamma:2.2
but in max2014- we have to…
Does this “solve” the gamma issues in Max 2014-?
(
image = getlastrenderedimage copy:false
if (IDisplayGamma.colorCorrectionMode==#gamma) do image.gamma = IDisplayGamma.gamma
image.filename = "D:\\Just testing.jpg"
save image
)
Yes. Thank you.
And there is not a word in the Help file that this can be used to overcome that annoying problem.