How can I print a dialog box?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

How can I print a dialog box?

Post by Kreop » Sat Jun 26, 2010 2:19 pm

How can I print the dialog screen?
Or make a button than can.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sat Jun 26, 2010 5:56 pm

See if this works for you...

Code: Select all

 Dialog>MyDialog
   Caption=This is My Dialog
   Width=312
   Height=207
   Top=150
   Left=31
   Button=Print Dialog Box,160,144,97,26,3
   Button=Exit Macro,21,144,100,22,6
   Label=This is a Dialog Box,8,8,true
   Edit=msEdit1,8,56,121,msEdit1
EndDialog>MyDialog

Show>MyDialog

Label>MainLoop
  GetDialogAction>myDialog,result
  If>result=2,End
  If>result=6,Close
  If>result=3,myPrint
  Wait>0.01
Goto>MainLoop

SRT>myPrint
  GetActiveWindow>WinTitle,X1,Y1,myWidth,myHeight
  Let>X2=X1+myWidth
  Let>Y2=Y1+myHeight
  ScreenCapture>X1,Y1,X2,Y2,%SCRIPT_DIR%\mytemp.bmp
  Run>mspaint /p "%SCRIPT_DIR%\mytemp.bmp"
  If>SCREENCAP_RESULT<>0
    MessageModal>Error saving screen - errorcode - %SCREENCAP_RESULT%
  Endif
  ResetDialogAction>MyDialog
END>myPrint

SRT>Close
  CloseDialog>MyDialog
  Let>r=2
END>Close


Label>End





Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

Post by Kreop » Sat Jun 26, 2010 7:07 pm

Thanks It worked, great idea...
Any idea on how to landskape the print so it can fit in one page.

[quote

="adroege"]See if this works for you...

Code: Select all

 Dialog>MyDialog
   Caption=This is My Dialog
   Width=312
   Height=207
   Top=150
   Left=31
   Button=Print Dialog Box,160,144,97,26,3
   Button=Exit Macro,21,144,100,22,6
   Label=This is a Dialog Box,8,8,true
   Edit=msEdit1,8,56,121,msEdit1
EndDialog>MyDialog

Show>MyDialog

Label>MainLoop
  GetDialogAction>myDialog,result
  If>result=2,End
  If>result=6,Close
  If>result=3,myPrint
  Wait>0.01
Goto>MainLoop

SRT>myPrint
  GetActiveWindow>WinTitle,X1,Y1,myWidth,myHeight
  Let>X2=X1+myWidth
  Let>Y2=Y1+myHeight
  ScreenCapture>X1,Y1,X2,Y2,%SCRIPT_DIR%\mytemp.bmp
  Run>mspaint /p "%SCRIPT_DIR%\mytemp.bmp"
  If>SCREENCAP_RESULT<0>Error saving screen - errorcode - %SCREENCAP_RESULT%
  Endif
  ResetDialogAction>MyDialog
END>myPrint

SRT>Close
  CloseDialog>MyDialog
  Let>r=2
END>Close


Label>End




[/quote]

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Feb 10, 2011 5:03 pm

I have a similar question. For years I've been doing the adroege suggestion but rather than using paint I've used WordPad. The results are uncontrollable and often unusable. Then I end up using irfanview which has many command line options but needs to be purchased for non-home use.

My question:
Any possibility of getting a built in print function?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts