cmoang Posted July 14, 2014 Share Posted July 14, 2014 Hello everybody. I want to take screenshots whose filenames contain text from the clipboard. When I copy text from anywhere (after mouse drag'n'drop select of of the text, right click and copy) the following script works. For example, I copy "hi there" and the filename of the screenshot is "C:UserscmoangDesktopScreenshot---hi-there.jpg" and this is also the same for the tooltip which contains "C:UserscmoangDesktopScreenshot---hi-there.jpg" However, when I copy a simple text value from an Excel cell this does not work. Let's say the Cell contains the text (without the quotes): "hi there". Then, the tooltip is "C:UserscmoangDesktopScreenshot---hi-there.jpg" but there is no screenshot file created. Why is that? Is it something wrong with the clipboard/excel formatting? How can I include the simple text value (without any forbidden filename characters, that is) of an Excel cell as the filename? #include <ScreenCapture.au3> #include <Clipboard.au3> $data_from_clipboard = StringReplace(ClipGet(), " ", "-") $desired_filename = @DesktopDir & "\Screenshot---" & $data_from_clipboard & ".jpg" _ScreenCapture_Capture($desired_filename ) Tooltip ($desired_filename , 400, 400) Link to comment Share on other sites More sharing options...
jdelaney Posted July 14, 2014 Share Posted July 14, 2014 Remove special chars: $sReportName = "sad\fjk""als|fjakl/s*dfjs:a?l.txt" $sReportNameFormatted = StringRegExpReplace ( $sReportName, "[\\/:*?<>\|'""]", "") ConsoleWrite($sReportName & @CRLF) ConsoleWrite($sReportNameFormatted & @CRLF) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
cmoang Posted July 14, 2014 Author Share Posted July 14, 2014 (edited) Thanks for the reply, but it does not work. I want to: select an Excel cell simply by clicking once on it, Ctrl+C for copying it's contents and last, running the AutoIt script so as the characters/words of the cell to be included in the filename of the screenshot. However, by: selecting an Excel cell by clicking twice on it (so the edit cursor appears), using mouse to select all of the cell's characters, Ctrl+C for copying all of it's contents and last, running the AutoIt script so as the characters/words of the cell to be included in the filename of the screenshot works, but it is not what I want. The cell's contents are simple characters/words with spaces without any special characters like question marks, exclamation marks, etc... Edited July 14, 2014 by cmoang Link to comment Share on other sites More sharing options...
jdelaney Posted July 15, 2014 Share Posted July 15, 2014 This circumvents the Ctrl+C...but I'm still not sure what you want...is it the value, or is it the formula? either way: #include <Excel.au3> $oExcel = _ExcelBookOpen(@DesktopDir & "\yourexcel.xlsx") ConsoleWrite($oExcel.ActiveCell.Value & @CRLF) ConsoleWrite($oExcel.ActiveCell.Formula & @CRLF) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now