[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Anton

2/22/2011 10:27:00 PM

For example, I want to open the Windows Microphone control.
So I use

Shell "sndvol32.exe /rec", vbNormalFocus

But if I click the button again I get another instance of the same.
Now, I know that I could search and see if there is an app with that
caption already open, but ...
The caption is
R...
Not too helpful.
So rather than searching for a caption, what is a better controlled way
of either launching an app and getting something in return that will
let me test it to see if it is already open if I try again or some
other method? This cannot be a modal op since I need to do other
things while the app is open. Not sure what to search for.


7 Answers

Kevin Provance

2/23/2011 12:24:00 AM

0

Class name. Look it up. http://tinyurl.c...


"BeeJ" <nospam@spamfree.com> wrote in message
news:ik1d84$m0g$1@speranza.aioe.org...
> For example, I want to open the Windows Microphone control.
> So I use
>
> Shell "sndvol32.exe /rec", vbNormalFocus
>
> But if I click the button again I get another instance of the same.
> Now, I know that I could search and see if there is an app with that
> caption already open, but ...
> The caption is
> R...
> Not too helpful.
> So rather than searching for a caption, what is a better controlled way of
> either launching an app and getting something in return that will let me
> test it to see if it is already open if I try again or some other method?
> This cannot be a modal op since I need to do other things while the app is
> open. Not sure what to search for.
>
>


Chris Douce

2/23/2011 6:57:00 AM

0

On 22/02/2011 23:27, BeeJ wrote:
> For example, I want to open the Windows Microphone control.
> So I use
>
> Shell "sndvol32.exe /rec", vbNormalFocus
>
> But if I click the button again I get another instance of the same.
> Now, I know that I could search and see if there is an app with that
> caption already open, but ...
> The caption is
> R...
> Not too helpful.
> So rather than searching for a caption, what is a better controlled way
> of either launching an app and getting something in return that will let
> me test it to see if it is already open if I try again or some other
> method? This cannot be a modal op since I need to do other things while
> the app is open. Not sure what to search for.
>
>

Hi BeeJ,

That's what i use (tested in project with 1 form and 1 bas moduile)

'*********************************
'In a Bas Module

Declare Function OpenProcess Lib "kernel32.dll" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal
dwProcessId _
As Long) As Long

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

Public Declare Function GetExitCodeProcess Lib "kernel32.dll" _
(ByVal hProcess As Long, lpExitCode As Long) _
As Long


Function is_prog_actief(h_ID, Optional hproc As Long) As Long

Dim exit_code As Long


'Bepalen van de Processhandle door middel van de ID van de Shell
If hproc = 0 Then hproc = OpenProcess(PROCESS_QUERY_INFORMATION,
False, h_ID)
'checken of het programma nog actif is
zz = GetExitCodeProcess(hproc, exit_code)
is_prog_actief = exit_code


End Function
'**********************************



'**************************
'In form with 1 button


Private Sub Command1_Click()
Static hnote As Long
' Instance handle from Shell function.

note = is_prog_actief(hnote)

If note = STILL_ACTIVE Then
AppActivate hnote
Else
hnote = Shell("notepad.exe ", 1)
End If

End Sub
'*******************************************

Kind regards

Chris

Dee Earley

2/23/2011 10:13:00 AM

0

On 22/02/2011 22:27, BeeJ wrote:
> For example, I want to open the Windows Microphone control.
> So I use
>
> Shell "sndvol32.exe /rec", vbNormalFocus
>
> But if I click the button again I get another instance of the same.
> Now, I know that I could search and see if there is an app with that
> caption already open, but ...
> The caption is
> R...
> Not too helpful.
> So rather than searching for a caption, what is a better controlled way
> of either launching an app and getting something in return that will let
> me test it to see if it is already open if I try again or some other
> method? This cannot be a modal op since I need to do other things while
> the app is open. Not sure what to search for.

The full title will be available to windows and your app.
Having said that, a better way is to store the process ID from Shell()
and find its window to reactivate it.
http://blogs.msdn.com/b/oldnewthing/archive/2008/02/20/78...
You can check the title to make sure it's still the window you expect as
both window handles and process IDs can be reused.

Note that what you have so far won't work on Windows 7, maybe Vista too.
The sound system was restructured heavily and what you wanted doesn't
apply anymore but this is probably the closest:
"C:\Windows\system32\rundll32.exe" Shell32.dll,Control_RunDLL
mmsys.cpl,,recording

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

BeeJ

2/23/2011 3:31:00 PM

0

It happens that Dee Earley formulated :
> On 22/02/2011 22:27, BeeJ wrote:
>> For example, I want to open the Windows Microphone control.
>> So I use
>>
>> Shell "sndvol32.exe /rec", vbNormalFocus
>>
>> But if I click the button again I get another instance of the same.
>> Now, I know that I could search and see if there is an app with that
>> caption already open, but ...
>> The caption is
>> R...
>> Not too helpful.
>> So rather than searching for a caption, what is a better controlled way
>> of either launching an app and getting something in return that will let
>> me test it to see if it is already open if I try again or some other
>> method? This cannot be a modal op since I need to do other things while
>> the app is open. Not sure what to search for.
>
> The full title will be available to windows and your app.
> Having said that, a better way is to store the process ID from Shell() and
> find its window to reactivate it.
> http://blogs.msdn.com/b/oldnewthing/archive/2008/02/20/78...
> You can check the title to make sure it's still the window you expect as both
> window handles and process IDs can be reused.
>
> Note that what you have so far won't work on Windows 7, maybe Vista too.
> The sound system was restructured heavily and what you wanted doesn't apply
> anymore but this is probably the closest:
> "C:\Windows\system32\rundll32.exe" Shell32.dll,Control_RunDLL
> mmsys.cpl,,recording

I have found that out.
I will try your suggestion.


BeeJ

2/23/2011 3:33:00 PM

0

Kevin Provance explained on 2/22/2011 :
> Class name. Look it up. http://tinyurl.c...
>
>
> "BeeJ" <nospam@spamfree.com> wrote in message
> news:ik1d84$m0g$1@speranza.aioe.org...
>> For example, I want to open the Windows Microphone control.
>> So I use
>>
>> Shell "sndvol32.exe /rec", vbNormalFocus
>>
>> But if I click the button again I get another instance of the same.
>> Now, I know that I could search and see if there is an app with that
>> caption already open, but ...
>> The caption is
>> R...
>> Not too helpful.
>> So rather than searching for a caption, what is a better controlled way of
>> either launching an app and getting something in return that will let me
>> test it to see if it is already open if I try again or some other method?
>> This cannot be a modal op since I need to do other things while the app is
>> open. Not sure what to search for.
>>
>>

How did you do that? Cute!

Thanks for the pointer.


BeeJ

2/23/2011 3:36:00 PM

0

Thanks. I will study this.


Anton

2/24/2011 1:49:00 AM

0

Found these

Playback Tab
C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL
mmsys.cpl,,0
Recording Tab
C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL
mmsys.cpl,,1
Sounds Tab
C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL
mmsys.cpl,,2
Communications Tab
C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL
mmsys.cpl,,3