|
If you want to keep the compiler happy you should watch the balance of symbols that come in pairs, such as { and }.
And if you want help around here, you'd better read the "how to get an answer" message on this page. Showing exact symptoms (compiler errors, run-time exceptions,...) is essential. Putting code snippets in PRE tags is highly recommended too.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Pete and Luc both raise valid points.
How to fix them:
1) When you post a code fragment, use the "code block" widget to put <pre> and </pre> tags around it: this preserves the indentation and formatting and makes it a lot easier to read!
2) As Luc said, you do need to balance all "matched pairs": every '(' must have it's ')', every '{' must have it's '}', and so on:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("wellcome to");
Console.Write(" " + args[0]);
Console.WriteLine(" " + args[1]);
}
}
} Your program should now compile cleanly.
3) You also need (as Pete said) to check your inputs: what if you didn't provide any command line parameters?
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
if (args.Length >= 2)
{
Console.Write("wellcome to");
Console.Write(" " + args[0]);
Console.WriteLine(" " + args[1]);
}
else
{
Console.WriteLine("Usage: ConsoleApplication1 YourName");
}
}
}
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Hi All,
Does anyone know how to move/copy an email from one folder to another in C#?
Thank you,
Melanie
|
|
|
|
|
In Outlook? In Exchange? In Thunderbird?
|
|
|
|
|
Thank you for your quick reply, sorry about the lack of info.
It's an Exchange email account that I'm processing emails from using SmtPop.
http://csharpopensource.com/smtpopdotnet.aspx[^]
However, certain emails I'm wanting to copy to a seperate folder.
Thanks,
Mel
|
|
|
|
|
Mel, you can accomplish this using the Exchange Web Services. The method you want is MoveItem[^].
|
|
|
|
|
Pete,
Great, thank you I'll give that a go and let you know how it goes.
Mel
|
|
|
|
|
Excellent. Good luck.
|
|
|
|
|
Just a quick question can Exchange Web Services be used in windows applications as well as web apps?
Also, do you have an example of how to use the CopyItem method?
Thank you,
Mel
|
|
|
|
|
Dear programmers have a question, I have the contents of the database are displayed on the listview. Suppose we have a row numbers 1,2,3,4,5. after the removal of such line number 2, line numbers will be 1,3,4,5. How to do that after deleting a row will automatically renumber as 1,2,3,4. Thanks in advance
|
|
|
|
|
If they are coming from a database directly into the listview, there is a very good chance that the nunbers are the record ID in the database, and an even better chance that they are autonumber - i.e. the database assigns them, incrementing as it goes, and you do not have to worry about duplicates, because the database will not allow that.
If so, then do not attempt to change them: in the real world changing a record ID is not a good thing to do, and it can cause enormous problems, even if the database would let you - which for autonumber fields it won't.
Hide the column instead, if it offends you!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I think this is a very correct answer to this question. The same question was posted in the Questions & Answers sections too..
|
|
|
|
|
Hi,
I am trying to do an app which has children windows inside it, and make it capable of when drag the mouse off the parent window it undocks and float all around the desktop, but for some reason i can seem to accomplish this. I am using the SetWindowLong method to change style of the window from WS_CHILD to WS_POPUP but it doesn't work, can someone please show me some code to make it work
long lastStyle = NativeMethods.GetWindowLong(myControl.Handle,
(int)NativeMethods.GetWindowLongConst.GWL_EXSTYLE);
long newStyle = NativeMethods.SetWindowLong(myControl.Handle,
(int)NativeMethods.GetWindowLongConst.GWL_STYLE,
(uint)NativeMethods.WindowStyles.WS_POPUP);
newStyle = NativeMethods.SetWindowLong(myControl.Handle,
(int)NativeMethods.GetWindowLongConst.GWL_EXSTYLE,
(long)(NativeMethods.WindowStylesEx.WS_EX_APPWINDOW | NativeMethods.WindowStylesEx.WS_EX_TOOLWINDOW));
myControl.Location = new Point(100, 200);
|
|
|
|
|
I would like to search through the buttons of a window handle and search for a specific button and if it exists perform an action, is there a way to do this?
If not, how can I identify a button and simulate a click based on the following info?
Thanks for reading!
>>>> Window <<<<
Title: HP OpenView ServiceCenter - Main Menu: HP OpenView ServiceCenter Client
Class: SWT_Window0
Position: 0, 90
Size: 1680, 960
Style: 0x96CF0000
ExStyle: 0x00100100
Handle: 0x005E24D6
>>>> Control <<<<
Class: SWT_Window0
Instance: 73
ClassnameNN: SWT_Window073
Name:
Advanced (Class): [CLASS:SWT_Window0; INSTANCE:73]
ID: 5510298
Text:
Position: 582, 407
Size: 57, 49
ControlClick Coords: 42, 30
Style: 0x56010000
ExStyle: 0x00100000
Handle: 0x0054149A
>>>> Mouse <<<<
Position: 632, 575
Cursor ID: 0
Color: 0x1272FA
>>>> StatusBar <<<<
>>>> ToolsBar <<<<
>>>> Visible Text <<<<
Top
Utilities
Maintenance
>>>> Hidden Text <<<<
|
|
|
|
|
If its a real native Win32 button, you can use FindWindow or FindWindowEx to find the window and send a BM_CLICK or WM_COMMAND message with SendMessage. If its not a native button (i.e. a WPF app, etc.), you can't do that and your only option is to simulate a mouse click with the mouse_event API.
|
|
|
|
|
Hi,
Thank you for the reply, do you have any code examples for this, I'm having a hard time finding anything online that looks like it will work with what I am doing. Or that will work with the window information I posted in my initial post. I do not believe it is a real native Win32 button.
|
|
|
|
|
Well, I don't have the HP openview software, so I couldn't tell you for sure. I don't know what tool your initial output is from, so try use Spy++ (comes with Visual Studio) instead. Use the binocular tool (6th button) then drag the cross hair thingy onto the title bar of the window and hit ok. NOTE: you need to start the HP app first, the refresh in the new Spy++ doesn't always work. Anyways... after you hit ok, you'll go to the window tree. You can expand the tree and see what controls are there. If the button is listed, its a native control. You might need to drill down in the tree to find it. Or you can just drag the cross hair directly onto the button.
If its not a native button, or even something like a toolbar its trickier... but it seems like from your output you can find the button of interest and get its screen rectangle. So then just use mouse_event() http://msdn.microsoft.com/en-us/library/ms646260(v=vs.85).aspx to simulate left button down | left button up at the absolute screen coordinates.
|
|
|
|
|
Hi,
Thanks again for the reply.
The cross hairs option gave me this, it looks like the button stays in the same general area no matter the window size, but its Class Name is not usable (all buttons are named that) and it does not seem to have any other uniquely identifiable information about it?
Is my best option the coordinates based mouse click?
Properties for window 0x00592342
Item Value
Class Name SWT_Window0
Text
Rectangle 576, 545, 633, 594
Size 57, 49
Client Rectangle 0, 0, 57, 49
Client Size 57, 49
Styles WS_CHILD
WS_VISIBLE
WS_CLIPSIBLINGS
WS_CLIPCHILDREN
WS_TABSTOP
StylesEx WS_EX_LEFT
WS_EX_LTRREADING
WS_EX_RIGHTSCROLLBAR
WS_EX_NOINHERITLAYOUT
ID 5841730
Properties Atom: #43288 0xFFFFFFFF (-1)
Class specific Window is Ansi
Owner EXE C:\Program Files\Peregrine Systems\ServiceCenter 6.2\Client\jre\bin\javaw.exe
|
|
|
|
|
Ok, so its a custom control with a class name of "SWT_Window0", so you can't search by class name. As you said, all the buttons have the same class name. It also doesn't seem to store the button text in the standard location, so you can't use that either. Hard coding the window coordinates is not a good idea because if they redesign the screen, your app will break.
It looks like your best bet is to get the button by ID (5841730), to do that, you kind of need to navigate down the tree yourself... what I mean is lets say the window structure is like this:
TopLevelWindow
|- Button you want
so you'd find the TopLevelWindow with FindWindow() (using the classname or window text) and get the HWND and then you'd use that in a call to GetDlgItem() using the 5841730 to get the button.
if the window structure is something like:
TopLevelWindow
|- Some other window
|- Button you want
you'd have to get the "some other window" somehow to use GetDlgItem() or you'd have to recurse through all the windows.
Once you get button HWND, you'd call GetWindowRect() on it to get the screen coordinates and then use the mouse_event with the absolute flag to do the left down and left up. Multi-monitors are handled by the APIs already.
|
|
|
|
|
Hey,
Thanks for taking so much time to help, I just closed and reopened the application and the ID actually changed, this time it was 3738914.
Is there a way to search through, maybe I could use that to identify it?
Thanks for the help.
Properties for window 0x00390D22
Item Value
Class Name SWT_Window0
Text
Rectangle 2275, 506, 2332, 555
Size 57, 49
Client Rectangle 0, 0, 57, 49
Client Size 57, 49
Styles WS_CHILD
WS_VISIBLE
WS_CLIPSIBLINGS
WS_CLIPCHILDREN
WS_TABSTOP
StylesEx WS_EX_LEFT
WS_EX_LTRREADING
WS_EX_RIGHTSCROLLBAR
WS_EX_NOINHERITLAYOUT
ID 3738914
Properties Atom: #43288 0xFFFFFFFF (-1)
Class specific Window is Ansi
Owner EXE C:\Program Files\Peregrine Systems\ServiceCenter 6.2\Client\jre\bin\javaw.exe
|
|
|
|
|
If there is nothing unique about the window, then there is not much you can do. You need a bullet proof way to ID the window. What if they happened to move a "format hard drive" button there?
|
|
|
|
|
Haha, that'd be real bad
I was hoping I could recursively search through the buttons somehow?
Maybe I could use reflector on the exe and decompile it? I'm not real familiar with reflector but maybe I could figure it out?
I've always had the mindset that anything that can be done by a person, can be imitated with code?
|
|
|
|
|
Actually I'm not sure if the mouse click will work because we have 2 monitors here and the coordinates of the button will change if it is on the other monitor.
|
|
|
|
|
If you are planning on doing a considerable amount of interacting with *other* applications I would suggest looking into this:
http://www.autoitscript.com/site/[^]
I wrote and posted a .NET wrapper on their forums.
You can do all sorts of cool stuff like find and interact with any class (buttons, listviews, etc..)
Only native Win32 classes of course tho.
|
|
|
|
|
Hi Jason,
I actually learned to code on AutoIT, so I am very fond of it
Do you post under the same user name over there so I can search for your .net wrapper?
If you look at my original button identification code in this post, you'll notice I used AuInfo.exe to capture that information, I think AIT at least identifies a classNN name for it
Thanks!
|
|
|
|
|