Fremde Anwendung auf dem Monitor verschieben / Monitor wechseln

  • VB6

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Schamash.

    Fremde Anwendung auf dem Monitor verschieben / Monitor wechseln

    Hallo zusammen,

    Ich hab da mal ein Problem:

    Ich versuche aus meinem Program ein anderes Program auf den 2. Bildschirm zu verschieben.
    Jetzt habe ich das Problem dass, das Verschieben beim ersten mal Funktioniert aber beim 2. mal nicht mehr.

    Visual Basic-Quellcode

    1. Public Sub TmrMonitor(ByVal sender As Object, ByVal e As EventArgs)
    2. If Warten Then
    3. For Each Me.oProcess In oProcessList
    4. Debug.Print(oProcess.MainWindowTitle)
    5. If oProcess.MainWindowTitle.Contains("Bankarbeitsplatz") Then
    6. fenster = oProcess.MainWindowHandle
    7. ShowWindow(fenster, 1)
    8. SetForegroundWindow(fenster)
    9. System.Threading.Thread.Sleep(400)
    10. If Screen.AllScreens.Length = 2 Then
    11. Select Case Monitor
    12. Case 1
    13. Case 2
    14. SetWindowPos(oProcess.MainWindowHandle, 0, 1280, 10, 0, 0, &H1)
    15. End Select
    16. End If
    17. Warten = False
    18. End If
    19. Next
    20. End If
    21. End Sub


    Visual Basic-Quellcode

    1. <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
    2. Private Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr,
    3. X As Integer, Y As Integer,
    4. cx As Integer, cy As Integer,
    5. uFlags As Integer) As Boolean
    6. End Function


    Danke schon vorab für die Mühen.
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    Ich hab zwar keine Ahnung was die Variable "Warten" macht, aber bist du dir sicher, dass du dir vor dem 2. Aufruf auch wieder auf true setzt?

    FlashTek schrieb:

    Ich hab zwar keine Ahnung was die Variable "Warten" macht, aber bist du dir sicher, dass du dir vor dem 2. Aufruf auch wieder auf true setzt?
    Ja sie wird von nach jedem Aufruf wieder auf True gesetzt.

    Die Variable "Warten" sorgt dafür das die suchschleife nur bei einem neuen Aufruf durchgeführt wird. Da das durchsuchen der Prozesse in einem Timerevent(alle 2sec) läuft.

    Ich habe die Vermutung das

    Visual Basic-Quellcode

    1. If oProcess2.MainWindowTitle = "agree Bankarbeitsplatz - Bedieneranmeldung" Then

    nicht mehr trifft.

    Allerdings verstehe ich das nicht da wie das sein kann da ich das gleiche Programm aufrufe.
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."
    Thema Erledigt!

    Ich habs gefunden.
    Ich hab vergessen die ProcessList neu zu füllen. Da das Programm einige Zeit zum Starten braucht war es beim ersten versuch noch nicht geladen und entsprechend wurde es NIE gefunden.

    So funktioniert es dann :)

    Danke für die Unterstützung.

    Visual Basic-Quellcode

    1. If Warten Then
    2. Dim oProcessList As Process() = Process.GetProcesses
    3. Dim oProcess As Process
    4. For Each oProcess In oProcessList
    5. Debug.Print(oProcess.MainWindowTitle)
    6. If oProcess.MainWindowTitle.Contains("Bankarbeitsplatz") Then
    7. '.....
    There is no CLOUD - just other people's computers

    Q: Why do JAVA developers wear glasses?
    A: Because they can't C#

    Daily prayer:
    "Dear Lord, grand me the strength not to kill any stupid people today and please grant me the ability to punch them in the face over standard TCP/IP."