It's an iPod that i am running from i changed the code to this and it still has no effect
Quote:
; first get the drive letter of "MyDrive":
driveget, list, list ; usb devices
stringtrimleft, len, list, 1 ; remove drive A
stringlen, len, list
loop, %len%
{
stringleft, drive, list, 1
driveget, label, label, %drive%:
if label = Koju's Ipod ; specify the label of
your drive here
mydrive = %drive%:
stringtrimleft, list, list, 1
}
; now get list of running programs:
WS_EX_APPWINDOW = 0x40000
WS_EX_TOOLWINDOW = 0x80
GW_OWNER = 4
WinGet, list, List
loop, %list%
{
wid := list%A_Index%
WinGet, es, ExStyle, ahk_id %wid%
if ( ( ! DllCall( "GetWindow", "uint", wid,
"uint", GW_OWNER ) and ! ( es & WS_EX_TOOLWINDOW )
)
or ( es & WS_EX_APPWINDOW ) )
{
WinGet, pid, PID, ahk_id %wid%
name := GetModuleFileNameEx( pid )
; use splitpath to obtain drive letter of
each app:
SplitPath, name, , , , , Drive
; close the program if drive matches:
if Drive = mydrive
WinClose, ahk_pid %pid%
}
}
return
GetModuleFileNameEx( p_pid )
{
if A_OSVersion in WIN_95,WIN_98,WIN_ME
{
MsgBox, This Windows version (%A_OSVersion%)
is not supported.
return
}
/*
#define PROCESS_VM_READ (0x0010)
#define PROCESS_QUERY_INFORMATION (0x0400)
*/
h_process := DllCall( "OpenProcess", "uint",
0x10|0x400, "int", false, "uint", p_pid )
if ( ErrorLevel or h_process = 0 )
{
MsgBox, [OpenProcess] failed
return
}
name_size = 255
VarSetCapacity( name, name_size )
result := DllCall(
"psapi.dll\GetModuleFileNameExA", "uint",
h_process, "uint", 0, "str", name, "uint",
name_size )
if ( ErrorLevel or result = 0 )
MsgBox, [GetModuleFileNameExA] failed
DllCall( "CloseHandle", h_process )
return, name
}