0

I'm writing a script to be used in DiaDem. The scrip uses WshShell to copy some data to the clipboard. Then an Alt TAB, then paste. Right now i have a wait function. Sometimes this fails. I want a way to wait on the window to become active before pasting.

I have tried WinWait but have not gotten it work correctly.

Sub SetClip(sContents)
  Dim WshShell: Set WshShell = CreateObject("WScript.Shell")
  WshShell.Run "cmd.exe /c echo " & sContents & " | clip", 0, TRUE
  WshShell.SendKeys "%{TAB}",True
  Call Pause(.1) 'This is my current method of waiting on the window.
  WshShell.SendKeys "^v"
  WshShell.Run "cmd.exe /c echo off | clip", 0, TRUE 'clear clipboard
  Set WshShell = nothing
End Sub

I have not been able to get any of the code i have tried to work. The code is written in the scripting environment of DiaDem.

  • https://stackoverflow.com/questions/19696308/how-can-i-use-clipboard-in-vbscript – Noodles Mar 25 '19 at 21:54
  • Thank you Noodles for the reply. Unfortunately this is not my problem. I have already gotten the information posted to the clipboard. My problem is getting the program to wait for the window that I alt Tab to, to become active. Currently i'm just using a pause of .1 seconds. Was looking for a way to have the program wait for the window I swap to, to become active. – Bradley Smith Mar 27 '19 at 01:02

0 Answers0