Magically passing data between scripts

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

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

Magically passing data between scripts

Post by JRL » Fri May 06, 2011 10:05 pm

I was asked how to pass data from one script to another or from one executable to another without first writing the data to a file or the clipboard or the registry etc. There are windows messaging APIs that look promising but why bother. Macro Scheduler has everything you need built in. This requires Macro Scheduler version 12 Dialogs.

Basically we pass the data from one script to the other using SetControlText and in the case of this sample a memo box in an invisible version 12 dialog.

Script one has the data

Code: Select all

Input>SendData,Enter the info to send to ReceivingDialog
SetControlText>ReceivingDialog,tMSMemo,1,SendData
SetFocus>ReceivingDialog
Script two waits patiently for script one to set the data in the memo box using SetControlText then setfocus to that memo box. At the moment the memo box receives focus, a dialog handler set up to detect that the memo box has been entered calls a subroutine that performs whatever task needs to be done with the data. In this case it displays the data in a Macro Scheduler message box.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  AlphaBlend = True
  AlphaBlendValue = 0
  Caption = 'ReceivingDialog'
  object MSMemo1: tMSMemo
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSMemo1,OnEnter,Process

Label>Loop
  Wait>0.01
Goto>Loop

SRT>Process
  GetDialogProperty>Dialog1,MSMemo1,Text,result
  MDL>result
  Exit>0
END>Process

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