2

I am creating an application that is supplimenting the data provided on our third part application. They don't have an open API so I have been force to using WM_GETTEXT to get the information that we are looking at. This works fine for the the window titles but some of the windows I need to find a unique identifier on the screen. If I click or tab through the box I need I get the text. If I don't however it only returns blank.

It's pretty simple code and if I have to I can write a wrapper in c++ though I'd prefer not to at the moment (I figure I'll have to for performance reasons later but right now I'm just trying to identify all the information I need for the full application later on)

StringBuilder sb = new StringBuilder(1024);

length = SendMessage(hWnd, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);

int successText = (int)SendMessage(hWnd, WM_GETTEXT, (IntPtr)sb.Capacity, sb);

I have tried just sending a bunch of tab key presses but even using the keybd_event it takes about a full second to iterate through all 44 fields back to the starting field which isn't really acceptable.

If it is any help the original application is a late 90's powerbuilder app.

  • 3
    It's possible that PowerBuilder isn't actually populating the windows control until it gets focus but paints the contents of non-focused controls as graphics. You should be able to SetFocus to the control you need, though, rather than tabbing through all of them. – 500 - Internal Server Error Apr 04 '13 at 17:24
  • So I tried the SetFocus (and a few other things) it doesn't seem to work. Sorry about how long it took to reply I wanted to check it on the console instead of remote just in case it was something to do with Terminal Services but that didn't seem to be it either. I don't know the winapi basically at all, is there anything that tabbing does besides just switching the focuse? – user2245977 Apr 08 '13 at 19:54
  • I wouldn't have thought so, but conceivably the application can do something special when TAB is handled. – 500 - Internal Server Error Apr 08 '13 at 20:41
  • Well ultimately since I couldn't think of anything else I had to move the mouse over click it and click at the opening field again and then back to where it started. I tried it while moving the mouse around in circles so it doesn't appear thats going to screw it up and the cursor moves and is back to its position so fast I doubt most will even know it happened except for the flicker on textboxes as they are activated the immediately deactivated. – user2245977 Apr 10 '13 at 00:41

0 Answers0