|
Not sure if your BN_CLICKED and BM_CLICK are same, but here is what the documentation at http://msdn.microsoft.com/en-us/library/bb775985(VS.85).aspx[^] says:
"Simulates the user clicking a button. This message causes the button to receive the WM_LBUTTONDOWN and WM_LBUTTONUP messages, and the button's parent window to receive a BN_CLICKED notification code."
I believe that the parent must be notified of the event for it to handle the event and BM_CLICK does this.
|
|
|
|
|
And I just verified that BM_CLICK is 245 (0x00F5) in winuser.h
|
|
|
|
|
Hmmm, so this is what I am using for BN_CLICKED so this should be the same as you suggested then
I may or may not be responsible for my own actions
|
|
|
|
|
Why are you attempting to go the long way round to automate the application? There's a feature called Microsoft Active Accessibility (MSAA)[^] which provides accessibility for WinForms applications. This allows you to get access to controls, and automate them.
|
|
|
|
|
Thanks for your reply, but I think you think this application I want to automate is my own application? Just to clear it up, this is a 3rd party application which I have no control over source code in any way.
Perhaps I am wrong and there is more to the information you linked, but it appears these are guidelines on how to create an application that allows for programmatic calls to achieve automation, right?
I may or may not be responsible for my own actions
|
|
|
|
|
|
How to convert RectangleF to and back from string representation in a similar way as Int32.Parse()?
Чесноков
|
|
|
|
|
You could use this[^] to convert it to a string, but you would need to write your own method to reconvert from strings to the structure.
The best things in life are not things.
|
|
|
|
|
The following class could be used (with a bit of beefing up) to convert back from a string representation:
namespace ParseRectangleF
{
using System;
using System.Drawing;
public static class ParserUtility
{
public static RectangleF Parse(string value)
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException(value);
value = value.Replace("{", string.Empty).Replace("}", string.Empty).Replace(" ", string.Empty);
var rectangle = new RectangleF();
rectangle.X = GetValue(value, "X=");
rectangle.Y = GetValue(value, "Y=");
rectangle.Width = GetValue(value, "Width=");
rectangle.Height = GetValue(value, "Height=");
return rectangle;
}
private static float GetValue(string value, string key)
{
if (!key.EndsWith("="))
{
key += "=";
}
int ordinal = value.IndexOf(key, StringComparison.CurrentCultureIgnoreCase);
int length = ordinal + key.Length;
int commaPos = value.IndexOf(",", length);
if (commaPos < length)
{
commaPos = value.Length;
}
string text = value.Substring(length, commaPos - length);
float output;
if (!float.TryParse(text, out output))
{
throw new ArgumentException(
string.Format("The input {0} is not the right format for Parse. It should be formatted like X=nn, Y=, Width=nn, Height=nn.", value));
}
return output;
}
}
} To call it, all you need to do is:
RectangleF rect = ParserUtility.Parse("{x=10, y=10, width=100,height=300");
|
|
|
|
|
Thank you for the code, why the same can not be executed with System.Drawing.RectangleConverter.
It worked with Rectangle but failed with RectangleF
Чесноков
|
|
|
|
|
You can achieve the same effect with the RectangleConverter, if you use the following code:
RectangleF rect = (RectangleF)(Rectangle)conv.ConvertFromInvariantString("10,10,100,300"); The ConvertFrom methods return an object, so you need to cast it into a Rectangle first before you can cast it into a RectangleF. It's a bit backwards, I know, but it does work.
|
|
|
|
|
the values in RectangleF are fractional
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: the values in RectangleF are fractional
I know. I'm just showing what happens, hence the reason you have to cast it.
|
|
|
|
|
The following two methods are based on the ConvertFrom and ConvertTo methods of the RectangleConverter class, tweaked for RectangleF and other bits removed as we know the types required in advance.
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
public class RectangleFUtilities
{
public static bool TryParse(string s, out RectangleF result)
{
if (string.IsNullOrEmpty(s))
{
result = RectangleF.Empty;
return false;
}
s = s.Trim();
if (s.Length == 0)
{
result = RectangleF.Empty;
return false;
}
CultureInfo culture = CultureInfo.CurrentCulture;
string[] strArray = s.Split(new char[] { culture.TextInfo.ListSeparator[0] });
float[] numArray = new float[strArray.Length];
for (int i = 0; i < numArray.Length; i++)
{
if (!float.TryParse(strArray[i], out numArray[i]))
{
result = RectangleF.Empty;
return false;
}
}
if (numArray.Length != 4)
{
result = RectangleF.Empty;
return false;
}
result = new RectangleF(numArray[0], numArray[1], numArray[2], numArray[3]);
return true;
}
public static string ToString(RectangleF rectangleF)
{
CultureInfo culture = CultureInfo.CurrentCulture;
string separator = culture.TextInfo.ListSeparator + " ";
TypeConverter converter = TypeDescriptor.GetConverter(typeof(float));
string[] strArray = new string[4];
int num = 0;
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.X);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Y);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Width);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Height);
return string.Join(separator, strArray);
}
}
Dave
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
modified on Wednesday, June 1, 2011 7:12 AM
|
|
|
|
|
Hey all,
Anyone have a very simplified/bare-bone cookbook sample to play a wav file over a serial port that was dialled?
So far I have successfully made a c# app that opens port, dials phone number and the app sleeps for a few seconds till i pick-up phone, i received the phone but then am now at the point where my code should play a wav file.
Anyone have a sample?
Tia
charles
|
|
|
|
|
you want to send some bytes and listen to them? I did those things before PC's became popular, and without a modem.
I suggest you read some articles, maybe google for serialport, waveform, sound, things like that. Here is one CP article that you might learn from: Universal Remote Control with PDA[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
So I have made some EXCELLENT progress. Practically done. What is left is finessing the audio into place. Right now. I take a wav file, and break it into blocks as per some examples. But when I listen to it over the phone it plays for the first couple seconds, then it starts to sound like it's skipping.
PS:I will help anyone who reads this. Email me @ dotnetcoder@hotmail.ca.
But if I can get help here is my audio loop.
BinaryReader rdr = new BinaryReader(strm);
Utils.Write("4");
while (!MSwitch)
{
byte[] bt = new byte[1024];
bt = rdr.ReadBytes(1024);
if (bt.Length == 0)
{
MSwitch = true;
break;
}
comPort.Write(bt, 0, bt.Length);
}
Before this, I read the stream after the 44th byte. Starts fine, but I think the program is writing too fast?
|
|
|
|
|
Did you consider handshaking? maybe your target is using hardware (or software) handshaking, and your code is not?
and plese use PRE tags when showing code snippets.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Must be something with the audio..... I chopped up the wav into portions. The first portion was skip free, so i repeated that over and over and no skips, then i played a portion that skipped and it skipped so it must be the wav file. though i believe i had re-encoded it properly. will investigate.
But a bigger issue, have you been able to send key tones? I want my system to dial extensions but from some early readings i may have to gimck this.
the other issue is i am targeting a USR5637 56K USB Faxmodem. but it appears that the only at command that gives me an ok is 'at' and 'atd'...... hey, can i give you my email?
dotnetcoder@hotmail.ca
|
|
|
|
|
Sorry, I never had my PC speak to my phone or my modem, and I don't know the specific faxmodem you're talking about.
Dual-tone dialing probably isn't that easy, it is explained here[^]; it needs two sine waves at the same time, and both better be pretty accurate in frequency and pretty close to a sine wave (as to avoid harmonics). So you need to be very careful about the number of bit-times each sample will require on your serial line.
I don't do e-mail, I'm here to help people, but I want to participate in threads for all to read, not off-line individual discussions.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hey Luc
If you can clarify one thing, so if I have a modem that is TAPI compatible, it may still not be considered a 'voice' modem. In the sense that it can not play a wav file after dialing a phone number. The modem modem I currently have is the USR 5637 but I am now permitted to get any voice modem avoiable?
|
|
|
|
|
Frankly I don't know these things, I know quite a bit about serial ports, but not about modems.
Setting up a connection is what a modem should be capable of, so I expect it known about dual-tone multi-frequency dialing. I have no idea why you would want more tones once the connection got established, and I don't know whether a modem could generate more tones when connected; I do know my phone can: if I press a button in the middle of a conversation, you can hear the DTMF.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
modified on Friday, June 10, 2011 8:44 PM
|
|
|
|
|
Ohhhhhhhhhhhhh,...
Sorry. I meant to imply that once the application dials a phone number, has a delay (so it can dial extensions) it plays a wav file to the mailbox it dials. So it simply calls an IVR here at the office and leaves someone a voice mail. The wav played is not DTMF but a voice that we choose.
|
|
|
|
|
PS, I gave 'good answer'
|
|
|
|
|
Reply to my own message is what I want.
I want to find the best voice modem out there (but it is ok to have some short comings as it seems there is no clear winner). What are your thoughts as per voice modems? I'm not concerned over flash-hangups (line switch) but mainly want to be able to send wav's to a modem to play after dialing and navigating through an IVR. So I can conquer the initial menu navigation with delays in the ATD command but after that simply need to leave a message (internal alert type system from server).
any recommendations on the optimal voice modem?
modified on Thursday, June 2, 2011 2:54 PM
|
|
|
|
|