with sendkeys, you can activate a window, and then send keys to that window, correct?
Well - all i need is to extract data directly from a window, active or not... Problem is that it is possible to do with a macro in an emulator of some sort, called 'EXTRA! Office client'. However this program is not available to me at work.
Du skal have fat i hWnd for den TekstBox som du vil aflæse indholdet af. Herefter kan du bruge GetWindowText til at aflæse teksten.
Her et eksempel : Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Const GW_HWNDFIRST = 0 Private Const GW_HWNDNEXT = 2 Private Const GW_CHILD = 5
'Find hWnd på det window (Form) der indeholder tekstboksen 'I dette eksempel er teksten i titellinien : WindowCaption hwnd = FindWindow(vbNullString, "WindowCaption")
'Kig alle Controls efter for at finde tekstboksen hWndChild = GetWindow(hwnd, GW_CHILD) Do DoEvents Class = String(1024, 0) Retn = GetClassName(hWndChild, Class, 1024) If Retn > 0 Then Class = Left(Class, Retn) Else Class = "" If Class = "ThunderTextBox" Then Caption = String(1024, 0) Retn = GetWindowText(hWndChild, Caption, 1024) If Retn > 0 Then Caption = Left(Caption, Retn) Else Caption = "" MsgBox "Tekst i tekstbox:" & Caption End If hWndChild = GetWindow(hWndChild, GW_HWNDNEXT) Loop Until hWndChild = 0
Jeg er kommet så langt, at jeg nok må kombinere et hotlink mellem 5250 emulatoren og Excel - og så sendkeys.
Dette vil give mig mulighed for at aflæse data fra en position på skærmen og gemme dette i et excel felt. Ganske som Copy'n Paste. Derefter kan jeg så skifte skærmbillede og via sendkeys indsætte værdien på dne rigtige plads.
Dog er dette en langsom løsning og man skal opdatere sine hotlinks hver gang man loader sit regneark...
Desværre heller ikke lige noget jeg kan bruge. Lige i øjeblikket bruger jeg AutoIt fra Hiddensoft.com - fantastisk stykke software. Dog tror jeg at jeg går tilbage til sendkeys når jeg engang får ordentlig styr på de DDE links jeg bruger i øjeblikket.
Jeg tror jeg har trukket tiden længe nok med dette spørgsmål. Det er på tide at stille et nyt :o)
Link til eksempel (udvikleren skriver: "Start this project, go to another application, type something, switch back to this application and unload the form. If you unload the form, a messagebox with all the typed keys will be shown."): http://www.mentalis.org/apilist/64BED1F862145FDD4477424686646320.html
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.