Jump to content
Macro Express Forums

cldcp00

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by cldcp00

  1. Hi

    The Clipboard contains 

    C:\Desmond Music\Music Library 2018\000 Music Selected To Play WhatsApp Group\Check if already got\02 Funky Maker (Horace Andy - Funny Man).mp3

     

    and

    I have entered the following expecting that it should trap anything that begins with C:\Desmond Music\

    Is this not the case? If not what options do I have?

    image.png.583ab18d6675f3497a3b23225dbd9e61.png

     

  2. Hi Cory,

     

    Below is the MEP Code which passes two values to the External VBScript

     

    Variables

    %FullFilename%

    %Destination%

     

    // PURPOSE OF MACRO
    Copy the seleced file to another existing user-selectable folder.
     
     

    Clipboard Empty
    Text Type (Simulate Keystrokes): <F2> // Edit mode.
    Delay: 0.2 seconds
    // Select all. (Iincluding extension, which I found necessary in Win 10.) Or use @acantor's equally effective method.
    Text Type (Simulate Keystrokes): <CONTROL>a
    Delay: 0.2 seconds
    Clipboard Copy
    Delay: 0.2 seconds
    Variable Set String %tFilename% from the clipboard contents
    Text Type (Simulate Keystrokes): <ESC> // Close edit mode
    Delay: 0.1 seconds
    // Select address of current folder.
    Text Type (Simulate Keystrokes): <ALT>d
    Delay: 0.1 seconds
    Clipboard Copy
    Delay: 0.1 seconds
     
    Variable Set String %tFolder% from the clipboard contents
    Text Type (Simulate Keystrokes): <ESC> // Close edit mode
    Delay: 0.1 seconds
    // Now re-assemble the original full filename and path.
    Variable Modify String %tFullFilename%: Append Text String Variable (%tFolder%)
    Variable Modify String %tFullFilename%: Append Text (\)
    Variable Modify String %tFullFilename%: Append Text String Variable (%tFilename%)
    Variable Modify String: Save %tFullFilename% to the clipboard
    Delay: 0.1 seconds
    Variable Set String %tDestination% to "C:\Desmond Music\New Music Library 2018\Classical"
    External Script: VBScript
    Text Box Display: Results

    The External VBscript is called (See code below)

     

    image.thumb.png.a7448c509bd02701f80c7d4c8453f8b5.png

     

    Things to note

    The %Console% variable specified in the  save console output to Box is the means by which and output form the VBscript is passed back to the host MEP script.

    So Wscript.Echo has passed "File Copied Successfully" to the the MEP script using Console.

     

    Then the last thing I do is display %Console% using Text Box

    image.png.2b8bdb1a4aa6a39136741388b5af5e8d.png 

     

    Warning

    The thing that caught me out was the quotes "%Destination%" around the passed  variables, I did not noticed that they were needed, and it just will not work without them. As i have already said this has something to do with the way MEP passings vales to the External Script.

     

    I am a newbie so sorry if I have not used the correct terms but I hopes it helps 

     

  3. On 10/17/2019 at 11:05 AM, terrypin said:

     

    Script:

    
    // BEFORE RUNNING: Read the opening comment lines to ensure I've interpreted your requirement accurately.
    // BEFORE RUNNING: Assign the required variables. (Quickest method is to open each command by double clicking it and respond Yes to the program's requests.)
     
    // I've used longish delays to be on the safe side.
    // I've used meaningful variable names as @samrae advised you. I prefix them to indicate their type, avoiding ambiguity in complex macros.
     
    // STARTING STATE BEFORE MACRO IS ACTIVATED
    A single file is selected in an active (focused) File Explorer folder.
    // PURPOSE OF MACRO
    Copy the seleced file to another existing user-selectable folder.
     
    Clipboard Empty
    Text Type (Simulate Keystrokes): <F2> // Edit mode.
    Delay: 0.2 seconds
    // Select all. (Iincluding extension, which I found necessary in Win 10.) Or use @acantor's equally effective method.
    Text Type (Simulate Keystrokes): <CONTROL>a
    Delay: 0.2 seconds
    Clipboard Copy
    Delay: 0.2 seconds
    Variable Set String %tFilename% from the clipboard contents
    Text Type (Simulate Keystrokes): <ESC> // Close edit mode
    Delay: 0.1 seconds
    // Select address of current folder.
    Text Type (Simulate Keystrokes): <ALT>d
    Delay: 0.1 seconds
    Clipboard Copy
    Delay: 0.1 seconds
     
    Variable Set String %tFolder% from the clipboard contents
    Text Type (Simulate Keystrokes): <ESC> // Close edit mode
    Delay: 0.1 seconds
    // Now re-assemble the original full filename and path.
    Variable Modify String %tFullFilename%: Append Text String Variable (%tFolder%)
    Variable Modify String %tFullFilename%: Append Text (\)
    Variable Modify String %tFullFilename%: Append Text String Variable (%tFilename%)
    Variable Modify String: Save %tFullFilename% to the clipboard
    Delay: 0.1 seconds
    // When testing or trouble-shooting it's helpful to show results at key stages, as in the following example. (Disable or delete this command when satisfied.)
    Text Box Display: Result so far
    // Now allow user to choose the destination folder.
    Text Box Display: Choose destination folder
    Text Type (Simulate Keystrokes): <ALT>d
    Clipboard Copy
    Delay: 0.1 seconds
    Variable Set String %tDestination% from the clipboard contents
    Text Type (Simulate Keystrokes): <ESC> // Deselect folder box
    Delay: 0.2 seconds
    Copy File/Files: "%tFullFilename%" to "%tDestination%"
    // You could now add  commands to return focus to the original folder if you wish. Or whatever. Such ad including the above in a Repeat loop to copy a SUCCESSION of files.

     

    Code:

    
    <COMMENT Value="BEFORE RUNNING: Read the opening comment lines to ensure I've interpreted your requirement accurately." _BACK="0080FFFF"/>
    <COMMENT Value="BEFORE RUNNING: Assign the required variables. (Quickest method is to open each command by double clicking it and respond Yes to the program's requests.)" _BACK="0080FFFF"/>
    <COMMENT/>
    <COMMENT Value="I've used longish delays to be on the safe side."/>
    <COMMENT Value="I've used meaningful variable names as @samrae advised you. I prefix them to indicate their type, avoiding ambiguity in complex macros."/>
    <COMMENT/>
    <COMMENT Value="STARTING STATE BEFORE MACRO IS ACTIVATED\r\nA single file is selected in an active (focused) File Explorer folder."/>
    <COMMENT Value="PURPOSE OF MACRO\r\nCopy the seleced file to another existing user-selectable folder."/>
    <COMMENT/>
    <CLIPBOARD EMPTY/>
    <TEXT TYPE Action="0" Text="<F2>" _COMMENT="Edit mode."/>
    <DELAY Flags="\x01" Time="0.2"/>
    <COMMENT Value="Select all. (Iincluding extension, which I found necessary in Win 10.) Or use @acantor's equally effective method."/>
    <TEXT TYPE Action="0" Text="<CONTROL>a"/>
    <DELAY Flags="\x01" Time="0.2"/>
    <CLIPBOARD COPY/>
    <DELAY Flags="\x01" Time="0.2"/>
    <VARIABLE SET STRING Option="\x02" Destination="%tFilename%" NoEmbeddedVars="FALSE"/>
    <TEXT TYPE Action="0" Text="<ESC>" _COMMENT="Close edit mode"/>
    <DELAY Flags="\x01" Time="0.1"/>
    <COMMENT Value="Select address of current folder."/>
    <TEXT TYPE Action="0" Text="<ALT>d"/>
    <DELAY Flags="\x01" Time="0.1"/>
    <CLIPBOARD COPY/>
    <DELAY Flags="\x01" Time="0.1"/>
    <COMMENT/>
    <VARIABLE SET STRING Option="\x02" Destination="%tFolder%" NoEmbeddedVars="FALSE"/>
    <TEXT TYPE Action="0" Text="<ESC>" _COMMENT="Close edit mode"/>
    <DELAY Flags="\x01" Time="0.1"/>
    <COMMENT Value="Now re-assemble the original full filename and path."/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%tFullFilename%" Variable="%tFolder%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x06" Destination="%tFullFilename%" Value="\\" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%tFullFilename%" Variable="%tFilename%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x10" Destination="%tFullFilename%" NoEmbeddedVars="FALSE"/>
    <DELAY Flags="\x01" Time="0.1"/>
    <COMMENT Value="When testing or trouble-shooting it's helpful to show results at key stages, as in the following example. (Disable or delete this command when satisfied.)"/>
    <TEXT BOX DISPLAY Title="Result so far" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 tFilename = %tFilename%\r\n\\par \r\n\\par tFullFilename = %tFullFilename%\r\n\\par \r\n\\par \\f1 tFolder\\f0  = \\f1 %tFolder%\r\n\\par \r\n\\par }\r\n" Left="541" Top="485" Width="638" Height="188" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
    <COMMENT Value="Now allow user to choose the destination folder."/>
    <TEXT BOX DISPLAY Title="Choose destination folder" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red255\\green0\\blue0;}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Navigate to your destination folder by whatever means you prer and leave it active.\r\n\\par \r\n\\par \\cf1 Then\\cf0  click OK to close this message and continue.\\f1 \r\n\\par }\r\n" Left="677" Top="776" Width="435" Height="171" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
    <TEXT TYPE Action="0" Text="<ALT>d"/>
    <CLIPBOARD COPY/>
    <DELAY Flags="\x01" Time="0.1"/>
    <VARIABLE SET STRING Option="\x02" Destination="%tDestination%" NoEmbeddedVars="FALSE"/>
    <TEXT TYPE Action="0" Text="<ESC>" _COMMENT="Deselect folder box"/>
    <DELAY Flags="\x01" Time="0.2"/>
    <COPY FILE/FILES Source="%tFullFilename%" Dest="%tDestination%" Progress="FALSE" Recurse="FALSE"/>
    <COMMENT Value="You could now add  commands to return focus to the original folder if you wish. Or whatever. Such ad including the above in a Repeat loop to copy a SUCCESSION of files."/>

     

    Exported macro: Attached.

     

    Terry

     

     

    CopySelectedFileToAnotherFolder.mex 4.9 kB · 1 download

    Hi Terry,

     

    Thanks to your help I have now got everything working perfectly.

     

    Currently the macro only works for a single item. Could it be amended to also work if multiple files are selected?

     

    Regards

     

    Desmond

  4. On 10/18/2019 at 7:56 PM, terrypin said:

    Did you run my macro or your version of it?

     

    For example,  mine has a delay between the two lines you’ve shown:

    Text Type (Simulate Keystrokes): <ALT>d

    Clipboard Copy

     

    If you don’t succeed in getting it working, in your next post show us all your script and code.

     

     

    Hi terrypin,

     

    Sorry I missed this post.

    Yes I got the script working and growing in experience with the language.

     

    Thanks again for all your help

  5. Hi Cory,

     

    Sorry to be a pain.

     

    I am having a bit of trouble passing the value of two Variables in my my macro to the VBScript. It works fine when I hard code but not with the variables.

     

    I have two variables in my macro that needs to be passed to the VBscript

     

    %tFullFilename%

    %tDestination%

     

    I have read the information you suggested (below) but still do not fully understand. If I set  "%tDestination%" to %MacExpString% , how do I pass the second Variable %tFullFilename%

     

    Variable Set String %MacExpString% to "%tDestination%"

     

    And in the External Script must the Variable be called vbsString?

     

    Have you got and example code?
     

     

     

    To pass Macro Express Pro variables to your VB Script do this:

    In your macro use the Variable Set String command

    Variable Set String %MacExpString% to "Pass this to VBScript"


    Then include this line in the External Script command:

    vbsString = "%MacExpString%"
  6. 25 minutes ago, Cory said:

    When one copies something to the clipboard, the type of data is detected and it's stored in a spot for the type of data. So if you copy a graphic, then it's stored as bitmap data. In the case of a file in Explorer or a picture, there is nothing set in the text bucket of the clipboard. When MEP sets a text variable, it uses a method like Clipboard.GetText. And since File Explorer din't set ant text, you get nothing. Which is what you see in MEP. 

    This is the same for most apps. Copy a file in File Explorer and go into Notepad and paste. Notice there's nothing pasted. It's the same issue. 

    Depending on what you're trying to do, there are many different methods to get the file name. But they're too numerous to enumerate. If I knew more about what you are doing, I could make some suggestions. 

    Thanks Cory Understand fully

  7. 12 minutes ago, Cory said:

    I recommend using code boxes when posting code. Also a small sample file helps us. Might get you more answers quicker the easier you make it for others.

     

    It works for me. If you're trying to copy a file object in Windows File Explorer, this will not work. If that's not what you're trying to do, what is it that you're copying? 

    That Exactly what I am trying. Can you explain why it will not work?

    The clipboard copies this

    C:\Desmond Music\Music Library 2018\000 Music Selected To Play WhatsApp Group\Bad Tunes\02 - Brethren & Sistren.mp3

     

  8. I cannot for the life of me see why this simple code does not work?

     

    The Clipboard Copy works but for some reason the Variable Set String does not

     

    Clipboard Copy
    Delay: 1 seconds
    Variable Set String %tFilename% from the clipboard contents
    MessageBox: Test
     

    Or

     

    <CLIPBOARD COPY/>
    <DELAY Flags="\x01" Time="1"/>
    <VARIABLE SET STRING Option="\x02" Destination="%tFilename%" NoEmbeddedVars="FALSE"/>
    <MESSAGEBOX Caption="Test" Message="%tFilename%" Icon="0"/>
     

     

    I seem to make good progress and then something simple baffles me.

  9. Hi

     

    I am toying with the idea of calling a VBScript to handle Copying and Writing to a text file as it appears to be more robust.

     

    If I needed to pass the full path name and receive back conformation of Successful run, How this could be done?

     

    Thanks for any advise

     

    This is the basic code I am proposing to call

     

    How would pass the replace the Copyfile hard coded values with variables 

     

    File to be copied

    C:\Desmond Music\Music Library 2018\000 Music Selected To Play WhatsApp Group\BB Seaton\05 - BB Seaton - Thin Line Between Love & Hate.mp3

    Folder to copy to

    C:\Desmond Music\New Music Library 2018\Jazz\

     

    Option Explicit
    Dim fso
    Dim fso1
    Dim filename   
     
    vbsString = "%MacExpString%"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fso1 = CreateObject("Scripting.FileSystemObject")
    Set filename = fso1.OpenTextFile("C:\Users\desmo\Desktop\Audit Trail.txt", 8)
     
    'To Copy a file
    fso.CopyFile "C:\Desmond Music\Music Library 2018\000 Music Selected To Play WhatsApp Group\BB Seaton\05 - BB Seaton - Thin Line Between Love & Hate.mp3", "C:\Desmond Music\New Music Library 2018\Jazz\"
    
    filename.WriteLine "C:\Desmond Music\New Music Library 2018\Jazz\"
    filename.Close

     

  10. Hi Terrypin,

     

    Thanks for all your time.

     

    I have run your script and it appears to have an issue in these lines.

     

    Text Type (Simulate Keystrokes): <ALT>d

    Clipboard Copy
     

    When I debug it %Destination% has  the Value  "Name Value" in it.

     

    What's very strange is that when I perform the task manually it copies the correct folder path to the clipboard

     

    C:\Desmond Music\New Music Library 2018\Jazz

     

    See debug info below

     

     

    Debug.JPG.151617d2fb25229b8653c950dc1204ed.JPG

     

     

     

  11. Hi There,

     

    I am looking for help to put together a macro that can do the following.

     

    I will have a Windows 10  File Explorer Windows open and have selected various files (these files will be the result of a search, so will be located in different Folders)

     

    So maybe Copying them to the Clipboard

     

    1.  The Macro will display a list of predefined Target Directories.

    2.  On clicking on one of the them it will move the file/files (details of which will be in the clipboard) to the selected  Directory.

     

    I have spent a great deal of time trying to get this to work and to be honest given up. This is a last ditch effort to be pointed in the right direction

     

    Below is my attempt at writing the macro

     

    Any help will be most appreciated.
     

    <CLIPBOARD COPY/>
    <COMMENT Value="Extract the FILENAME from full path & filename."/>
    <VARIABLE SET STRING Option="\x02" Destination="%Input%" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET INTEGER Option="\x0D" Destination="%Length%" Text_Variable="%Input%"/>
    <REPEAT START Start="%Length%" Step="-1" Count="%Length%" Save="TRUE" Variable="%Index%"/>
    <VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="%Index%" Count="1" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x07" Destination="%Output%" Variable="%Char%" NoEmbeddedVars="FALSE"/>
    <END REPEAT/>
    <VARIABLE SET INTEGER Option="\x0E" Destination="%nPosReversed%" Text_Variable="%Output%" Text="\\" Ignore_Case="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x01" Destination="%nPos%" Value1="%Length%" Value2="%nPosReversed%"/>
    <VARIABLE MODIFY INTEGER Option="\x07" Destination="%nPos%"/>
    <VARIABLE MODIFY STRING Option="\x0A" Destination="%Input%" Start="1" Count="%nPos%"/>
    <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Input%\r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE" _COMMENT="Disable this when satisfied."/>
    <COMMENT Value="Proceed with rest of macro."/>
    <OPEN FOLDER Path="C:\\Users\\desmo\\Desktop\\Music Library 2018\\Favourite"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T4%" Value="C:\\Users\\desmo\\Desktop\\Music Library 2018\\Favourite\\" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T4%" Value="%T4%%Input%" NoEmbeddedVars="FALSE"/>
    <WAIT FOR WINDOW TITLE Title="Favourite" Partial="FALSE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="20"/>
    <CLIPBOARD PASTE/>
    <DELAY Flags="\x01" Time="1"/>
    <WINDOW CLOSE Option="\x01" Title="Favourite" Partial="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
    <DATE/TIME Format="dd/MM/yyyy HH:MM" Flags="\xB0" Date="25/12/2018 22:29:25" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%T3%" IsDateVar="FALSE"/>
    <VARIABLE SET STRING Option="\x02" Destination="%T1%" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T2%" Value="   - Moved to Favourite" NoEmbeddedVars="FALSE"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T1%" Value="%T1%  %T2% %T3%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x10" Destination="%T1%" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x00" Destination="%T4%"/>
    <IF FILE EXISTS File="%T4%" Search_Path="FALSE"/>
    <CLIPBOARD APPEND TEXT Filename="C:\\Users\\desmo\\Desktop\\Music Sorting Log.txt" Prompt="FALSE"/>
    <TEXT BOX DISPLAY Title="File Copied Sucessfully" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 File has been moved to \\b Favourite \\b0 Folder\\b  \r\n\\par \\b0\\f1\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x01" Delay="3"/>
    <DELAY Flags="\x01" Time="3"/>
    <ELSE/>
    <TEXT BOX DISPLAY Title="File Copy Failed" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 The file copy \\b Failed \\b0 please check and retry\\b \r\n\\par \\b0\\f1\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x01" Delay="3"/>
    <DELAY Flags="\x01" Time="3"/>
    <END IF/>
    
    

     

×
×
  • Create New...