dcsimg
Results 1 to 40 of 40

Thread: Emulate Double Click

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Emulate Double Click

    I have these media files and when I double click on any one of them it will launch the appropriate media application to play it so how can I emulate this double click from my program. My program will display a list of all the files and when I click on one of the names in the listbox I want to also double click on the actual file so it will bring up the application to play it

    Is there a another way which might be a better way to do this

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,199

    Re: Emulate Double Click

    I think you want to use ShellExecute. https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
    Beat me to it. Plus my link is to a C++ page anyway, so follow DataMiser's link.
    Last edited by passel; Aug 18th, 2016 at 11:17 AM.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    I'm not sure that is what I am looking for. First, my program wont know what application to shell and second my program won't know how to pass the path of the file to the shelled application. I looking for a way to emulate the effects of double clicking on the file itself so it will launch the app instead of my program shelling it and then having to pass to it the path of the file. The application that will be launched can change from one time to another and it can be different from one PC to another. It will depend on what application users will use to play these files; it would be whatever they choose.
    Last edited by On Error Try Again; Aug 18th, 2016 at 11:59 AM.

  5. #5
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Emulate Double Click

    you pass the path of the file to shell execute, and the shell takes care of the "DoubleClick"


  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    ShellExecute is what you want. It will use the default application associated with the file extension to open the selected file. You will however need the full path to the file you are intending to launch. Since you are adding the files to a listbox, it sounds like you should also be able to access the file path.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Here's an example of what I mean

    On my PC all I have to do is this:

    Shell "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe D:\DVD Movies\Dark Country" and it plays the video

    but on my friend's PC the above won't work and he doesn't have Nero anyway and he uses WMP so I changed the above line to this:

    Shell "C:\Program Files\Windows Media Player\wmplayer.exe D:\DVD Movies\Dark Country"

    but that didn't work so I changed it again to this:

    Shell "C:\Program Files\Windows Media Player\wmplayer.exe D:\DVD Movies\Dark Country\VIDEO_TS.IFO"

    and that didn't work either but if I double click on VIDEO_TS.IFO it will launch WMP and play the video

    Now, on someone else's PC it may not be either Nero nor WMP; it could be some other application that I'm not aware of. So the problem I'm having is knowing what to shell and then like with WMP it may or may not even work doing it using shell but it always works by double clicking on the file
    Last edited by On Error Try Again; Aug 18th, 2016 at 12:54 PM.

  8. #8
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    That's why people are suggesting ShellExecute instead of Shell.
    Code:
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) As Long
    
    Const SW_SHOW = 5
    
    Private Sub Command1_Click()
    Dim strPath As String
        
        strPath = "D:\DVD Movies\Dark Country\VIDEO_TS.IFO"
        ShellExecute Me.hwnd, "open", strPath, vbNullString, vbNullString, SW_SHOW
    End Sub

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    OK, if I do what you are suggesting:

    Dim strPath As String

    strPath = "D:\DVD Movies\Dark Country\VIDEO_TS.IFO"
    ShellExecute Me.hwnd, "open", strPath, vbNullString, vbNullString, SW_SHOW

    it doesn't do anything so I changed it to the same as I used with the Shell

    Dim strPath As String

    strPath = "D:\DVD Movies\Dark Country"
    ShellExecute Me.hwnd, "open", strPath, vbNullString, vbNullString, SW_SHOW

    and that doesn't work either but this does:

    Shell "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe D:\DVD Movies\Dark Country"

    notice that I only need the name of the folder, 'Dark Country', and not the file name, 'VIDEO_TS.IFO', even though it is 'VIDEO_TS.IFO' that I have to double click on I don't need it in the code. This seems to only work with Nero and not WMP
    so I'm still at a lost.

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

    Re: Emulate Double Click

    IFO ?

    What happens when you double click on an ifo file in explorer? The same should happen using shellexecute.
    I rarely play dvd images but I think media player wants you to open the vob file?

  11. #11
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    There must be some details we aren't getting here. If you can double click on the VIDEO_TS.IFO in windows explorer and it opens and "D:\DVD Movies\Dark Country\VIDEO_TS.IFO" is the proper full path then ShellExecute should work. What does this message box say if you run this code.
    Code:
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) As Long
    
    Const SW_SHOW = 5
    
    Private Sub Command1_Click()
    Dim strPath As String
    Dim ret As Long
        
        strPath = "D:\DVD Movies\Dark Country\VIDEO_TS.IFO"
        ret = ShellExecute(Me.hwnd, "open", strPath, vbNullString, vbNullString, SW_SHOW)
        
        MsgBox ret
    End Sub

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    I get 31 and nothing else happens. Clicking on a VOB file only gets you what is on that file so it wont be the entire video so that is why I click on IFO which tells the media player all the other files needed.

  13. #13
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    The ShellExecute() function returns the value 31 if there is no association for the specified file type. With that I find it hard to believe that on the machine where you are having this issue that double clicking VIDEO_TS.IFO in windows explorer will launch it.

  14. #14
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    On Error,

    Yes, it appears the lack of a file association is your problem. Also, just a couple of other FYI pointers.

    I typically use zero (rather than one of my own form handles) for the first parameter. This causes the program to be executed without being associated with my program, but that's a personal preference (possibly situation dependent).

    I typically, use SW_SHOWNORMAL (rather than SW_SHOW) for the last parameter. That way, if the program is already open but possibly hidden, minimized, or maybe drug off the screen, the SW_SHOWNORMAL (Const SW_SHOWNORMAL = 1) will fix that.

    Also, if you wanted, you could actually build your strPath to have the full program-path-program-name and also the file-path-file name such that you'd be assured you'd find the program to open the data file. Done this way, the internal Shell command will probably get it done though. If you do use this approach, it's typically a good idea to surround the program filespec in quotes, and then the data filespec separately in quotes. Also, this has the downside of requiring that the program always be found in the same spot. An upside is that you circumvent any need for file associations.

    I use ShellExecute all over the place, and find it to be a bulletproof and fantastic API function.

    Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    When I installed Nero on my machine it automatically associated itself with all the video file types (.IFO, .VOB, .BUP). If I double click on any .VOB file Nero is launched and it will play only the video data contained in that particular VOB file. If I click on any .IFO file Nero is launched and it will play the entire video from start to finish. Now, when I run my program and I use Shell I cannot include the .IFO file as part of the parameter input string as it will cause Nero to be launched but Nero will not play the video but if I omit the .IFO file name and only include the path to the video as I pointed out in my post #9 it will then play the entire video.

    Now, this only works on my machine. On my friend's machine I have to Shell Wmplayer.exe + the path and name of the video I want to play but it doesn't work anyway. When I double click on the .IFO file in his directory it will launch WMP and play the video.

    This is all very strange since if I go to the directory I have to double click on the .IFO file but in my code I cannot include it in the path using Shell.

    I get nowhere using ShellExecute no matter what I do on my machine and on my friend's machine as well. Only Shell works but only for Nero on my machine. On my friend's machine nothing works from the program; I have to double click the .IFO file to get it to play

    So this is the reason I asked if there is a way to automate double clicking and not use any Shell at all

    I cannot install Nero on my friend's machine because I have a proprietary version of Nero that came with the Sony DVD player I installed on my machine and it wont work if you dont have that Sony player
    Last edited by On Error Try Again; Aug 18th, 2016 at 02:56 PM.

  16. #16
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: Emulate Double Click

    Quote Originally Posted by LaVolpe View Post
    In some projects of mine, I use ShellExecute to try to open a file with registered association, if any. If that API fails, then I launch an "Open With" dialog via run32dll.
    On Error Try Again

    You might want to consider using fafalone's "implementation" of the SHOpenWithDialog (Vista+) API function: [VB6] API Open With Dialog with enhanced functionality


    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  17. #17
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    You know?

    It dawns on me that some programs --- and, in particular, some media players --- create their own lpOperation verb, rather than having a default of "Open".

    Try replacing the "Open" with a 0& (which would just be a null string). In such a case, Windows will attempt to identify a default verb, using that to open the file.

    Quote from MSDN:
    lpOperation [in, optional]
    Type: LPCTSTR
    A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. The following verbs are commonly used:
    • edit - Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
    • explore - Explores a folder specified by lpFile.
    • find - Initiates a search beginning in the directory specified by lpDirectory.
    • open - Opens the item specified by the lpFile parameter. The item can be a file or folder.
    • print - Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
    • NULL - The default verb is used, if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.
    IMHO, the ShellExecute basically IS a double-click, if used in this way. To actually emulate a double-click, what are you going to do? Open a copy of Windows Explorer, somehow navigate to your file, somehow select your file, and then spoof a double-click on the keyboard? ShellExecute is the way to do it.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    BINGO! That made it work - Thanks a million Elroy the 0& did it

  19. #19
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Emulate Double Click

    I think you figured it out Elroy. Nero probably doesn't use the "open" verb, so might as well pass vbNullString as lpOperation.

  20. #20
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    Something else that comes to mind. Is there possibly Unicode in your media file name and/or in part of your path/folder name? From what you've said above, that does not appear to be the case. However, there is a ShellExecuteW that could be used in these cases, along with StrPtr to pass in Unicode strings.

    I'm just really taking pot-shots though. It appears that Bonnie may have found a good idea to try if nothing else works.

    Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    hahaha, my gears are still turning, and you got it.

    I'm glad, OnError.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Well, one problem solved another one created

    It appears when I use Shell or ShellExecute, Nero comes up and plays the same video over again even though I pass it a different name.

    Here's what I did

    1) Select 'Dark Country' from the listbox. Nero launches and plays 'Dark Country' as expected
    2) Later I select 'Gladiator' and again Nero launches and play 'Dark Country' again
    3) Select another title and again Nero launches and plays 'Dark Country' again

    I know for sure I am always passing a new title in the string but always 'Dark Country' plays

    However, if I go the the folders and double click on a different title (it's .IFO file) Nero will play the new video but when I return to my program later and select any title Nero still plays 'Dark Country'. I can't seem to get out of this problem.

    Is it possible that somehow using Shell the 'Dark Country' title is still being passed to Nero regardless of which title I select

  23. #23
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    Using either MsgBox or Debug.Print, show yourself the filespec (path and name) that's being passed into ShellExecute. And do this immediately before the ShellExecute line.

    This is just to convince yourself that the correct filespec is being passed in. Also, double-check these filespecs for both the name and path. I don't really use Nero, but maybe, if it can't find the file you specified, it just plays the last file.

    Again, just pot-shots.

    Elroy

    EDIT1: Also, are you completely closing Nero between each song/movie? If not, maybe it's just adding the song/movie to it's queue (or playlist, of whatever it's called).
    Last edited by Elroy; Aug 18th, 2016 at 06:31 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  24. #24

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Even if I reboot the PC it still plays 'Dark Country'

    Yes, I am absolutely positive I am passing the correct path and file name

    If I rename the folder Dark Country to X Dark Country and even if I pass Nero and different title it complains that there is not a valid video file so it appears that no matter what path and title I pass it always goes back to d:\dvd movies\dark country. I scanned the registry and no where is the name Dark Country found and I even renamed the title in Nero's bookmark file from Dark Country (which is the only place I was able to find the title) to Gladiator it still play Dark Country

    Yet, if I double click on the file d:\dvd movies\gladiator\video_ts.ifo it will then and only then play Gladiator but if I go back to ny program and use shell again then it goes back and plays 'Dark Country' so this tell me that double clicking on the file is not the same as using Shell to do the double clicking for me

    BTW: The command is Play, not Open
    Last edited by On Error Try Again; Aug 18th, 2016 at 06:38 PM.

  25. #25
    Lively Member
    Join Date
    Apr 2015
    Posts
    120

    Re: Emulate Double Click

    Did you try VLC ? It can play .IFOs and its free and (IMHO) the best.

  26. #26
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    Hmmm, maybe try what Bonnie suggested, or learn to be a daily fan of Dark Country. GTG though. I do hope you get it sorted.

    And yeah, I sort of suspected the verb was "play" but it's also almost certainly marked as the default.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  27. #27
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    Actually, yes. I've wrapped the smplayer/mplayer into my app for years, but I control where that program is and how it plays my video clips, specifying the smplayer.exe in ShellExecute when I run it. I also like VLC though and have considered switching.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  28. #28

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    OK, I found a way around this problem. In my program....

    Code:
       '
       '
    Dim MovieName As String
       '
       '
    Private Sub List1_DblClick()
     MovieName = List1.List(List1.ListIndex)
    
     Open App.Path & "\RunNero.bat" For Output As #1
    
     Print #1, Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & Chr(34) & " " & Chr(34) & "D:\DVD Movies\" & MovieName & Chr(34)
    
     Close #1
    
     Shell App.Path & "\RunNero.bat"
    End Sub
       '
       '
    works every time with different video names

  29. #29
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

    Re: Emulate Double Click

    You could have did that with a shell command as well by simply passing the program path and name along with the file path and name.
    That of course is not what you indicated you wanted to do in the OP where you stated that you wanted to simulate a double click which of course would mean shellexecute

    The difference is in the one case you tell it which program to use and in the other it works with any file that has an association registered.
    If you selected a word doc it would open word, an AVI would open WMP or Showtime depending on your config, .vbp would open VB and so on

  30. #30
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    Say OnError. Elroy again. I'm back for a bit.

    If you're so inclined, maybe start a new thread with the problem you're having now, so people don't get confused. You could probably copy-paste most of your post #22 to get it started.

    It's also totally puzzling to me as to why that didn't work with ShellExecute. Also, just FYI, that's a well formatted string you're constructing for the batch file.

    Code:
    Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & Chr(34) & " " & Chr(34) & "D:\DVD Movies\" & MovieName & Chr(34)
    It's totally strange to me that you can't do something like the following:

    Code:
    
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Dim MovieName As String
       '
       '
    Private Sub List1_DblClick()
    
        Dim sShellLine As String
    
        MovieName = List1.List(List1.ListIndex)
    
        ' The following string is copy-pasted directly from your post #28. 
        sShellLine = Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & Chr(34) & " " & Chr(34) & "D:\DVD Movies\" & MovieName & Chr(34)
    
        ShellExecute 0&, 0&, sShellLine, 0&, 0&, vbNormalFocus
    
    End Sub
    
    I certainly believe that you're having problems, but it just seems that the ShellExecute would do the same thing, and much more efficiently.

    Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Nope, doesn't work, same as previous attempts but this time I get return code 2

  32. #32
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    ERROR_FILE_NOT_FOUND

    Here are all the error codes returned by ShellExecute.

    Can you tell me more about what D: is? Is this a file server or possibly a NAS box? If so, there may be some funny parsing going on. You may need to replace all your single "\" with double "\\".

    For instance:


    Code:
    
        sShellLine = Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & _
                          Chr(34) & " " & Chr(34) & _
                          "D:\\DVD Movies\\" & MovieName & Chr(34)
    
    I'm not sure why, but the ShellExecute isn't finding the file-specification you're passing it.

    Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  33. #33

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Nope, same problem, file not found, but it still works if I shell a bat file

    Also I made a change:

    I made a copy of D:\DVD Movies to C:\DVD Movies

    sShellLine = Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & Chr(34) & " " & Chr(34) & "C:\DVD Movies\" & MovieName & Chr(34)

    and it still doesn't work

    I made copies of my program on all my drives including C and it always returns a 2 but in all cases it works if I shell the bat file
    Last edited by On Error Try Again; Aug 19th, 2016 at 11:44 AM.

  34. #34
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,552

    Re: Emulate Double Click

    WOW, truly puzzling.

    I'm almost tempted to install a copy of Nero and see it myself, but I'm not quite ready to go that far. Maybe others will jump in with some fresh ideas.

    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  35. #35
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

    Re: Emulate Double Click

    I just tested using the following code
    Code:
        Option Explicit
    
        Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) As Long
         
        Private Const SW_SHOWNORMAL = 1
         
        Private Sub Command1_Click()
            ShellExecute Me.hwnd, vbNullString, """F:\Movies\16 Blocks\VIDEO_TS\VIDEO_TS.IFO""", vbNullString, "C:\", SW_SHOWNORMAL
        End Sub
    
    
        Private Sub Command2_Click()
            ShellExecute Me.hwnd, vbNullString, """F:\Movies\Comedy\Used Cars\VIDEO_TS\VIDEO_TS.IFO""", vbNullString, "C:\", SW_SHOWNORMAL
        End Sub
    By default ifo files open with Nero Showtime on my system.

    The code works exactly as expected. Button1 launches Showtime and starts the movie 16 blocks, button2 launches showtime and starts the movie used cars.

    If I click on the file in explorer and tell it to always open with Media Player then that same code launches media player and starts the correct movie.

    I see no issue at all, shellexecute works as expected and launches whatever program is associated with the file type in question.
    It does exactly the same thing as if I double click on the file in windows explorer

  36. #36
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    """F:\Movies\16 Blocks\VIDEO_TS\VIDEO_TS.IFO"""

    Do you really need to warp this in quotes. Would this work

    "F:\Movies\16 Blocks\VIDEO_TS\VIDEO_TS.IFO"

    Either way, I have to believe that when On Error is calling ShellExecute a second time he isn't passing the path he thinks he is. A little code showing how you're attempting that could help resolve the issue.

  37. #37
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

    Re: Emulate Double Click

    I do not know for sure if the quotes are required but there is a space in the path so just covering my bases

    Edit: Yes the quotes are required. I tried it again without them and showtime opens but no movie is loaded
    Last edited by DataMiser; Aug 19th, 2016 at 12:49 PM.

  38. #38

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    Here is my complete program
    Attached Files Attached Files

  39. #39

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    69

    Re: Emulate Double Click

    I think I got it

    This line I got for post #30

    sShellLine = Chr(34) & "C:\Program Files\Ahead\Nero ShowTime\ShowTime.exe" & Chr(34) & " " & Chr(34) & "D:\DVD Movies\" & MovieName & Chr(34)


    But it should be this:

    sShellLine = Chr(34) & "D:\DVD Movies\" & MovieName & Chr(34)

    It works but I get return code 42 whatever that is

  40. #40
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,132

    Re: Emulate Double Click

    I would think this would work
    Code:
    Private Sub List1_DblClick()
     Dim sShellLine As String
     Dim ret As Long
     
     MovieName = List1.List(List1.ListIndex) & "\VIDEO_TS.IFO"
     MovieName = "D:\DVD Movies\" & MovieName
     
     ' Make sure you have what you think you should have
     MsgBox MovieName
     
     sShellLine = Chr(34) & MovieName & Chr(34)
    
     ret = ShellExecute(Me.hWnd, 0&, sShellLine, 0&, 0&, vbNormalFocus)
     MsgBox ret
     
    End Sub
    A return code less than 33 is an error. Greater that 33 is fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width