AutoIT Script unter Visual Basic parallel ausführen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von musabe24.

    AutoIT Script unter Visual Basic parallel ausführen

    Hallo!
    Ich habe bereits eine Visual Basic Software geschrieben. Diese Software will ich nun wie folgt erweitern:
    Auf Knopfdruck soll demonstriert werden, was die Software so kann.
    Das wollte ich mit AutoIT lösen.
    Nun habe ich eine Visual Basic Software und einen AutoIT Script, der meine Software sozusagen "bedient".
    Mein Wunsch ist: Über die AutoIT Library für Visual Studio würde ich gerne meine AutoIT Software in meine Visual Basic Software einbinden.
    Doch dann habe ich das Problem, dass AutoIT meine Software bedient, meine Software aber auf die ganzen Mausklicks gar nicht reagiert.
    Ich denke das liegt daran, dass ich nur einen Prozess für Visual Basic und AutoIT habe. Somit kann Visual Basic erst wieder reagieren, wenn der AutoIT Script zuende geht.
    Gibt es dafür eine Abhilfe?

    Wäre dankbar für Eure Hilfe.

    Hier der Programmteil mit AutoIT:

    VB.NET-Quellcode

    1. Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
    2. Me.Close()
    3. Dim AutoIT As New AutoItX3Lib.AutoItX3
    4. AutoIT.AutoItSetOption("MouseCoordMode", 2)
    5. AutoIT.ControlFocus("Notizen", "", "[NAME:TextBoxNotiz]")
    6. AutoIT.Send("H")
    7. AutoIT.Sleep(100)
    8. AutoIT.Send("e")
    9. AutoIT.Sleep(100)
    10. AutoIT.Send("l")
    11. AutoIT.Sleep(100)
    12. AutoIT.Send("l")
    13. AutoIT.Sleep(100)
    14. AutoIT.Send("o")
    15. AutoIT.Sleep(100)
    16. AutoIT.Send(".")
    17. AutoIT.Sleep(500)
    18. Dim ContrPosX
    19. Dim ContrPosY
    20. ContrPosX = AutoIT.ControlGetPosX("Notizen", "Einstellungen", "[NAME:ButtonEinstellungen]")
    21. ContrPosY = AutoIT.ControlGetPosY("Notizen", "Einstellungen", "[NAME:ButtonEinstellungen]")
    22. AutoIT.MouseClick("left", ContrPosX + 61, ContrPosY + 10)
    23. AutoIT.Sleep(500)
    24. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Rot", "[NAME:Button4]")
    25. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Rot", "[NAME:Button4]")
    26. AutoIT.MouseClick("left", ContrPosX + 74, ContrPosY + 11)
    27. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    28. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    29. AutoIT.MouseClick("left", ContrPosX + 126, ContrPosY + 12)
    30. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Benutzerdefiniert", "[NAME:Button7]")
    31. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Benutzerdefiniert", "[NAME:Button7]")
    32. AutoIT.MouseClick("left", ContrPosX + 74, ContrPosY + 11)
    33. AutoIT.Sleep(500)
    34. ContrPosX = AutoIT.ControlGetPosX("Farbe", "", "[CLASS:Static; INSTANCE:2]")
    35. ContrPosY = AutoIT.ControlGetPosY("Farbe", "", "[CLASS:Static; INSTANCE:2]")
    36. AutoIT.MouseClick("left", ContrPosX + 196, ContrPosY + 121)
    37. ContrPosX = AutoIT.ControlGetPosX("Farbe", "OK", "[CLASS:Button; INSTANCE:2]")
    38. ContrPosY = AutoIT.ControlGetPosY("Farbe", "OK", "[CLASS:Button; INSTANCE:2]")
    39. AutoIT.MouseClick("left", ContrPosX + 34, ContrPosY + 13)
    40. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    41. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    42. AutoIT.MouseClick("left", ContrPosX + 179, ContrPosY + 10)
    43. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Schrift 2", "[NAME:Button16]")
    44. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Schrift 2", "[NAME:Button16]")
    45. AutoIT.MouseClick("left", ContrPosX + 49, ContrPosY + 10)
    46. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "benutzerdefiniert", "[NAME:Button20]")
    47. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "benutzerdefiniert", "[NAME:Button20]")
    48. AutoIT.MouseClick("left", ContrPosX + 48, ContrPosY + 12)
    49. AutoIT.Sleep(500)
    50. ContrPosX = AutoIT.ControlGetPosX("Schriftart", "", "[CLASS:ComboLBox; INSTANCE:3]")
    51. ContrPosY = AutoIT.ControlGetPosY("Schriftart", "", "[CLASS:ComboLBox; INSTANCE:3]")
    52. AutoIT.MouseClick("left", ContrPosX + 11, ContrPosY + 34)
    53. ContrPosX = AutoIT.ControlGetPosX("Schriftart", "OK", "[CLASS:Button; INSTANCE:5]")
    54. ContrPosY = AutoIT.ControlGetPosY("Schriftart", "OK", "[CLASS:Button; INSTANCE:5]")
    55. AutoIT.MouseClick("left", ContrPosX + 38, ContrPosY + 12)
    56. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    57. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    58. AutoIT.MouseClick("left", ContrPosX + 236, ContrPosY + 11)
    59. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TrackBar1]")
    60. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TrackBar1]")
    61. AutoIT.MouseClickDrag("left", ContrPosX + 299, ContrPosY + 12, ContrPosX + 242, ContrPosY + 11)
    62. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    63. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    64. AutoIT.MouseClick("left", ContrPosX + 294, ContrPosY + 10)
    65. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Immer im Vordergrund", "[NAME:CheckBox1]")
    66. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Immer im Vordergrund", "[NAME:CheckBox1]")
    67. AutoIT.MouseClick("left", ContrPosX + 5, ContrPosY + 8)
    68. AutoIT.WinActivate("Einstellungen")
    69. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Schließen", "[NAME:Button14]")
    70. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Schließen", "[NAME:Button14]")
    71. AutoIT.MouseClick("left", ContrPosX + 39, ContrPosY + 11)
    72. End Sub


    Ich weiß, das ist nicht wirklich professionell, aber ich mache das eigentlich nur nebenher und nur für mich. :D

    *Topic verschoben*

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()

    Danke für die Antwort!
    Das werde ich jetzt mal ausprobieren.

    Edit:

    So habe das Problem endlich gelöst durch erstellen eines neues Threads. Wieder mal was Neues dazugelernt. Falls jemand ein ähnliches Problem hat, hier meine Lösung:

    VB.NET-Quellcode

    1. Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
    2. Me.Close()
    3. Dim NeuerThread As System.Threading.Thread
    4. NeuerThread = New System.Threading.Thread(AddressOf Me.Demonstrator)
    5. NeuerThread.Start()
    6. End Sub
    7. Private Sub Demonstrator()
    8. Dim AutoIT As New AutoItX3Lib.AutoItX3
    9. AutoIT.AutoItSetOption("MouseCoordMode", 2)
    10. AutoIT.ControlFocus("Notizen", "", "[NAME:TextBoxNotiz]")
    11. AutoIT.Send("H")
    12. AutoIT.Sleep(100)
    13. AutoIT.Send("e")
    14. AutoIT.Sleep(100)
    15. AutoIT.Send("l")
    16. AutoIT.Sleep(100)
    17. AutoIT.Send("l")
    18. AutoIT.Sleep(100)
    19. AutoIT.Send("o")
    20. AutoIT.Sleep(100)
    21. AutoIT.Send(".")
    22. AutoIT.Sleep(500)
    23. Dim ContrPosX
    24. Dim ContrPosY
    25. ContrPosX = AutoIT.ControlGetPosX("Notizen", "Einstellungen", "[NAME:ButtonEinstellungen]")
    26. ContrPosY = AutoIT.ControlGetPosY("Notizen", "Einstellungen", "[NAME:ButtonEinstellungen]")
    27. AutoIT.MouseClick("left", ContrPosX + 61, ContrPosY + 10)
    28. AutoIT.Sleep(500)
    29. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Rot", "[NAME:Button4]")
    30. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Rot", "[NAME:Button4]")
    31. AutoIT.MouseClick("left", ContrPosX + 74, ContrPosY + 11)
    32. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    33. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    34. AutoIT.MouseClick("left", ContrPosX + 126, ContrPosY + 12)
    35. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Benutzerdefiniert", "[NAME:Button7]")
    36. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Benutzerdefiniert", "[NAME:Button7]")
    37. AutoIT.MouseClick("left", ContrPosX + 74, ContrPosY + 11)
    38. AutoIT.Sleep(500)
    39. ContrPosX = AutoIT.ControlGetPosX("Farbe", "", "[CLASS:Static; INSTANCE:2]")
    40. ContrPosY = AutoIT.ControlGetPosY("Farbe", "", "[CLASS:Static; INSTANCE:2]")
    41. AutoIT.MouseClick("left", ContrPosX + 196, ContrPosY + 121)
    42. ContrPosX = AutoIT.ControlGetPosX("Farbe", "OK", "[CLASS:Button; INSTANCE:2]")
    43. ContrPosY = AutoIT.ControlGetPosY("Farbe", "OK", "[CLASS:Button; INSTANCE:2]")
    44. AutoIT.MouseClick("left", ContrPosX + 34, ContrPosY + 13)
    45. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    46. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    47. AutoIT.MouseClick("left", ContrPosX + 179, ContrPosY + 10)
    48. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Schrift 2", "[NAME:Button16]")
    49. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Schrift 2", "[NAME:Button16]")
    50. AutoIT.MouseClick("left", ContrPosX + 49, ContrPosY + 10)
    51. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "benutzerdefiniert", "[NAME:Button20]")
    52. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "benutzerdefiniert", "[NAME:Button20]")
    53. AutoIT.MouseClick("left", ContrPosX + 48, ContrPosY + 12)
    54. AutoIT.Sleep(500)
    55. ContrPosX = AutoIT.ControlGetPosX("Schriftart", "", "[CLASS:ComboLBox; INSTANCE:3]")
    56. ContrPosY = AutoIT.ControlGetPosY("Schriftart", "", "[CLASS:ComboLBox; INSTANCE:3]")
    57. AutoIT.MouseClick("left", ContrPosX + 11, ContrPosY + 34)
    58. ContrPosX = AutoIT.ControlGetPosX("Schriftart", "OK", "[CLASS:Button; INSTANCE:5]")
    59. ContrPosY = AutoIT.ControlGetPosY("Schriftart", "OK", "[CLASS:Button; INSTANCE:5]")
    60. AutoIT.MouseClick("left", ContrPosX + 38, ContrPosY + 12)
    61. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    62. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    63. AutoIT.MouseClick("left", ContrPosX + 236, ContrPosY + 11)
    64. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TrackBar1]")
    65. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TrackBar1]")
    66. AutoIT.MouseClickDrag("left", ContrPosX + 299, ContrPosY + 12, ContrPosX + 242, ContrPosY + 11)
    67. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "", "[NAME:TabControl1]")
    68. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "", "[NAME:TabControl1]")
    69. AutoIT.MouseClick("left", ContrPosX + 294, ContrPosY + 10)
    70. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Immer im Vordergrund", "[NAME:CheckBox1]")
    71. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Immer im Vordergrund", "[NAME:CheckBox1]")
    72. AutoIT.MouseClick("left", ContrPosX + 5, ContrPosY + 8)
    73. AutoIT.WinActivate("Einstellungen")
    74. ContrPosX = AutoIT.ControlGetPosX("Einstellungen", "Schließen", "[NAME:Button14]")
    75. ContrPosY = AutoIT.ControlGetPosY("Einstellungen", "Schließen", "[NAME:Button14]")
    76. AutoIT.MouseClick("left", ContrPosX + 39, ContrPosY + 11)
    77. End Sub


    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „musabe24“ ()