|
Hi guys. I'd like to simulate keyboard keystrokes and not everything is working.
I'm using Postmessage and Sendmessage API.
Sending a character is simple using PostMessage(handle, WM_KEYDOWN, key, IntPtr.Zero), but I can't simulate key combos like shift+1 or capslock+a. For the combos here's what I tried:
PostMessage(handle, WM_SYSKEYDOWN, VK_CAPITAL, new IntPtr(1));
PostMessage(handle, WM_KEYDOWN, VK_A, IntPtr.Zero);
PostMessage(handle, WM_KEYUP, VK_A, new IntPtr(1));
PostMessage(handle, WM_SYSKEYUP, VK_CAPITAL, new IntPtr(1));
|
|
|
|
|
Did you look at the SendKeys API in the .NET framework?
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
SendKeys.Send is the first thing I tried, but it was limited: I can't send ctrl+shift among other things.
|
|
|
|
|
xax wrote: I can't send ctrl+shift among other things.
You're wrong, you can send CTRL+Shift using SendKeys[^].
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
At the top of your class:
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);
Within your class you will need the following two methods:
private static void PressKey(byte keyCode)
{
keybd_event(keyCode, 0x45, 0, 0);
}
private static void ReleaseKey(byte keyCode)
{
keybd_event(keyCode, 0x45, 0x2, 0);
}
Simply send the correct keyCode to execute the press or release key method.
With these methods until the ReleaseKey method is called for a key it is held down by the PressKey method.
One word of warning - make sure you release all the pressed keys or wierd things will happen.
Regards
Guy
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
You'll give this a try. I've read that keybd_event is buggy.
Thanks.
|
|
|
|
|
xax wrote: I've read that keybd_event is buggy.
I hope not...
I use it in a commercial application I am developing for voice recognition.
I have had no problems in the testing environment with this.
The important bit is to make sure that you issue the keyRelease for all the keyPress(es).
Good luck.
Regards
Guy
P.S. I need to correct the information I gave you - when you issue the keyPress this counts as one keyPress.
This means that you may need to issue more than one keyPress for each key to keep it held down.
The way I get around this is I record the users keystrokes and play them back at the same rate that they were recorded.
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
hello sir,
my application is on c# and i have give connection string according to
machine name in app.config
"server="+Environment.MachineName+"\\"+this.instancename()+" ;Trusted_Connection=yes; database="+this.databasename()+"; Pooling=false"
thanks in advance
|
|
|
|
|
monu_khan wrote: i have give connection string
Do you also have a question?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Application configuration files are designed to provide this information without undo coding. Use the connection strings block in the xml to add connection string keys and then have your application blindly read it and use it.
Individual machines are responsible for their own configuration settings and that is the entire point of application configuration files.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
actually my problem is that how to pass enviornment.machinename value
<add key="con" value="server=Enviornment.Machinename\INFOSOFT\ist;database=sm;user id=sa;pwd=****" />
|
|
|
|
|
Hi!
I've got two picture boxes on my form. The variables "firstDice" and "secondDice" are two randomly generated integer values.
I've also got a label under each picturebox that shows the generated value just to be able to see if the right
picture is shown in the picturebox, but that's not always the case..
I'm pretty sure I'm doing something wrong in the code when the picture box is told its "file location", but what?
Code:
switch (firstDice)
{
case 1:
label1.Text = "1";
firstPictureLocation += "D:\\bilder\\1.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
case 2:
label1.Text = "2";
firstPictureLocation += "D:\\bilder\\2.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
case 3:
label1.Text = "3";
firstPictureLocation += "D:\\bilder\\3.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
case 4:
label1.Text = "4";
firstPictureLocation += "D:\\bilder\\4.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
case 5:
label1.Text = "5";
firstPictureLocation += "D:\\bilder\\5.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
case 6:
label1.Text = "6";
firstPictureLocation += "D:\\bilder\\6.gif";
picBoxDice1.ImageLocation = firstPictureLocation;
break;
}
switch (secondDice)
{
case 1:
label4.Text = "1";
secondPictureLocation += "D:\\bilder\\1.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
case 2:
label4.Text = "2";
secondPictureLocation += "D:\\bilder\\2.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
case 3:
label4.Text = "3";
secondPictureLocation += "D:\\bilder\\3.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
case 4:
label4.Text = "4";
secondPictureLocation += "D:\\bilder\\4.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
case 5:
label4.Text = "5";
secondPictureLocation += "D:\\bilder\\5.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
case 6:
label4.Text = "6";
secondPictureLocation += "D:\\bilder\\6.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
}
/Joplinazz
|
|
|
|
|
Joplinazz wrote: I'm pretty sure I'm doing something wrong in the code when the picture box is told its "file location", but what?
Well for one thing you have put VB style code in C#. That is not what the language was intended for.
Secondly, I would verify those paths for you but I can't seem to access your network.
Thirdly I would check to see if your code is upgradating the picture control but you did not post that code.
led mike
|
|
|
|
|
Err, yeah.
First problem:
switch (secondDice)
{
case 1:
label4.Text = "1";
secondPictureLocation += "D:\\bilder\\1.gif";
picBoxDice2.ImageLocation = firstPictureLocation;
break;
...
And second, why are you using += ? You should just be using = otherwise after a few changes, the path could look like this:
D:\\bilder\\1.gifD:\\bilder\\3.gifD:\\bilder\\2.gifD:\\bilder\\6.gif
And finally, you could ditch the switch statement and just use the generated number to get to the file, like:
firstPictureLocation = "D:\\bilder\\" + firstDice.ToString() + ".gif";
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Problem solved, I used Image img1 = Image.FromFile("D:\\bilder\\1.gif") and picBoxDice2.Image instead.
Thx both for your help though.
/Joplinazz
|
|
|
|
|
I'd suggest you put the below code in a method.
<br />
<br />
label.Text = ""; <br />
secondPictureLocation += "D:\\bilder\\number.gif"; picBoxDice.ImageLocation = firstPictureLocation;<br />
Coding 101, if something the same, or similar pops up more than 2 times give it it's own method.
|
|
|
|
|
I wanted to put some simple example code here to show how I am doing Data I/O between the BLL and the DL. Any comments would be great!
Data Layer DAO object:
public class CMItemDAO
{
public CMItemDAO()
{
//
// TODO: Add constructor logic here
//
}
public static IDataReader GetItems(int quantity, ItemManager.Item type)
{
string itemType = (type == ItemManager.Item.Document ? "SW" : "DOC");
String sSql = "SELECT CMLib_Key, CM_Number, Item_Name ";
sSql += "FROM ccdb.cclib WHERE Item_Type = :pITEMTYPE AND ROWNUM <= 10";
Database db = DatabaseFactory.CreateDatabase();
UserDBLogon(db, "xxxxxxxxx@xxxxxxxx.xxx", "WNhc(#111111111");
DbCommand cmd = db.GetSqlStringCommand(sSql);
db.AddInParameter(cmd, "pITEMTYPE", DbType.String, itemType);
return db.ExecuteReader(cmd);
}
------------How this is being called from the Business Layer:
public class ItemManager
{
public enum Item
{
Document,
Software
}
public ItemManager()
{
//
// TODO: Add constructor logic here
//
}
public static List<ICMItem> GetItems(int quantity, Item type)
{
Cache listCache = HttpRuntime.Cache;
List<ICMItem> list = new List<ICMItem>();
ICMItem iCMItem;
if (HttpRuntime.Cache["Item" + type.ToString()] != null &&
(HttpRuntime.Cache["Item" + type.ToString()] as List<ICMItem>).Count <= quantity)
{
list = ((HttpRuntime.Cache.Get("Item" + type.ToString()))) as List<ICMItem>;
list.RemoveRange(quantity, (list.Count - quantity));
}
else
{
using (IDataReader reader = CMItemDAO.GetItems(quantity, type))
{
while (reader.Read())
{
if (type == Item.Document)
iCMItem = new Document() as Document;
else
iCMItem = new Software();
iCMItem.CMLibraryKey = reader.GetInt32(0);
iCMItem.CMNumber = (string)reader[1];
if (reader.GetValue(2) != DBNull.Value)
iCMItem.ItemName = (string)reader.GetValue(2);
else
iCMItem.ItemName = "";
list.Add(iCMItem);
}
}
HttpRuntime.Cache.Insert("Item" + type.ToString(), list);
}
return list;
}
I hope this is not too much simple example code; however, any comments on how I am doing things would be great!
Thanks,
Steve
|
|
|
|
|
Business layer shouldn't know anything about the data layer internals. I mean data layer might be using database or some other data store. Business layer should be isolated. You are returning IDataReader instance and it tells your business layer knows about the data store. You should take a look at DTO (Data transfer object) for passing values between layers. (Information got from colin )
|
|
|
|
|
Hello all ,
I have developed a ecommerce web site, for which i want to integrate the payment gateway using paypal.
I want to accept the credit card details, user details such as Shipping, and billing and the contact details in my website. And process the payment using the Direct Payment API.
I tried since 5 to 6 days in the internet to search the solution to this problem, but i didn't got a single resource.
Also in paypal developer community and in paypal website, they have mentioned that, the Direct Payment API method will be applicable only to the US Customers. So it is not possible me to download any resources for this method.
Can any body help me regarding this problem. if any one has the solution this problem, please reply, or please provide any links, or some sample code for this problem in Asp.Net with C#.
Thank you,
regards,
|
|
|
|
|
Your best bet is to talk to the PayPal support folks and see if there are any other options opened to you.
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
You have not google it correctly.............. google it u will find code for it ,, with hidden tags in it ..and runat="server" to those and supply the values dynamically
It is simple .. i will fwd the complete code if possible
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
Use Google, I like their API better and use it for my purposes. Plus the TOS is so much better and the payment terms are more competitive. It is akin to having my own merchant account. (Google really should pay me for lauding their services so)
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I have added a NotifyIcon in Console application, but I am having a hard time disposing off the icon when the application exits.
Can anyone tell me the way ?
Thanks.
|
|
|
|
|
What do you mean? Are you talking about the way the icon stays in the tray, even after tha application exits until you hover over it, at which time it finally goes?
Because if you are it happens with everything. Before you exit you need to set the NotifyIcon'svisible property to false , then it will dissapear.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
He is running a NotifyIcon in Console app without a message pump...
|
|
|
|