I did never needed it, but wrote this just in case somebody else needs this. This is nothing really spectacular and all arguments given to string can be retrieved via the built in variables %0%, %1% and up ... The string retrieved by this function is the full string used by Windows itself (including the options like "/restart").
edit: For example, this could be used for debugging.
Code:
; getCmdLine - get full command line string
; Public Domain 2008 Tuncay
; http://www.autohotkey.com/
/*
Function: getCmdLine
Get the full command line string of current script, including the
arguments to AutoHotkey.
Parameters:
There are no parameters.
Return:
Returns the full command line string.
ErrorLevel:
ErrorLevel is changed by DllCall().
*/
getCmdLine()
{
Return p2str(DllCall("GetCommandLine", "Str")) ; LPTSTR GetCommandLine(VOID)
}
/*
Function: p2str
Get a pointers variable content as a string.
Parameters:
_p - An address to a variable with a string content. (string pointer)
Return:
Returns the "extracted" string.
*/
p2str(_p)
{
; Get the content of first character, to avoid in the Loop the need
; of "A_Index - 1" at each iteration.
c := *(_p + 0)
str .= Chr(c)
Loop
{
If (c := *(_p + A_Index))
str .= Chr(c)
Else
Break
}
Return str
}
edit: Corrected the DllCall argument from "int" to "str".