Wanted: Sample scripts to cannibalize

Page 5 of 6 FirstFirst ... 3456 LastLast

  1. Posts : 720
    Win10 x64 Pro - 2 desktops, 2 laptops
    Thread Starter
       #41

    LesFerch said:
    Here you go: Attachment 354636
    Thank you. I've tried those, got errors, and having trouble posting my description. I'm getting a "Blocked" message from the forum. I'm guessing it's my trying to include screen captures of error popups (although I don't think I've had trouble before). I'll keep trying.

    Update: This is really weird. I tried replacing screen capture images with text. I tried removing wrappers from around script statements. Everything else was just plain text. When I click Submit I get one of two odd conditions
    • Sometimes I get a popup asking me to confirm I want to leave the forum page. When I confirm, I'm taken to page saying I'm blocked from the forum,
    • Other times I'm taken to a different page saying I'm blocked from the forum

    On the other hand, I was able to post this reply, and I suspect this update will succeed.

    I think I will try submitting a few line of my intended reply and repeatedly update until I find the offending data. Don't bother reading the reply if you don't see something at the bottom saying the posting is complete.

    - - - Updated - - -

    LesFerch said:
    Here you go:
    In the HTA version I get error
    Wanted: Sample scripts to cannibalize-script-error.png
    The referenced line is
    Code:
    <input type=file id=f1 accept=".m3u" style=width:40em oninput=ProcessFile()>
    I assume that means there is something wrong in ProcessFile. The closest match I could find on the web had to do with the content specification in
    Code:
    <meta charset="UTF-8" http-equiv="X-UA-Compatible" content="IE=10">
    I'm not sure how to do with this. The computer where this script will usually be run is a very old Win7 laptop (with no network connectivity). It may occasionally be run on a couple other Win7 laptops - a backup and a loaner. I have no control over that; that's the target configuration I'm designing this for. And I usually have no access to those laptops so I'm developing this on my Win10 desktop.

    BTW, this is the same kind of error I was getting when I tried putting my script in HTA. (I can guarantee the error code was the same, but it was on the <input /> statement.)

    In the FileDialog version I get a " Path not found" error on statement 25 (which I'm sure I can debug on my own). Trying to include either the error popup or the statement seems to get me blocked from the forum so this is all I'm going to say.

    This posting is now complete.
    Last edited by pokeefe0001; 12 Dec 2021 at 15:40.
      My Computer


  2. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #42

    Pokee,

    When you are chasing script errors, always check
    Windows security [aka WD, aka Microsoft Defender],
    Virus & threat protection,
    Protection history
    just in case it has blocked access / quarantined something.

    All the best,
    Denis
      My Computer


  3. Posts : 720
    Win10 x64 Pro - 2 desktops, 2 laptops
    Thread Starter
       #43

    @LesFerch, I'm trying to debug the hta version and have immediately run into my ignorance. In your earlier samples you have
    Code:
    Sub window_onload
      document.title = "... whatever ..."
        x = 600
        y = 400
        Window.ResizeTo x, y
        Window.MoveTo (screen.availWidth - x)/2, (screen.availHeight - y)/2
    End Sub
    but don't explicitly invoke that subroutine (that I could see). Does window_onload get invoked automatically?

    In HTAVersion.hta you have that code - and a bunch more - in the main hta script. Is there any effective difference? You still have the windows_onload subroutine, but it contains only a comment.

    I suspect this is the first of many questions as I go through this. I intend to add your code in chunks to my test hta until my test fails. I don't know any other way to pinpoint the source of the error.

    - - - Updated - - -

    I found an error in the script, but it was a logic error, not something that upsets mshta (or whatever was throwing the error).

    In your code you have
    Code:
    ' Determine script path and set it as the current directory
    MyPath = oFSO.GetParentFolderName(Mid(document.url,8))
    oWSH.CurrentDirectory = MyPath
    
    ' Determine the path of the grandparent folder of this script.
    ' That folder will also contain the SBD Library and the MediaMonkey folder.
    pathname = oFSO.GetParentFolderName(oFSO.GetParentFolderName(MyPath))
    You already put the script's parent directory in MyPath so its grandparent would be
    Code:
    pathname = oFSO.GetParentFolderName(MyPath)
    Update:
    Hah! That pathname problem was the cause of the error. The error occurred in
    Code:
    ' Invoke MediaMonkey with an Add parameter pointing to the newly modified playlist.
      MMpath = pathname & "\MediaMonkey\MediaMonkey"
      MMarg = "/ADD " & OutFile
      oShell.ShellExecute  MMpath , MMarg
    when no \MediaMonkey directory was in pathname.

    Thank you for your help. The function is now essentially done. I still need to handle playlists containing comments - either ignore the comments or copy them unchanged. I also need to see if I can invoke the function from within MediaMonkey. That's not necessary, but will simplify documentation.
    Last edited by pokeefe0001; 12 Dec 2021 at 18:04.
      My Computer


  4. Posts : 745
    Windows 10/11
       #44

    pokeefe0001 said:
    I'm getting a "Blocked" message from the forum. I'm guessing it's my trying to include screen captures of error popups (although I don't think I've had trouble before). I'll keep trying.
    The block occurred for me when I tried to paste the HTA code with Code tags. I think it doesn't like seeing HTML code unless it's in HTML tags. And I assume HTML tags cause the page to try to render that code, so HTML tags would not be useful for posting HTA code. The same issue is probably causing the block for you. It looks like we have to use zip attachments or post a link to another site (like I did for the sample code on my GitHub page).

    pokeefe0001 said:
    In the HTA version I get error
    Wanted: Sample scripts to cannibalize-script-error.png
    The computer where this script will usually be run is a very old Win7 laptop (with no network connectivity). It may occasionally be run on a couple other Win7 laptops - a backup and a loaner. I have no control over that; that's the target configuration I'm designing this for. And I usually have no access to those laptops so I'm developing this on my Win10 desktop.
    Did you get the error when running on the old Win7 laptop or when running on the Win10 machine? I ask because I suspect the issue is that the IE version is less then 10 and the HTA is calling for IE=10. Please note that HTAs do not use IE, but do use the same HTML rendering engine as IE. Therefore, if IE is out of date, the rendering engine is out of date. If that's indeed the issue, I have to wonder if the test machine properly represents the target machine. Any Windows 7 machine still in use should already be updated to IE 11, as that came out 8 years ago. I know if you build a test Windows 7 machine from ISO, it starts off with an old version of IE (maybe 9?) and you have to spend about a whole day applying updates to bring it to the state of a typical Windows 7 machine in production. Anyhow, the IE10 requirement is for the accept option in the file input which restricts the files shown to m3u files. If you change the compatibility line from IE=10 to IE=9 and remove the accept option (as in the first HTA example I posted) I think it will work. I only have test machines with IE 11 installed, so I can't verify this issue easily.

    pokeefe0001 said:
    You already put the script's parent directory in MyPath so its grandparent would be
    Code:
    pathname = oFSO.GetParentFolderName(MyPath)
    Yes, I did go up one too many levels. I got misled by seeing "grandparent" in the comment. What you really wanted (and now have) is the parent folder of the script's directory, not the grandparent. Parent folder is defined as: "A folder that is one level up from the current directory in a file hierarchy".

    The confusion comes from:

    HTA version:
    Code:
    MyPath = oFSO.GetParentFolderName(Mid(document.url,8))
    VBS version:
    Code:
    MyPath = oFSO.GetParentFolderName(WScript.ScriptFullName)
    Both of the above return the script's path, not the script's path's parent, yet they call GetParentFolderName because the parent of a path that contains a filename (script filename in this case) is the folder where that script resides.

    pokeefe0001 said:
    Does window_onload get invoked automatically?
    Yes, window_onload gets invoked automatically once the HTML code in the HTA has been rendered.

    pokeefe0001 said:
    In HTAVersion.hta you have that code - and a bunch more - in the main hta script. Is there any effective difference? You still have the windows_onload subroutine, but it contains only a comment.
    I originally put the code to resize and center the window in that sub, but realized that was unnecessary. The window exists before the HTML code is rendered, so that code can just go in the main section. I left the window_onload sub in place just for instructional purposes. You can delete that sub. There is also a sub that is automatically invoked when the page is unloaded (i.e. on exit). It's named window_onunload.

    The "bunch more" code is all code you had in your sub (other than the line to set the current directory) but makes more sense to put in the main section (i.e. stuff that would not need to be repeated in the sub if the sub were to be called again).

    pokeefe0001 said:
    The function is now essentially done.
    Are you going with the HTA version or the version that uses FileDialog.exe? The former is a tidy single HTA file, but produces a file dialog with the title "Choose File to Upload" which may be confusing, whereas you can set the file dialog title to anything you like using the exe.

    I'm guessing you must have chose the filedialog.exe version because I didn't see that you resolved the 8070000b error.
    Last edited by LesFerch; 13 Dec 2021 at 04:26.
      My Computer


  5. Posts : 720
    Win10 x64 Pro - 2 desktops, 2 laptops
    Thread Starter
       #45

    LesFerch said:
    Did you get the error when running on the old Win7 laptop or when running on the Win10 machine? I ask because I suspect the issue is that the IE version is less then 10 and the HTA is calling for IE=10. Please note that HTAs do not use IE, but do use the same HTML rendering engine as IE. Therefore, if IE is out of date, the rendering engine is out of date.
    I'm not going to have access to th Win7 laptop until this coming weekend. The error I got had nothing to do with the compatibility level. (I may run into those errors when I try it on Win7.) But I'm currently running HTA code with "IE=9" so I'm hoping I'll be OK.

    The error happened with
    Code:
    MMpath = pathname & "\MediaMonkey\MediaMonkey"
         MMarg = "/ADD " & OutFile
         oShell.ShellExecute  MMpath , MMarg
    when MMpath did not contain the \MediaMonkey directory.


    LesFerch said:
    ..., the IE10 requirement is for the accept option in the file input which restricts the files shown to m3u files. If you change the compatibility line from IE=10 to IE=9 and remove the accept option (as in the first HTA example I posted) I think it will work. I only have test machines with IE 11 installed, so I can't verify this issue easily.
    I used your original, unupdated HTA sample as my model. It already had IE=9 and no accept.
    LesFerch said:
    Yes, I did go up one too many levels. I got misled by seeing "grandparent" in the comment. What you really wanted (and now have) is the parent folder of the script's directory, not the grandparent. Parent folder is defined as: "A folder that is one level up from the current directory in a file hierarchy".
    When I said "grandfather" I was speaking in reference to the script itself. At the time I was running
    D:\MMV4\Utilities\ImportSBDM3U.hta and wanted to point to MMV4.

    After getting this function working I realized it would be better to invoke it from within MediaMonkey. To achieve that the script would have to live in
    D:\MMV4\MediaMonkey\Scripts
    so I changed the script to deal with either scenario.
    LesFerch said:
    Are you going with the HTA version or the version that uses FileDialog.exe? The former is a tidy single HTA file, but produces a file dialog with the title "Choose File to Upload" which may be confusing, whereas you can set the file dialog title to anything you like using the exe.
    As you can tell from my earlier comments, I'm using the HTA solution. And wherever "Choose File to Upload" may have originally been, it's not there now. I've got a bit of cleanup to do but all is working well.

    Thank you for your help.
      My Computer


  6. Posts : 745
    Windows 10/11
       #46

    pokeefe0001 said:
    I used your original, unupdated HTA sample as my model. It already had IE=9 and no accept.
    I'm very curious to know if the IE=10 mode with accept works correctly for you. Wouldn't it be best to limit the file choices in the dialog to m3u files? If so, in your current script, just change IE=9 to IE=10 and add the accept code back in the input=file line. It should work fine.

    pokeefe0001 said:
    wherever "Choose File to Upload" may have originally been, it's not there now. I've got a bit of cleanup to do but all is working well.
    It can't be gone. It's in the title bar of the open file dialog (not the HTA window) and cannot be changed in an HTA (or any web page). With filedialog.exe, you can change that text

    pokeefe0001 said:
    Thank you for your help.
    My pleasure!
    Last edited by LesFerch; 14 Dec 2021 at 22:30.
      My Computer


  7. Posts : 720
    Win10 x64 Pro - 2 desktops, 2 laptops
    Thread Starter
       #47

    LesFerch said:
    I'm very curious to know if the IE=10 mode with accept works correctly for you. Wouldn't it be best to limit the file choices in the dialog to m3u files? If so, in your current script, just change IE=9 to IE=10 and add the accept code back in the input=file line. It should work fine.
    I won't have a chance to test this on the Win7 laptop until this weekend. Limiting the input to m3u and m3u8 files is a good idea. I should probably put in an edit if the accept doesn't work in the Win7 system.

    I now see the "Choose File to Upload" line. I don't think it's too obtrusive or misleading, but I'll consider using Filedialog.exe in my next version.

    Update:
    I don't know why I had included two identical screen shots in this post but I've deleted them.

    I decided that limiting input files to m3u and m3u8 would be a bad idea. I've changed the script to allow M3U, M3U8, XSPF, WPL, and SPL formatted playlists (all in the same file if the user feels like being difficult). I haven't yet tried either the IE=10 HTA or the Filedialog versions of the script on Win7 yet and may not get to it for a while. The IE=9 version works fine on Win7.
    Last edited by pokeefe0001; 19 Dec 2021 at 22:14.
      My Computer


  8. Posts : 745
    Windows 10/11
       #48

    Try3 said:
    I've written a pair of batch files containing the code that I will copy to individual operational batch scripts that need Folder or File dialogs... I've zipped them up along with the current version of FileDialog.exe [which is common to both batch scripts].
    I've updated FileDialog with a few changes:
    • Targeted to .Net 4.x instead of .Net 3.5 because 3.5 is NOT installed by default, whereas 4.x is.
    • Multi-select is now OFF by default and is turned on with the Multi argument
    • The dialog title must now always be prefixed with ~ on the command line. This fixes an issue where an invalid path would fall through to become the dialog title.
      My Computer


  9. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #49

    Les,

    Thanks for letting me know. I've downloaded a copy of the latest version.

    I have so little free time these days that I don't know when I'll be able to make use of it. Looking at my mountain of notes, it will probably take me a day or two just to get back to the level I was at last year / the year before.

    All the best,
    Denis
      My Computer


  10. Posts : 745
    Windows 10/11
       #50

    Try3 said:
    Thanks for letting me know. I've downloaded a copy of the latest version.
    I updated it again with support for environment variables and a Retro parameter to use the old-school dialogs. File it away for a time when you're not so busy.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 09:15.
Find Us




Windows 10 Forums