KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: FileSystemObjects
Topic Summary: What, if anything, should be hereā€¦
Created On: 05/19/2022 04:18 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 FileSystemObjects   - GarethR - 05/19/2022 04:18 PM  
 FileSystemObjects   - GarethR - 05/19/2022 04:22 PM  
 FileSystemObjects   - Lunis Orcutt - 05/19/2022 08:11 PM  
 FileSystemObjects   - Todd - 05/20/2022 12:47 AM  
 FileSystemObjects   - GarethR - 05/20/2022 11:58 AM  
Keyword
 05/19/2022 04:18 PM
User is offline View Users Profile Print this message

Author Icon
GarethR
New Member

Posts: 18
Joined: 05/27/2021

I have a command that lets me cut, copy and paste from three files kept in my C drive. here are two snippets from it…

Dim oFSO As New FileSystemObject
Dim oFS
...
Case "Paste"
   Select Case ListVar2
   Case "one"
      Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt")
      Do Until oFS.AtEndOfStream
         sText = oFS.ReadLine
      Loop
      Clipboard sText
      SendSystemKeys "{Ctrl+v}"

so what, if anything should be after "Dim oFS"? it still works, but I'd like to know please.
Cheers,
Gareth

 

 

 



-------------------------

DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz

"Confidence isn't walking into a room thinking you are better than everyone; it's walking in not having to compare yourself at all."

 05/19/2022 04:22 PM
User is offline View Users Profile Print this message

Author Icon
GarethR
New Member

Posts: 18
Joined: 05/27/2021

Perhaps this would be best in Commands, Scripts, and Macros - Dragon, if those with power can move it?

-------------------------

DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz

"Confidence isn't walking into a room thinking you are better than everyone; it's walking in not having to compare yourself at all."

 05/19/2022 08:11 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 39967
Joined: 10/01/2006

Originally posted by: GarethR Perhaps this would be best in Commands, Scripts, and Macros - Dragon, if those with power can move it?

 

Done



-------------------------

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1

 05/20/2022 12:47 AM
User is offline View Users Profile Print this message

Author Icon
Todd
Advanced Member

Posts: 172
Joined: 02/03/2008

By default, oFS will be declared as a variant.  This will work, but you might want to declare it as a generic object:

 

          Dim oFS as Object

 

If your code works, then you probably already referenced "Microsoft Scripting Runtime (1.0)".  Finally, it looks like you will need to rework the logic for sText as it appears to simply store the last line read.  The following code appears to work should you wish to integrate it into your existing script.

 

          '#Language "WWB-COM"

 

          Option Explicit

 

          Sub Main

                    Dim oFSO As FileSystemObject

                    Dim oFS As Object

                    Dim sText As String

 

                    sText = ""

 

                    Set oFSO = CreateObject("Scripting.FileSystemObject")

                    Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt")

 

                    Do Until oFS.AtEndOfStream

                               sText = sText & oFS.ReadLine

                    Loop

 

                    Clipboard sText

          End Sub

 

I hope you find this helpful.



-------------------------

Todd Kermit
Principal
SpeechWise
todd@speechwise.com

www.speechwise.com

Dragon Professional Individual 15.61, Intel Core i7-10700K, 16GB RAM, Windows 10 Pro, Plantronics CS55/Andrea PureAudio USB-SA

 05/20/2022 11:58 AM
User is offline View Users Profile Print this message

Author Icon
GarethR
New Member

Posts: 18
Joined: 05/27/2021

Very much so, thank you. I didn't have that reference at the top, but have added it.

I added & vbNewLine as well, therefore completing the idea of three extra multiple line clipboards, even if they're text only.

Up till now, I relied on the main clipboard for multiple line copies, and use clipboard 1-3 for single line words, phrases, code…

Thanks again.

Maybe others have better versions, especially the software people have developed, but here is my command, after updating, if anybody else is interested in it.

'#Language "WWB-COM"

Option Explicit
Sub Main
Dim oFSO As New FileSystemObject
Dim oFS As Object
Dim sText As String
Dim CBMaster As String
    On Error Resume Next
        CBMaster = Clipboard
        Select Case ListVar1
            Case "Copy"
                Select Case ListVar2
                Case "one"
                    SendSystemKeys "{Ctrl+c}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip1.txt", True)
                    oFS.Write(Clipboard)
                Case "two"
                    SendSystemKeys "{Ctrl+c}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip2.txt", True)
                    oFS.Write(Clipboard)
                Case "three"
                    SendSystemKeys "{Ctrl+c}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip3.txt", True)
                    oFS.Write(Clipboard)
                End Select
            Case "Paste"
                Select Case ListVar2
                Case "one"
                    Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip1.txt")
                    Do Until oFS.AtEndOfStream
                    sText = sText & oFS.ReadLine & vbNewLine
                    Loop
                    Clipboard sText
                    SendSystemKeys "{Ctrl+v}"
                Case "two"
                    Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip2.txt")
                    Do Until oFS.AtEndOfStream
                    sText = sText & oFS.ReadLine & vbNewLine
                    Loop
                    Clipboard sText
                    SendSystemKeys "{Ctrl+v}"
                Case "three"
                    Set oFS = oFSO.OpenTextFile("C:\ProgramData\Clip3.txt")
                    Do Until oFS.AtEndOfStream
                    sText = sText & oFS.ReadLine & vbNewLine
                    Loop
                    Clipboard sText
                    SendSystemKeys "{Ctrl+v}"
                End Select
            Case "Cut"
                Select Case ListVar2
                Case "one"
                    SendSystemKeys "{Ctrl+x}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip1.txt", True)
                    oFS.Write(Clipboard)
                Case "two"
                    SendSystemKeys "{Ctrl+x}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip2.txt", True)
                    oFS.Write(Clipboard)
                Case "three"
                    SendSystemKeys "{Ctrl+x}"
                    Set oFS = oFSO.CreateTextFile("C:\ProgramData\Clip3.txt", True)
                    oFS.Write(Clipboard)
                End Select
        End Select
        Clipboard CBMaster
    If Err.Number <> 0 Then
        Beep
    End If

End Sub


-------------------------

DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz

"Confidence isn't walking into a room thinking you are better than everyone; it's walking in not having to compare yourself at all."



KnowBrainer Speech Recognition » Commands, Scripts, and Macros - Dragon » FileSystemObjects

Statistics
32324 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 2 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 355 guests browsing this forum, which makes a total of 357 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.