![]() |
| |||
| A ver si me explico : tengo 2 programas.exe, el exe1 y el exe2 En el exe1 tengo una coleccion y un timer que constantemente esta comprobando si hay algun elemento en la coleccion para tratarlo. Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del exe1, no se si esto se puede hacer. Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se traten las lineas muy rapido, pero realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir no se si afecta al rendimiento el tener el interval tan bajo. un saludo y gracias. |
| | ||||
| ||||
| |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |||
| Lairon wrote: > A ver si me explico : > tengo 2 programas.exe, el exe1 y el exe2 > > En el exe1 tengo una coleccion y un timer que constantemente esta > comprobando si hay algun elemento en la coleccion > para tratarlo. > > Lo que necesito es, desde el exe2 enviar un elemento a la coleccion del > exe1, no se si esto se puede hacer. > > Por cierto el interval del timer del exe1 lo tengo = 1, necesito que se > traten las lineas muy rapido, pero > realmente no se si es correcto y deberia ponerlo por ejemplo a 100, es decir > no se si afecta al rendimiento > el tener el interval tan bajo. > un saludo y gracias. > > puedes usar la api para encontrar a tu exe y mandarle despues lo que quieras... baja el api-guide que será una ayuda de lo mejorcito para tal situación. aquí un ejemplo que abre el notepad y se queda con su Wnd: ---------------------------------------- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long Const GW_HWNDNEXT = 2 Dim mWnd As Long Function InstanceToWnd(ByVal target_pid As Long) As Long Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long 'Find the first window test_hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While test_hwnd <> 0 'Check if the window isn't a child If GetParent(test_hwnd) = 0 Then 'Get the window's thread test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then InstanceToWnd = test_hwnd Exit Do End If End If 'retrieve the next window test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT) Loop End Function Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim Pid As Long 'Lock the window update LockWindowUpdate GetDesktopWindow 'Execute notepad.Exe Pid = Shell("c:\windows\notepad.exe", vbNormalFocus) If Pid = 0 Then MsgBox "Error starting the app" 'retrieve the handle of the window mWnd = InstanceToWnd(Pid) 'Set the notepad's parent SetParent mWnd, Me.hwnd 'Put the focus on notepad Putfocus mWnd 'Unlock windowupdate LockWindowUpdate False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unload notepad DestroyWindow mWnd 'End this program TerminateProcess GetCurrentProcess, 0 End Sub ---------------------------------------- aqui se busca el notepad para imprimir su ventana: ---------------------------------------- Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim mWnd As Long 'launch notepad Shell "notepad.exe", vbNormalNoFocus DoEvents 'set the graphics mode to persistent Me.AutoRedraw = True 'search the handle of the notepad window mWnd = FindWindow("Notepad", vbNullString) If mWnd = 0 Then Me.Print "NotePad window not found!" Else 'draw the image of the notepad window on our form PrintWindow mWnd, Me.hDC, 0 End If End Sub ---------------------------------------- aqui se cambia el texto de una ventana: ---------------------------------------- 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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(100, Chr$(0)) 'Get the windowtext GetWindowText Me.hwnd, MyStr, 100 'strip the rest of buffer MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1) 'Triple the window's text MyStr = MyStr + MyStr + MyStr 'Set the new window text SetWindowText Me.hwnd, MyStr End Sub ---------------------------------------- pillamos texto de una ventana: ---------------------------------------- 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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam***Allapi.net Dim MyStr As String 'Create a buffer MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) 'Get the window's text GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub ---------------------------------------- y en fin.. api-guide posee todos estos ejemplos y muchos más. |
| |
| |
![]() |
| Herramientas | |
| Desplegado | |
| |
Temas Similares | ||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| colección Age | María Eugenia Ryan | Newsgroup microsoft.public.es.ageofempires | 48 | 19-09-2005 20:12:45 |
| COLECCION DE 7 VIDAS EN DVD (39 DVD´S) | Juan José | Newsgroup es.rec.coleccionismo | 0 | 10-07-2005 17:20:28 |
| Re: COLECCION DE MICS | _libra_ | Newsgroup es.rec.musica.blues | 112 | 15-11-2004 18:28:39 |
| Re: COLECCION DE MICS | dº!ºb | Newsgroup es.rec.musica.blues | 7 | 01-11-2004 21:31:21 |
| Colección Nintendo 64 | Showtime | Newsgroup es.comp.emuladores | 0 | 19-08-2003 12:04:48 |