• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

AutoIT ShellExecuteRaw()

Status
Not open for further replies.

DDoSer

The Real DDoSer
User
Joined
Oct 9, 2013
Messages
352
Reputation
0
Reaction score
4,578
Points
243
Credits
0
‎11 Years of Service‎
51%
[HIDE-THANKS]This UDF takes a raw string and parses it into command and parameters variables, which it passes to ShellExecute() -- or ShellExecuteWait() if variable $vWait is set. I use it to read command strings from an .ini file, which can be executed by entering a short alias, or key. For example, with the following .ini entry I can open the NY Times website in Firefox by simply entering "N":

N="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
This link is hidden for visitors. Please Log in or register now.


ShellExecuteRaw() parses the command string into command and parameter(s), and then returns ShellExecute[Wait]().

Code:
>Func ShellExecuteRaw($R, $vWorkingDir="", $vVerb="", $vWait="")
#cs
   Format raw string as "command", "params" for ShellExecute[Wait]()
   Variables: $R = raw string; $C = command; $D = delimiter; $P = params
   If input var $vWait is set, func returns
       ShellExecuteWait($C, $P, $vWorkingDir, $vVerb)
   otherwise, it returns
       ShellExecute($C, $P, $vWorkingDir, $vVerb)
#ce
   Local $C = $R, $D = " ", $P = ""
   If StringInStr($R, '"') == 1 Then
       $D = '" '
   EndIf
   If StringInStr($R, $D) > 0 Then
       $C = StringTrimRight( $R, StringLen($R) _
           - StringinStr($R, $D) + 2 - StringLen($D) )
       $P = StringTrimLeft( $R, StringInStr($R, $D) )
   EndIf
   Local $ShellFuncName = "ShellExecute"
   If $vWait Then
       $ShellFuncName = $ShellFuncName & "Wait"
   EndIf
   Return Call($ShellFuncName, $C, $P, $vWorkingDir, $vVerb)
EndFunc ; ShellExecuteRaw
[/HIDE-THANKS]

 
Status
Not open for further replies.
Back
Top