Do not open notepad if notepad is already open
Do not open notepad if notepad is already open
Can anybody help?
I have the following code...
Dim TextFile As String
TextFile = "C:Documents and SettingsdsmithDesktopMechTools Project FilesThings To do.txt"
Shell ("C:WindowsNotePad.exe", Chr$(34) + TextFile + Chr$(34), Sw_ShowNormal)
Everything works OK
But If I run it with NotePad.exe already running it opens another instance of NotePad.exe.
How can I prevent it from opening up another instance of NotePad.exe
rather than just opening up the text file.
Many thanks in advance!!!
I have the following code...
Dim TextFile As String
TextFile = "C:Documents and SettingsdsmithDesktopMechTools Project FilesThings To do.txt"
Shell ("C:WindowsNotePad.exe", Chr$(34) + TextFile + Chr$(34), Sw_ShowNormal)
Everything works OK
But If I run it with NotePad.exe already running it opens another instance of NotePad.exe.
How can I prevent it from opening up another instance of NotePad.exe
rather than just opening up the text file.
Many thanks in advance!!!
Do not open notepad if notepad is already open
Here `s somthing you can use for it.
best regards
declare check as "WaitForSingleObject" of "kernel32.dll"
hhandle as integer
dwmilliseconds as integer
result as integer
end declare
``get windows folder
dim winfolder as string
Declare getwindir as "GetWindowsDirectoryA" of "kernel32"
lpBuffer As String byaddress
nSize As integer
end declare
getwindir.lpbuffer=space$(256)
getwindir.nsize=256
getwindir.execute
winfolder=rtrim$(getwindir.lpbuffer)+""
``testform
object testform as form
object npad as button
caption="open notepad"
onclick=npad_onclick
end object
showmodal
end object
sub npad_onclick
``check if application is running
dim pid as integer
check.hhandle=pid
check.execute
if check.result > 0 then
showmessage "notepad already running"
exit sub
end if
pid=shell(winfolder+"notepad.exe")
end sub
best regards
declare check as "WaitForSingleObject" of "kernel32.dll"
hhandle as integer
dwmilliseconds as integer
result as integer
end declare
``get windows folder
dim winfolder as string
Declare getwindir as "GetWindowsDirectoryA" of "kernel32"
lpBuffer As String byaddress
nSize As integer
end declare
getwindir.lpbuffer=space$(256)
getwindir.nsize=256
getwindir.execute
winfolder=rtrim$(getwindir.lpbuffer)+""
``testform
object testform as form
object npad as button
caption="open notepad"
onclick=npad_onclick
end object
showmodal
end object
sub npad_onclick
``check if application is running
dim pid as integer
check.hhandle=pid
check.execute
if check.result > 0 then
showmessage "notepad already running"
exit sub
end if
pid=shell(winfolder+"notepad.exe")
end sub
Do not open notepad if notepad is already open
It works very good :D
Do not open notepad if notepad is already open
If you can do this you also can put focus on the notepad or whatever prgram you run right?
;D
this is the API, i think this is the one
declare focus as "SetFocus" of "User32"
hhandle as integer byadress
result as integer
end declare
;D
this is the API, i think this is the one
declare focus as "SetFocus" of "User32"
hhandle as integer byadress
result as integer
end declare
Do not open notepad if notepad is already open
busy with that because you need a window handle for that and whe have a process handle.
best regards
best regards
Do not open notepad if notepad is already open
[quote author=6461686C6B050 link=1343917838/4#4 date=1345475067]busy with that because you need a window handle for that and whe have a process handle.
best regards[/quote]
Sorry Admin i didn?t understood, isn`t possible at the moment?
best regards[/quote]
Sorry Admin i didn?t understood, isn`t possible at the moment?
Do not open notepad if notepad is already open
I think it is somehow possible but i did not find the solution yet.
best regards
best regards