#NoTrayIcon
#Include <APIConstants.au3>
#Include <Array.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Opt('WinTitleMatchMode', 3)
Opt('WinWaitDelay', 0)
If Not $CmdLine[0] Then
Exit
EndIf
Global $tCOPYDATA, $hReceiver, $hMutex, $Ret, $Lenght, $Count = 1
Global $Path[101] = [1, $CmdLine[1]]
$hMutex = _WinAPI_CreateMutex('{3891B756-85A2-4274-9226-5E66967E60A4}')
If _WinAPI_GetLastError() = 183 Then
$hReceiver = WinWait('{A257F21D-D0BF-4CE9-A6C9-84C7D258C91B}', '', 3)
If @error Then
Exit
EndIf
$Lenght = StringLen($CmdLine[1]) + 1
$tCOPYDATA = DllStructCreate('ulong_ptr;dword;ptr;wchar[' & $Lenght & ']')
DllStructSetData($tCOPYDATA, 1, 0x1000)
DllStructSetData($tCOPYDATA, 2, 2 * $Lenght)
DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tCOPYDATA, 4))
DllStructSetData($tCOPYDATA, 4, $CmdLine[1])
$Ret = DllCall('user32.dll', 'uint', 'SendMessage', 'hwnd', $hReceiver, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($tCOPYDATA))
If (@error) Or (Not $Ret[0]) Then
; Nothing
EndIf
Exit
EndIf
$hReceiver = GUICreate('{A257F21D-D0BF-4CE9-A6C9-84C7D258C91B}')
GUIRegisterMsg($WM_COPYDATA, 'WM_COPYDATA')
While 1
Sleep(200)
If $Path[0] = $Count Then
ExitLoop
EndIf
$Count = $Path[0]
WEnd
GUIRegisterMsg($WM_COPYDATA, '')
GUIDelete($hReceiver)
_WinAPI_CloseHandle($hMutex)
ReDim $Path[$Path[0] + 1]
_ArrayDisplay($Path)
Func WM_COPYDATA($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case $hReceiver
Local $tCOPYDATA = DllStructCreate('ulong_ptr;dword;ptr', $lParam)
Switch DllStructGetData($tCOPYDATA, 1)
Case 0x1000
$Path[0] += 1
If $Path[0] > UBound($Path) - 1 Then
ReDim $Path[$Path[0] + 100]
EndIf
$Path[$Path[0]] = DllStructGetData(DllStructCreate('wchar[' & (DllStructGetData($tCOPYDATA, 2) / 2) & ']', DllStructGetData($tCOPYDATA, 3)), 1)
Return 1
EndSwitch
EndSwitch
Return 0
EndFunc ;==>WM_COPYDATA