volume control
Moderators: Dorian (MJT support), JRL
volume control
Hi Folks,
I'm back with a new problem and of course pressed for time so I thought I'd post this new improved problem as new as well.
Thanks for your quick responses guys. I now can get this scp to check the box quite nicely,(although it comes up already checked?) but it seems like it only "looks" checked and when I step thru it, if I double click on the already selected box, it then becomes really selected...and I hear sound.
Also, after the macro runs and closes the window, the check box is not checked when I open the window up again with the mouse.
Any ideas?
Thanks,
Pat
ExecuteFile>C:\WINDOWS\SNDVOL32.EXE
WaitWindowOpen>Volume Control
GetCheckBox>Volume Control,Line-In,res
If>res=1,checked,unchecked
Wait>5
Label>checked
SetCheckBox>Volume Control,&Select,FALSE
Wait>5
Goto>end
Label>unchecked
SetCheckBox>Volume Control,&Select,TRUE
Wait>5
Label>end
Wait>5
CloseWindow>Volume Control
I'm back with a new problem and of course pressed for time so I thought I'd post this new improved problem as new as well.
Thanks for your quick responses guys. I now can get this scp to check the box quite nicely,(although it comes up already checked?) but it seems like it only "looks" checked and when I step thru it, if I double click on the already selected box, it then becomes really selected...and I hear sound.
Also, after the macro runs and closes the window, the check box is not checked when I open the window up again with the mouse.
Any ideas?
Thanks,
Pat
ExecuteFile>C:\WINDOWS\SNDVOL32.EXE
WaitWindowOpen>Volume Control
GetCheckBox>Volume Control,Line-In,res
If>res=1,checked,unchecked
Wait>5
Label>checked
SetCheckBox>Volume Control,&Select,FALSE
Wait>5
Goto>end
Label>unchecked
SetCheckBox>Volume Control,&Select,TRUE
Wait>5
Label>end
Wait>5
CloseWindow>Volume Control
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
Interesting. This function enumerates all check box objects on the given window and when it finds one with the specified label it sends the BM_SETCHECK message to it. This is the windows message that is sent when a checkbox is checked/unchecked.
Now it sounds like your checkbox is doing some other kind of processing - and seems to want a mouse click as well as the usual BM_SETCHECK.
I get the same problem with sndvol32 but it works fine with another application.
This is one of the problems with writing commands which send windows messages. When making commands like this we have to assume that all applications process the messages in the same way and all follow the same rules. Unfortunately this isn't always the case. It is like the CloseWindow function which sends a WM_CLOSE message to the specified window which *normally* tells the window to close and when the window gets this message it closes. But this isn't necessarily always the case. E.g. Some apps will decide to ignore it if it didn't come from itself for example. On the contrary Microsoft Word does something very strange and closes down completely without even checking if the user wants to save their changes - most odd!
This just goes to show why automating by simulating user activity is so important. We don't know what the programmers of sndvol32.exe or Microsoft Word have done and we can't make assumptions about how it processes standard windows messages, BUT we do know that if we send keystrokes or mouse clicks it will do what we want, because that's what the user does, that's what the designer of the interface has allowed for and that's what triggers off the internal processes of the application.
In this case unfortunately it looks like we're gonna have to use keystrokes to check/uncheck the checkbox. Use Press Tab the required number of times to get to the checkbox and then press a Space:
Press Tab
Press Tab
etc
Send>
There's a space at the end of the last line.
In version 7.1 you can do:
Press Tab * 3
To make the Tab press three times.
I hope this is helpful.
Interesting. This function enumerates all check box objects on the given window and when it finds one with the specified label it sends the BM_SETCHECK message to it. This is the windows message that is sent when a checkbox is checked/unchecked.
Now it sounds like your checkbox is doing some other kind of processing - and seems to want a mouse click as well as the usual BM_SETCHECK.
I get the same problem with sndvol32 but it works fine with another application.
This is one of the problems with writing commands which send windows messages. When making commands like this we have to assume that all applications process the messages in the same way and all follow the same rules. Unfortunately this isn't always the case. It is like the CloseWindow function which sends a WM_CLOSE message to the specified window which *normally* tells the window to close and when the window gets this message it closes. But this isn't necessarily always the case. E.g. Some apps will decide to ignore it if it didn't come from itself for example. On the contrary Microsoft Word does something very strange and closes down completely without even checking if the user wants to save their changes - most odd!
This just goes to show why automating by simulating user activity is so important. We don't know what the programmers of sndvol32.exe or Microsoft Word have done and we can't make assumptions about how it processes standard windows messages, BUT we do know that if we send keystrokes or mouse clicks it will do what we want, because that's what the user does, that's what the designer of the interface has allowed for and that's what triggers off the internal processes of the application.
In this case unfortunately it looks like we're gonna have to use keystrokes to check/uncheck the checkbox. Use Press Tab the required number of times to get to the checkbox and then press a Space:
Press Tab
Press Tab
etc
Send>
There's a space at the end of the last line.
In version 7.1 you can do:
Press Tab * 3
To make the Tab press three times.
I hope this is helpful.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
volume control
Hi Marcus,
Thankyou very much for responding again so quickly.
Yes the tab idea works just fine. I have made 2 macros, one for on and one for off... and then I got crazy and tried to take out the 1 second pause between opening the window and pressing the tabs..... now I've lost the macros in the program selection. They and many more seem to have disappeared. I shall reboot and assume they will be there all fresh and scrubbed.
So I guess I'll take a 2 second appearance of the window on screen and run.
Again, thanks for your timely help.
Pat
Thankyou very much for responding again so quickly.
Yes the tab idea works just fine. I have made 2 macros, one for on and one for off... and then I got crazy and tried to take out the 1 second pause between opening the window and pressing the tabs..... now I've lost the macros in the program selection. They and many more seem to have disappeared. I shall reboot and assume they will be there all fresh and scrubbed.
So I guess I'll take a 2 second appearance of the window on screen and run.
Again, thanks for your timely help.
Pat
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: volume control
Dunno why your macros have disappeared! The script files themselves should still be there. If they don't come back do File / New Macro and hit the Import button and you should find the script file in the Macro Scheduler directory - and just reimport it.0894761f wrote:... now I've lost the macros in the program selection. They and many more seem to have disappeared. I shall reboot and assume they will be there all fresh and scrubbed.
Even though you have a WaitWindowOpen>Volume Control sometimes a small wait is necessary as the window may be created and in existance but not quite ready for keyboard input - it could be doing some initialisation for example. Could also try a WaitReady>1 instead. But I expect a Wait>2 is all you need.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi,
something additional.
MixerBrowser:
http://ilmari.siba.fi/users/pdonner/mixerbrowser.htm
Looks interesting, for those who want to go further on that topic
Here are some parameters which I've found to be used with sndvol32.exe.
sndvol.exe /s = small
sndvol.exe /r = recorder
sndvol.exe /t = tray
So use /s and something like this:
I've detected "MasterOut" as window title, check if it's the same for you. And five "M"steps were needed to reach the "line"-section. Check this as well.
Rgds,
Ernest
something additional.
MixerBrowser:
http://ilmari.siba.fi/users/pdonner/mixerbrowser.htm
Looks interesting, for those who want to go further on that topic
Here are some parameters which I've found to be used with sndvol32.exe.
sndvol.exe /s = small
sndvol.exe /r = recorder
sndvol.exe /t = tray
So use /s and something like this:
Code: Select all
Let>counter=0
WaitWindowOpen>Master Out
Label>Mute
Add>counter,1
If>counter=6, CheckLineBox
Press ALT
Send>M
Goto>Mute
Label>CheckLineBox
Release ALT
Press Shift
ReleaseShift
Rgds,
Ernest
How can we check a checkbox, rather than toggling it?
As you've discussed above, in certain programs, the SetCheckBox command doesn't work because, for example, the program expects a mouse click (and not just a BM_SETCHECK).
A couple of alternative approaches---invoking an available keyboard shortcut or tabbing to a checkbox and then sending a space---generally will TOGGLE a checkbox.
If, however, for some reason, it's uncertain whether the checkbox is or is not already checked before we act upon it, then merely toggling it may leave it unchecked.
[b]How, then, can we achieve the goal of making sure that the box is checked? [/b]
(This has proven to be a problem not only in the volume-control application mentioned previously in this thread, but in the checkboxes in the "Message Options" dialog for MS Outlook e-mail messages. I'm using Macro Scheduler 7.3.11.4 in Windows XP Pro SP2. Thanks for any help anyone can give!)
A couple of alternative approaches---invoking an available keyboard shortcut or tabbing to a checkbox and then sending a space---generally will TOGGLE a checkbox.
If, however, for some reason, it's uncertain whether the checkbox is or is not already checked before we act upon it, then merely toggling it may leave it unchecked.
[b]How, then, can we achieve the goal of making sure that the box is checked? [/b]
(This has proven to be a problem not only in the volume-control application mentioned previously in this thread, but in the checkboxes in the "Message Options" dialog for MS Outlook e-mail messages. I'm using Macro Scheduler 7.3.11.4 in Windows XP Pro SP2. Thanks for any help anyone can give!)
Answer to toggling question
Ah, me. It turns out that I unnecessarily assumed that, just because the SetCheckBox won't work in a window/dialog, the GetCheckBox won't work either.
In MS Outlook, at least, GetCheckBox works fine even when SetCheckBox does not, so all that's necessary to reliably set a particular checkbox to CHECKED status is to use GetCheckBox to check the checkbox's status and then toggle it only if necessary, like so:
GetCheckBox>WindowName,CheckBoxName,Result
If>Result=0
// TOGGLE THE CHECKBOX BY TABBING TO IT & SENDING A SPACE
Press TAB * 3
Send Character/Text>
Else
...rest of script
That's it!
In MS Outlook, at least, GetCheckBox works fine even when SetCheckBox does not, so all that's necessary to reliably set a particular checkbox to CHECKED status is to use GetCheckBox to check the checkbox's status and then toggle it only if necessary, like so:
GetCheckBox>WindowName,CheckBoxName,Result
If>Result=0
// TOGGLE THE CHECKBOX BY TABBING TO IT & SENDING A SPACE
Press TAB * 3
Send Character/Text>
Else
...rest of script
That's it!
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
If You Are After An Easy Vol Control, Look At Post http://www.mjtnet.com/forum/viewtopic.php?t=2022
Way To Bring Up An Old Post Though.
Way To Bring Up An Old Post Though.
FIREFIGHTER