Jump to content

Filename containing copied value from an Excel cell


Recommended Posts

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

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

Thanks for the reply, but it does not work.

I want to:

  1. select an Excel cell simply by clicking once on it,
  2. Ctrl+C for copying it's contents and last,
  3. running the AutoIt script so as the characters/words of the cell to be included in the filename of the screenshot.

 

However, by:

  1. selecting an Excel cell by clicking twice on it (so the edit cursor appears), 
  2. using mouse to select all of the cell's characters,
  3. Ctrl+C for copying all of it's contents and last,
  4. 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 by cmoang
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...