JRL wrote:jpuziano wrote:Check out ClipboardToFile.exe and FileToClipboard.exe
I could but would rather not use these two apps. For me on my computer I can live with the flashing windows. If they aren't working for you on your Win XP SP1 computer, that is a bright red blinking warning beacon in my mind.
Hi JRL,
As it happens, the red blinking beacon, once I figured it out, was actually saying... "Install the free MS Visual C++ Runtime
available here" and once I did,
ClipboardToFile.exe and FileToClipboard.exe worked perfectly.
The Microsoft Visual C++ 2005 Redistributable Package (x86) installs runtime components of Visual C++ Libraries required to run applications developed with Visual C++ on a computer that does not have Visual C++ 2005 installed.
Note that the C++ source code for these is also freely available.
The advantages here are speed and no blinking or flashing of any kind. Here's what I came up with...
Code: Select all
//2006-10-15 00:46:16 Sunday jpuziano
//Clipboard Image Save/Restore via ClipboardToFile.exe and FileToClipboard.exe
IfDirExists>%TEMP_DIR%ClipBoardData,DirExists
CreateDir>%TEMP_DIR%ClipBoardData
Label>DirExists
//Delete all saved clipboard files from last run
DeleteFile>%TEMP_DIR%ClipBoardData\*.*
//Save clipboard data
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run>e:\ClipboardToFile.exe %TEMP_DIR%ClipBoardData\
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
//Put some text into the clipboard using the PutClipBoard function
PUT>This text is now in the clipboard.
Run>notepad.exe
WaitWindowOpen>Untitled - Notepad
Wait>1
//Paste the clipboard text into notepad
//proving the script has overwritten the clipboard.
Press ctrl
send>v
Release ctrl
wait>2
CloseWindow>Untitled - Notepad
Wait>1
Send>n
Wait>1
//Restore Clipboard Data - Only restoring 5 data formats below.
//If you need to restore more, add another section for each additional format.
//To discover the format names, look in the %TEMP_DIR%ClipBoardData\ directory
//for all formats saved from the clipboard when you last ran this macro.
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
IfFileExists>%TEMP_DIR%ClipBoardData\CF_DIBV5
Run>e:\FileToClipboard.exe %TEMP_DIR%ClipBoardData\CF_DIBV5 CF_DIBV5
Else
Endif
IfFileExists>%TEMP_DIR%ClipBoardData\CF_DIB
Run>e:\FileToClipboard.exe %TEMP_DIR%ClipBoardData\CF_DIB CF_DIB
Else
Endif
IfFileExists>%TEMP_DIR%ClipBoardData\CF_BITMAP
Run>e:\FileToClipboard.exe %TEMP_DIR%ClipBoardData\CF_BITMAP CF_BITMAP
Else
Endif
IfFileExists>%TEMP_DIR%ClipBoardData\CF_TEXT
Run>e:\FileToClipboard.exe %TEMP_DIR%ClipBoardData\CF_TEXT CF_TEXT
Else
Endif
IfFileExists>%TEMP_DIR%ClipBoardData\CF_OEMTEXT
Run>e:\FileToClipboard.exe %TEMP_DIR%ClipBoardData\CF_OEMTEXT CF_OEMTEXT
Else
Endif
Unfortunately, for deploying to a large number of users, they'd have to get that C++ runtime installed and they are still locked down... so I took another look at your original script and tried to eliminate as much of the flashing as possible and here's the result of that effort (not perfect but I think I reduced flashing quite a bit)...
Code: Select all
//2006-10-15 02:29:32 Sunday
//JRL's Clipboard Image Save and Restore script with mods by jpuziano
Let>SK_DELAY=10
Let>Clipfile=%TEMP_DIR%~SaveClipBoard~.clp
IfFileExists>%Clipfile%
DeleteFile>%Clipfile%
EndIf
//Write the current clipboard contents to a file
Let>RP_WINDOWMODE=0
//Let>RP_WINDOWMODE=1
Run>clipbrd.exe
Let>WIN_USEHANDLE=0
WaitWindowOpen>ClipBook Viewer*
MoveWindow>ClipBook Viewer*,2000,1000
SetFocus>ClipBook Viewer*
Wait>1
//From "Window" main menu, choose "1" to view clipboard instead of clipbook
Press Alt
Send>w
Release Alt
Send>1
Wait>0.5
//save existing clipboard contents
Press Alt
// Send>fa
Send>f
Release Alt
Send>a
WaitWindowOpen>Save As
Let>WIN_USEHANDLE=1
FindWindowWithText>NT Clipboard File (*.CLP),1,window_handle
MoveWindow>window_handle,2000,1000
Wait>0.5
send>%Clipfile%
Press enter
//Close clipbrd.exe app
Press Alt
// Send>fx
Send>f
Release ALT
Send>x
Wait>1
//Put some text into the clipboard using the PutClipBoard function
PUT>This text is now in the clipboard.
Let>RP_WINDOWMODE=1
Run>notepad.exe
Let>WIN_USEHANDLE=0
WWO>Untitled - Notepad
Wait>1
//Paste the clipboard text into notepad
//proving the script has overwritten the clipboard.
Press ctrl
send>v
Release ctrl
wait>2
CloseWindow>Untitled - Notepad
Wait>1
Send>n
Wait>1
//Read the saved pre-script clipboard contents back to the clipboard
Let>RP_WINDOWMODE=0
//Let>RP_WINDOWMODE=1
Run>clipbrd.exe
Let>WIN_USEHANDLE=0
WaitWindowOpen>ClipBook Viewer*
MoveWindow>ClipBook Viewer*,2000,1000
SetFocus>ClipBook Viewer*
Wait>1
//From "Window" main menu, choose "1" to view clipboard instead of clipbook
Press Alt
Send>w
Release Alt
Send>1
Wait>2
Press Alt
// Send>fo
Send>f
Release Alt
Send>o
Let>WIN_USEHANDLE=0
WaitWindowOpen>Open
Let>WIN_USEHANDLE=1
FindWindowWithText>NT Clipboard File (*.CLP),1,window_handle
MoveWindow>window_handle,2000,1000
send>%Clipfile%
Press enter
Let>WIN_USEHANDLE=0
WaitWindowOpen>Clear Clipboard
//Let>WIN_USEHANDLE=1
//FindWindowWithText>Do you want to clear the contents of the Clipboard?,1,window_handle
//MoveWindow>window_handle,2000,1000
send>y
Press Alt
// Send>fx
Send>f
Release ALT
Send>x
Menu dropdown flashing was eliminated by re-positioning the main window way off-screen. The Open and Save As dialogs were a problem as even though the main window was off-screen, the dialogs always came up where you could see them. I used FindWindowWithText> to get the handle of the dialogs and repositioned them off screen as well. For the Clear Clipboard dialog, it turned out to be less flashing by just quickly sending a "y".
If anyone knows of any VB script or Win32 API calls to make all child windows of a main window appear hidden as well, please let us know.
Beyond the above two methods, I'd still like to see (one day) commands added to Macro Scheduler that could accomplish this, something like this perhaps:
jpuziano wrote:TakeClipBoardSnapShot>
- writes to a structure in memory (or disk?) created by Macro Scheduler
- must be called before RestoreClipBoardfromSnapShot
RestoreClipBoardfromSnapShot>
- reads from a structure in memory (or disk?) created by Macro Scheduler
...but I know the Windows Clipboard is a complex thing and there are many more mainstream things to work on with the beta etc., so I know something like this might be a long time coming. Until then, at least we have the methods worked out so far.
If anyone has any more ideas on this, please jump in.
Hope this was of some help JRL, always enjoy your posts, take care...