Sign in to follow this  
Followers 0
sbrady

pass variable to clipboard

2 posts in this topic

here is the end goal.

put data onto the clipboard so I can paste it into an email. Pasting would yield something like this:

GM111n1

HM222n2

OP333n3

the file name contains a CD number (GM111) and a cut number (n1) so what I would do is select some files in a folder for processing:

AR123 score v1 GM111n1.txt

AR123 score v1 HM222n2.txt

AR123 score v1 OP333n3.txt

and from these files I extract the CD and cut number (GM111n1) and put them on the clipboard. Each file needs to have a return. Here is the code I have so far. I can get the data I need from the file name. I just dont know how to put it into an array or a variable. Here is the code I have so far. Any kind reply's would be appreciated.

#include
#include

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc")
ClipPut ("")
$aWinList=WinList("[REGEXPCLASS:^(Explore|Cabinet)WClass$]")

For $i = 1 To $aWinList[0][0]
; Get base folder and selections
$aSelection = _ExplorerWinGetSelectedItems($aWinList[$i][1])

; Display as strings
ConsoleWrite("Explorer Window: " & $aSelection[1] & " Selection(s)" & @CRLF)
For $j = 2 To $aSelection[0] + 1
ConsoleWrite(@TAB & $aSelection[$j] & @CRLF)
Next
; Display as array
;_ArrayDisplay($aSelection, "Explorer Instance #" & $i & " / " & $aWinList[$i][0])







; START SHAWN's CODE____________________________
; repeat with the selected items
For $File_Name = 1 To $aSelection
$Array = [0]

; check if $file_name contains "n"
$result = StringInStr($File_Name, "n",0,1)
If $result > 0 Then

;v2 rename
$filename5 = StringRegExpReplace($File_Name, "(?i)(.*)(\sv.*)(\s.*\sMIX)(\.txt)", "$1$3$2$4")
$full_path_len =StringLen ( $File_Name ) ;79
$filename_len = StringInStr ( $File_Name, "\" , 0 , -1) ;47 (characters to last "\")
$folder_path = StringTrimRight ( $File_Name, $full_path_len - $filename_len) ;C:\Documents and Settings\sebrad\Desktop\shawn
$file_renamed = StringTrimLeft ( $File_Name, $filename_len) ;AR123 Smith, Bob FULL MIX v1
$filename_len2 = StringInStr ( $file_renamed, " " , 0 , -1) ;47 (characters to last "\")
$file_renamed2 = StringTrimLeft ( $file_renamed, $filename_len2) ;GM333n333.txt
$file_renamed3 = StringTrimRight ($file_renamed2 , 4)
;MsgBox(4096, "wwwww", $file_renamed3)

;=================
; I NEED $file_renamed3 TO BE ADDED TO THE CLIPBOARD
; WITH A RETURN AFTER SO THE SELECTION RETURNS THIS
; TO THE CLIPBOARD
; GM111n1
; GM222n2
; GM333n3
;=================



EndIf

Next
; END SHAWN's CODE________________________

Next


























; ==========================================================================================================================

; Func _ObjectSHFolderViewFromWin($hWnd)
;
; Returns an 'ShellFolderView' Object for the given Window handle
;
; Author: Ascend4nt, based on code by KaFu, klaus.s
; ==========================================================================================================================

Func _ObjectSHFolderViewFromWin($hWnd)
If Not IsHWnd($hWnd) Then Return SetError(1,0,0)
Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView

; Shell Object
$oShell=ObjCreate("Shell.Application")
If Not IsObj($oShell) Then Return SetError(2,0,0)

; Get a 'ShellWindows Collection' object
$oShellWindows = $oShell.Windows()
If Not IsObj($oShellWindows) Then Return SetError(3,0,0)

; Iterate through the collection - each of type 'InternetExplorer' Object

For $oIEObject In $oShellWindows
If $oIEObject.HWND = $hWnd Then
; InternetExplorer->Document = ShellFolderView object
$oSHFolderView=$oIEObject.Document
If IsObj($oSHFolderView) Then Return $oSHFolderView
Return SetError(4,0,0)
EndIf
Next

Return SetError(-1,0,0)
EndFunc

; ==========================================================================================================================
; Func _ExplorerWinGetSelectedItems($hWnd)
;
;
; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification)
; ==========================================================================================================================

Func _ExplorerWinGetSelectedItems($hWnd)
If Not IsHWnd($hWnd) Then Return SetError(1,0,'')
Local $oSHFolderView
Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""]

$oSHFolderView=_ObjectSHFolderViewFromWin($hWnd)
If @error Then Return SetError(@error,0,'')

; SelectedItems = FolderItems Collection object->Count
$iSelectedItems = $oSHFolderView.SelectedItems.Count

Dim $aSelectedItems[$iSelectedItems+2] ; 2 extra -> 1 for count [0], 1 for Folder Path [1]

$aSelectedItems[0]=$iSelectedItems
; ShellFolderView->Folder->Self as 'FolderItem'->Path
$aSelectedItems[1]=$oSHFolderView.Folder.Self.Path

; ShellFolderView->SelectedItems = FolderItems Collection object
$oSelectedFolderItems = $oSHFolderView.SelectedItems

#cs
; For ALL items in an Explorer window (not just the selected ones):
$oSelectedFolderItems = $oSHFolderView.Folder.Items
ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]
#ce

For $oFolderItem In $oSelectedFolderItems
$aSelectedItems[$iCounter] = $oFolderItem.Path
$iCounter += 1
Next

Return SetExtended($iCounter-2,$aSelectedItems)
EndFunc ;==>_ExplorerWinGetSelectedItems

Func _ComErrFunc($oError)
ConsoleWrite("COM Error occurred:" & @CRLF & _
"Number: " & @TAB & $oError.number & @CRLF & _
"Windescription:" & @TAB & $oError.windescription & @CRLF & _
"Description is: " & @TAB & $oError.description & @CRLF & _
"Source is: " & @TAB & $oError.source & @CRLF & _
"Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
"Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
"Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
"Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
"Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc ;==>_ComErrFunc

Share this post


Link to post
Share on other sites



Which mail program do you use? Maybe there is a direct way without using the clipboard.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0