Jump to content

_GetPath and _RunIn UDF


Recommended Posts

Hello !

I am quite new in autoit but I think that this udf can be useful for some of you becuse I couldn't find something similar. It includes 2 functions:

1) _GetPath - this function can get full path from name of file

2) _RunIn - function for opening URL in non-default browser

 

#include-once
#include <Constants.au3>

;=======================================================================================
; Function Name     _GetPath
;
; Description:      Gets a full path from name of file
;
; Parameter(s):     name of file
;
; Return Value(s):  0 if the file is not found.
;                   path if the file was found successfully
;
; Author:           ssamko
;=======================================================================================
Func _GetPath($name="")
   Local $DOS, $Message = '',$path

   $DOS = Run(@ComSpec & " /C cd \ & dir /s /b "&$name, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
   ProcessWaitClose($DOS)
   $Path = StdoutRead($DOS)
   If $Path="" Then Return 0

   Return $path

EndFunc   ;==>_GetPath

 ;=======================================================================================
; Function Name     _RunIn
;
; Description:      Run url in non default browser
;
; Parameter(s):     name or path to browser
;                   url
;                   window: 0 for opening in actual window
;                           1 for opening in new window
;
; Return Value(s):  0 if parameters ísn't found
;
; Author:           ssamko
;=======================================================================================
Func _RunIn($name="", $url="", $window=0)

   If $name<>"" And $url<>"" Then
      $url=" "&$url
      If Not FileExists ( $name ) Then $name= _GetPath($name)
      If $window=1 Then $window=" --new-window"

      Run($name&$url&$window)

      Return ""
   Else
      MsgBox(0,"Error","Make sure you if you filled both parameters.")
      Return 0
   EndIf

EndFunc   ;==>_RunIn

 

If you have some questions or tips just write. :) 

PS: Please can you rate my english level from 1-10 ? :D  

Edited by ssamko
Link to post
Share on other sites

Probably need to be an exe which was installed via some compliant package.

Definitely does not work on stand alone packages.

EDIT: Your English 9/10

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites
  • 3 months later...
On 27. 12. 2015 at 5:00 PM, JohnOne said:

Probably need to be an exe which was installed via some compliant package.

Definitely does not work on stand alone packages.

EDIT: Your English 9/10

UDF updated ! Now _GetPath searches not only for installed exe but also for other files.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...