warrentheo Posted January 7, 2010 Report Share Posted January 7, 2010 Hello, I am in the middle of writing a macro, that processes info found in the clipboard. It works just fine when it finds simple text in the clipboard, but I also want it to work by parsing text files passed to it by copying their name in explorer or something similar. I have the XP clipboard viewer, which says that the clipboard just contains a simple string with the location of the file copied (I realize that it is anything but simple text, and is just being displayed that way). When my current macro hits this kind of info in the clipboard, it reads nothing at all, and the macro exits as it has no data to run from. What I am looking for is a way to extract the file name and location from the clipboard when it occurs. Your help is appreciated, and I thank you in advance EDIT: Haven't done much with them, but is this the sort of thing "Control" class variables are for? This is what I am using currently: <VARIABLE SET STRING Option="\x02" Destination="%T[1]%"/> Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 7, 2010 Report Share Posted January 7, 2010 I'm not sure I'm the best person to answer this but how are you copying the filenames? Just selecting in Explorer won't work as far as I know. If you click the name, short delay, click again, (+ Shift+End in Opus), Ctrl+C that will copy the text name. Other 3rd party XP shells (eg ExplorerXP or Directory Opus) will copy the file name or complete filepath to the clipboard with a few (macro?) key presses. I don't know how many times I've used the full filepath utility in DO while making macros! I don't have Vista or W7. Quote Link to comment Share on other sites More sharing options...
warrentheo Posted January 7, 2010 Author Report Share Posted January 7, 2010 I'm not sure I'm the best person to answer this but how are you copying the filenames? Just selecting in Explorer won't work as far as I know. If you click the name, short delay, click again, (+ Shift+End in Opus), Ctrl+C that will copy the text name. Other 3rd party XP shells (eg ExplorerXP or Directory Opus) will copy the file name or complete filepath to the clipboard with a few (macro?) key presses. I don't know how many times I've used the full filepath utility in DO while making macros! I don't have Vista or W7. I have Win7x64, but have a copy of the XP Clipboard viewer, it shows full file name/path when I copy the file. When I use that program to save the contents of the clipboard, then open them in notepad, it shows the same file name buried in the middle of the garbage and shell extensions stuff used by windows to know it is a file and not text. I was just wondering if there was a way to get that same info to a variable in MXP? Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 7, 2010 Report Share Posted January 7, 2010 I was right, I'm the wrong guy. I thought your last post might be the alternative scenario. One of the experts will have to comment on what characters can be pasted from the Clipboard. If it's a large file it would take some time to Paste into ME but I'm sure you must have waited long enough. Quote Link to comment Share on other sites More sharing options...
rberq Posted January 8, 2010 Report Share Posted January 8, 2010 You say you can use the XP clipboard viewer to save the contents of the clipboard to a file, and you can view that file in Notepad. So, maybe you could write a macro that uses ME commands to: 1) launch the XP Clipboard Viewer 2) type the keystrokes needed to save clipboard contents to a file 3) open the save file in Notepad 4) copy from the Notepad screen into the clipboard 5) parse the new clipboard data and extract the file name and path Steps 3 & 4 might be replaced by simply reading the save file into a ME variable. Step 5 might be very easy, or it might be the trickiest. It depends on what "garbage and shell extensions stuff" surrounds the data you want to extract. If you are not familiar with using ME to parse strings, post an example of the data you see in Notepad, and we can probably give you advice on how to do it. Quote Link to comment Share on other sites More sharing options...
Cory Posted January 8, 2010 Report Share Posted January 8, 2010 You might check out a clipboard app like ClipMate. Quote Link to comment Share on other sites More sharing options...
paul Posted January 8, 2010 Report Share Posted January 8, 2010 You might check out a clipboard app like ClipMate. I've used Clipmate for years and have found it an indispensable tool. Unfortunately much of it simply no longer works under Windows 7 x64 (it's written in Delphi, which doesn't offer any 64-bit capabilities). Quote Link to comment Share on other sites More sharing options...
Cory Posted January 11, 2010 Report Share Posted January 11, 2010 Good to know. ......................... I just moved to W7x64 at the end of the year and haven’t gotten around to installing all my utilities yet. I can’t believe so many vendors are so behind on supporting 64 bit OSs. They’ve been around for a coon’s age and I’m surprised how many bits of software aren’t there yet. Big ones like Adobe Flash too. Also there will be huge increase now with W7 I think given it ships with both versions. When I installed Ultimate it didn’t even ask me if I wanted the 32 or 64. I bet there are tons of people who don’t even realize their machines are x86-64 and will be surprised when they get the 64 bit version. Quote Link to comment Share on other sites More sharing options...
acantor Posted January 11, 2010 Report Share Posted January 11, 2010 I wonder whether this is some kind of timing issue. Certain operations take longer to complete than we might like, and in those cases, one of the only recourses we have is to insert time delays into our scripts. Clipboard operations often require a little extra time, so you might want to add short delays before and after copying text to see if it makes a difference. Start with 1000 ms, and if your macro works, decrease the delay or delays until it stops working reliably. When I find I need to insert delays, they are usually 100-300 ms. on occasion, five or 10 ms is all it takes. Quote Link to comment Share on other sites More sharing options...
warrentheo Posted January 12, 2010 Author Report Share Posted January 12, 2010 After checking, it doesn't appear to be timeing :-( This is part of a macro I was planning to release to the general public once done, and so I am attempting to skip other programs that need to be downloaded to get it to work Thank you for the replies, Ill keep looking into it Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 12, 2010 Report Share Posted January 12, 2010 (edited) I don't know if this is of any help. It seemed to me that what you think you see on the clipboard may not be what is actually there. If you copied a file off Explorer, why would the filepath be there? An exe for example does not contain the filepath neither does a text file. Perhaps what you are seeing as a filepath is Clipboard internal stuff. I looked at clipboard content using a hex viewer. Pasting the clipboard asked for the clipboard format. They don't mean much to me. From Explorer there were 7 format options (from Data Object through OLE Private Data); from Directory Opus 17 options. Filename or filenamew options produced the full text path which could be copied. Filename from Explorer sometimes produced 8.3 filenames so you had to go to filenamew. If you copied an exe file for example, it does not matter what any viewer says, when you paste the file, all that is pasted is the content of the exe file. There is no path information. Edited January 12, 2010 by JohnS Quote Link to comment Share on other sites More sharing options...
acantor Posted January 12, 2010 Report Share Posted January 12, 2010 Have you tried inserting a "Macro Stop" command after copying information to the clipboard, and then manually checking its content by pasting it somewhere? If you discover that the content of the clipboard is what you expect it to be, try copying it to a text variable. Then check the value of the variable, and see whether it matches the clipboard. If I were trying to parse information, I would rather manipulate a variable than the clipboard. Finally, your method for copying information to the clipboard might affect things. A method that works in one macro may fail in another. You should try both "Clipboard Copy" and "Text Type<CONTROL>c". In one situation, neither of these techniques worked for me, but I found that "Clipboard Cut" did the trick. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 13, 2010 Report Share Posted January 13, 2010 I'm still not sure how the information is being added to the clipboard but anyway I wrote a quickie macro with AutoIt that may help. If a filename is copied in Explorer by right-click copy or select-copy this short macro will put the full filepath in T77 and display in a text box. If this is of any use, edit as needed. I also tried this in several non-Explorer file listings and it also works if plain text has been copied. Only tested in XP. External Script: AutoIt Text Box Display: Results <EXTERNAL SCRIPT Language="AutoIt" Dest="%T[77]%" Script="$contents = ClipGet()\r\nConsoleWrite($contents)\r\n"/> <TEXT BOX DISPLAY Title="Results" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\lang4105\\f0\\fs16 The filepath is %T[77]%\\lang1033\\f1 \r\n\\par }\r\n" Left="276" Top="275" Width="546" Height="93" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Let me know if this works on other PCs regardless of whether it solves this thread as I'm a beginner with AutoIt! I also made a standalone compiled exe which puts the results back on the clipboard (presumably deleting what was there). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.