Dialog Designer copy and paste

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

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

Dialog Designer copy and paste

Post by JRL » Wed Oct 24, 2007 6:59 pm

I use the Dialog Designer often. It is a fabulous tool. It does have some inadequacies and one of these is copy and paste of dialog objects. Currently the Dialog Designer can copy and paste an object but the new pasted object will share exactly the same space as the original copied object. You can then use the mouse to drag one of them to a new location. I find this a little cumbersome and sometimes confusing. Sometimes I can't tell that I've created an extra object because it is sitting directly on top of the original. I would like to see the Dialog Designer copy and paste functionality work in a fashion more like the script below.

To use this script for copy and paste in the Dialog Designer:

First, start Dialog Designer from the Macro Scheduler editor. Then start the script, I have mine set to a hot key. After you create an object using the standard features of the Dialog Designer, copy the object by right clicking the object and selecting "Copy" from the menu. Then Right click in the location you want to place your pasted object and select "Paste" from the menu. The new object should show up in approximately the location you've selected.

This script can only copy one object at a time. It would be nice if this enhancement were implemented that it would be capable of copy/pasting selected groups of objects.

Hopefully someone will find this script useful and more hopefully it will soon be obsoleted.

Thanks for listening,
Dick

Code: Select all

//Following is the only user specific variable
//"DialogTitleHeight" compensates for the vertical offset distance between
//the top of the dialog window,  and the top of the usable dialog box.
//In other words,  the height of the title bar in pixels.
Let>DialogTitleHeight=20

Let>MouseFlag=0
Let>LabelMessage=1) Right Click on an object to copy%CRLF%
Concat>LabelMessage,2) Select "Copy" from the list%CRLF%
Concat>LabelMessage,3) Right Click the point for new copy of object%CRLF%
Concat>LabelMessage,4) Select "Paste" from the list%CRLF%%CRLF%
Concat>LabelMessage,or press ESC to quit.

IfWindowOpen>Dialog Designer*
  IfWindowOpen>no selected components*
    SetFocus>no selected components*
  EndIf
  IfWindowOpen>Name: *
    SetFocus>Name: *
  EndIf
  Let>WIN_USEHANDLE=1
  GetActiveWindow>WinTitle,WinX,WinY
  //Let>WIN_USEHANDLE=0
Else
  MDL>Dialog Designer not open...
  Goto>EOF
EndIf

OnEvent>KEY_DOWN,VK2,0,Process
OnEvent>KEY_DOWN,VK27,0,Quit

Dialog>DialogSelectPoint
   Caption=Pick a point
   Width=250
   Height=116
   Top=0
   Left=0
   Close=0
   Label=%LabelMessage%,8,8,true
EndDialog>DialogSelectPoint

Show>DialogSelectPoint

Label>SelectLoop
IfWindowOpen>%WinTitle%
  If>%MouseFlag%<>0
    Add>MouseFlag,1
    If>MouseFlag>20
      Let>MouseFlag=0
    EndIf
  EndIf
Wait>0.01
Else
  Goto>EOF
EndIf
Goto>SelectLoop

SRT>Process
  If>MouseFlag=0
    GetClipBoard>clip
    Let>WIN_USEHANDLE=1
	IfWindowOpen>%WinTitle%,Continue,NormalCopyObject
    Label>Continue
	  SetFocus>%WinTitle%
      GetWindowPos>%WinTitle%,WinX,WinY
    GetCursorPos>CurX,CurY
    Sub>CurX,%WinX%
    Sub>CurY,%WinY%
    Sub>CurY,%DialogTitleHeight%
    Separate>clip,Left = ,left
    Separate>left_2,%CRLF%,left
    Separate>clip,Top = ,top
    Separate>top_2,%CRLF%,top
    StringReplace>clip,Left = %left_1%,Left = %CurX%,clip
    StringReplace>clip,Top = %top_1%,Top = %CurY%,clip
    PutClipBoard>clip
	IfWindowOpen>%WinTitle%
      SetFocus>%WinTitle%
	EndIf
  EndIf
  Label>NormalCopyObject
  Let>MouseFlag=1
  //Let>WIN_USEHANDLE=0
END>Process

SRT>Quit
Goto>EOF
END>Quit

Label>EOF

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