forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Shell Command

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Sun Apr 23, 2006 4:27 am    Post subject: Shell Command Reply with quote

Is there a way to perform a shell command and use Min/Max/Hide? I was reading the SHELL command and there is no option for Min/Max/Hide.

Thanks

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Sun Apr 23, 2006 12:23 pm    Post subject: Reply with quote

Chris,
No the VDS Shell command does not have those options but you could use the Win32 API ShellExecute function that the VDS Shell command uses.

Code:
Title ShellExecute instead
#DEFINE COMMAND,SHELLEXECUTE

# Call the ShellExecute command with the verb Init to load the DLL's and setup the constants.
ShellExecute Init
# Call the ShellExecute command with the proper information to open a text file
ShellExecute OPEN,@Path(%0)happy programmers day.txt,,SW_SHOWNOACTIVATE

:CLOSE
  # Call the ShellExecute command with the verb UnInit to unload the DLL's
  ShellExecute UnInit
Exit


:ShellExecute
  # Example command to show the useage of the ShellExecute API function.
  # %1 = Shell command
  # %2 = Path\Filename.Ext
  # %3 = Optional command line parameters
  # %4 = one or more of the SW_ constants defaults to SW_SHOWDEFAULT
  ####### SW_HIDE
  ####### SW_NORMAL
  ####### SW_MAXIMIZE
  ####### SW_MINIMIZE
  ####### SW_RESTORE
  ####### SW_SHOW
  ####### SW_SHOWDEFAULT
  ####### SW_SHOWMAXIMIZED
  ####### SW_SHOWMINIMIZED
  ####### SW_SHOWMINNOACTIVE
  ####### SW_SHOWNA
  ####### SW_SHOWNOACTIVATE
  ####### SW_SHOWNORMAL
  #
  If @Equal(%1,INIT)
    # INIT verb is internal to this command.
    # It loads the DLL's and sets up the constants need for the ShellExecute API function to work
    GoSub ShellExecute_Init
  ElsIf @Equal(%1,_INIT)
    # INIT verb is internal to this command.
    # It loads the DLL's and sets up the constants need for the ShellExecute API function to work
    GoSub ShellExecute_Init
  ElsIf @Equal(%1,UNINIT)
    # UnInit verb unloads the DLL's
    GoSub ShellExecute_UnInit
  ElsIf @Equal(%1,_UNINIT)
    # UnInit verb unloads the DLL's
    GoSub ShellExecute_UnInit
  Else
    If %2
      # Split off the path and file name...
      %P = @Path(%2)
      If @Greater(@Pos(.,%2),0)
        %N = @Name(%2).@Ext(%2)
      Else
        %N = @Name(%2)
      End
    Else
      # must have a file or folder if not throw VDS error code 20
      error 2
    End
    If %4
      # Should be 1 of these values
      If @Equal(%4,SW_HIDE)
        # %%SW_HIDE = 0
        %4 = 0
      ElsIf @Equal(%4,SW_NORMAL)
        # %%SW_NORMAL = 1
        %4 = 1
      ElsIf @Equal(%4,SW_MAXIMIZE)
        # %%SW_MAXIMIZE = 3
        %4 = 3
      ElsIf @Equal(%4,SW_MINIMIZE)
        # %%SW_MINIMIZE = 6
        %4 = 6
      ElsIf @Equal(%4,SW_RESTORE)
        # %%SW_RESTORE = 9
        %4 = 9
      ElsIf @Equal(%4,SW_SHOW)
        # %%SW_SHOW = 5
        %4 = 5
      ElsIf @Equal(%4,SW_SHOWDEFAULT)
        # %%SW_SHOWDEFAULT = 10
        %4 = 10
      ElsIf @Equal(%4,SW_SHOWMAXIMIZED)
        # %%SW_SHOWMAXIMIZED = 3
        %4 = 3
      ElsIf @Equal(%4,SW_SHOWMINIMIZED)
        # %%SW_SHOWMINIMIZED = 2
        %4 = 2
      ElsIf @Equal(%4,SW_SHOWMINNOACTIVE)
        # %%SW_SHOWMINNOACTIVE = 7
        %4 = 7
      ElsIf @Equal(%4,SW_SHOWNA)
        # %%SW_SHOWNA = 8
        %4 = 8
      ElsIf @Equal(%4,SW_SHOWNOACTIVATE)
        # %%SW_SHOWNOACTIVATE = 4
        %4 = 4
      ElsIf @Equal(%4,SW_SHOWNORMAL)
        # %%SW_SHOWNORMAL = 1
        %4 = 1
      End
    Else
      # if %4 is not provided set the default to SW_SHOWDEFAULT
      %4 = 10
    End
    If %3
      # if command line parameters are provided
      %A = @Lib(shell32,ShellExecuteA,INT,INT:@Lib(user32,GetDesktopWindow,INT),STR:%1,STR:%N,%3,STR:%P,INT:%4) 
    Else
      # if command line parameters are not provided
      %A = @Lib(shell32,ShellExecuteA,INT,INT:@Lib(user32,GetDesktopWindow,INT),STR:%1,STR:%N,NIL:,STR:%P,INT:%4)
    End
    If @Not(@Greater(%A,32))
      # if the return value is not greater than 32 then there is an error otherwise it is a instance handle to the process
      # or a DDE handle.
      if @Equal(%A,0)
        # The operating system is out of memory or resources.
        error 29
      ElsIf @Equal(%A,2)
        # The specified file was not found.
        error 20
      ElsIf @Equal(%A,3)
        # The specified path was not found.
        error 20
      ElsIf @Equal(%A,11)
        # The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).
        error 43
      ElsIf @Equal(%A,5)
        # The operating system denied access to the specified file.
        error 44
      ElsIf @Equal(%A,27)
        # The filename association is incomplete or invalid.
        error 45
      ElsIf @Equal(%A,30)
        # The DDE transaction could not be completed because other DDE transactions were being processed.
        error 46
      ElsIf @Equal(%A,29)
        # The DDE transaction failed.
        error 47
      ElsIf @Equal(%A,28)
        # The DDE transaction could not be completed because the request timed out.
        error 48 
      Elsif @Equal(%A,32)
        # The specified dynamic-link library was not found.
        error 40
      ElsIf @Equal(%A,31)
        # There is no application associated with the given filename extension.
        error 49
      ElsIf @Equal(%A,8)
        # There was not enough memory to complete the operation.
        error 29
      ElsIf @Equal(%A,26)
        # A sharing violation occurred.
        error 50
      Else
        # An unknown and undocumented error was returned by the ShellExecute API function.
        error 27
      End
    End
  End 
Exit

:ShellExecute_Init
  # A sub-routine to load the DLL's needed
  # to use the ShellExecute API function
  LoadLib shell32.dll
  LoadLib user32.dll
Exit

:ShellExecute_UnInit
  # free the DLL's before script ends
  FreeLib shell32
  FreeLib user32
Exit


While you can do it the above way I do belive that VDS is now using the ShellExecuteEx function instead since the ShellExecuteEx function has several options to allow you to wait or not wait for the program to finish. Unfortunately it uses a Structure and I don't have the time right now to go into breaking that apart with VDS. It is alot easier to use structures with GadgetX so I guess I will make a simple DSU for ya with GadgetX that gives you all the options for the ShellExecuteEx function.

My only suggestion at this point is to have your program use the Run command flavors. You can have your program read the registry for the file types Shell commands. Below is the Regkey for Txt files.

HKEY_CLASSES_ROOT\txtfile\shell\open\command

To find the name of this key you would look in

HKEY_CLASSES_ROOT\.txt

Look at the default name for the name of the file type this will take you to the shell command key above. Then you can replace the "%1" with the file on the VDS Run command's command line.

C:\WINDOWS\EditPad.exe "%1"

_________________
Home of

Give VDS a new purpose!


Last edited by vdsalchemist on Mon Sep 24, 2007 2:57 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Sun Apr 23, 2006 5:03 pm    Post subject: Reply with quote

Thanks dragonsphere, this will work fine until you get the GadgetX example finished. Will you get a chance to make a Bassmode example? Smile
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Apr 24, 2006 11:35 am    Post subject: Reply with quote

Chris,
I have wrappers for both the Bassmod.dll and the Bass.dll. I just finished a converter that converts the definitions from the old Gadget syntax to GadgetX'es syntax.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Mon Apr 24, 2006 6:54 pm    Post subject: Reply with quote

Great! looking forward to getting that.
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group