Frage Antwort Tread zu Autoit

    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )

    • "Code"

      C-Quellcode

      1. ;~ Includes
      2. #include <ButtonConstants.au3>
      3. #include <EditConstants.au3>
      4. #include <GUIConstantsEx.au3>
      5. #include <WindowsConstants.au3>
      6. ;~ Form
      7. $Form1 = GUICreate("Form1", 131, 60, 192, 114)
      8. ;~ Input
      9. $prozess = GUICtrlCreateInput("", 8, 8, 121, 21)
      10. ;~ Buttons
      11. $Button1 = GUICtrlCreateButton("Prüfen/Starten", 24, 32, 83, 25, $WS_GROUP)
      12. ;~ Status
      13. GUISetState(@SW_SHOW)
      14. While 1
      15. $nMsg = GUIGetMsg()
      16. Switch $nMsg
      17. Case $GUI_EVENT_CLOSE
      18. Exit
      19. Case $Button1
      20. $prozessread = GUICtrlRead($prozess)
      21. If ProcessExists ("" & $prozessread) Then
      22. MsgBox (4068, "Info", "Der Prozess läuft grade!")
      23. Else
      24. ShellExecute ("Dateiname.Dateiformat", "" , "Pfad" , "run", @SW_SHOW)
      25. EndIf
      26. EndSwitch
      27. WEnd
      Alles anzeigen


      Du musst unten nurnoch Dateiname.Dateiformat ändern und den Pfad.
    • ich streng mich so an und es klappt nich ganz und du hast es sofort xD

      Hier meine Version...vllt kann mir da ja auch jmd weiterhelfen :D

      "Code"

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <WindowsConstants.au3>

      #Region ### START Koda GUI section ### Form=
      $Form1 = GUICreate("Form1", 455, 300, 193, 125)
      $Input1 = GUICtrlCreateInput("", 32, 120, 265, 21)
      $Input2 = GUICtrlCreateInput("", 32, 48, 265, 21)
      $Button1 = GUICtrlCreateButton("Check", 344, 48, 89, 25, 0)
      $Button2 = GUICtrlCreateButton("Prozess " & GUICtrlRead($Input1) & " starten", 200, 180, 201, 25, 0)
      $Button3 = GUICtrlCreateButton("Prozess suchen", 200, 150, 201, 25, 0)
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###

      While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
      Case $GUI_EVENT_CLOSE
      Exit
      Case $Button1
      If WinExists(GUICtrlRead($Input1)) Then
      MsgBox(1, "Prozess" & GUICtrlRead($Input1), "Der Prozess " & GUICtrlRead($Input1) & " wird bereits ausgeführt")
      Not
      MsgBox(1, "Prozess" & GUICtrlRead($Input1), "Der Prozess " & GUICtrlRead($Input1) & " ist nicht aktiv.")
      EndIf
      Case $Button3
      $sufu = FileOpenDialog(GUICtrlRead($Input1),@ScriptDir,GUICtrlRead($Input1) & (*.exe))
      GUICtrlSetData($Input1, $sufu)
      Case $Button2
      ShellExecute(GUICtrlRead($Input2))
      EndSwitch
      WEnd


      *EDIT*:

      @ Tekumi: warum nicht gleich n Input mit dem Pfad drin? ich denke nich, dass er das nur für einen Prozess machen will^^
    • Hätte da auch noch eine möglichkeit:
      "Code"

      C-Quellcode

      1. #include <ButtonConstants.au3>
      2. #include <EditConstants.au3>
      3. #include <GUIConstantsEx.au3>
      4. #include <StaticConstants.au3>
      5. #include <WindowsConstants.au3>
      6. #Region ### START Koda GUI section ### Form=
      7. $Form1 = GUICreate("Prozess check", 188, 59, 203, 144, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
      8. WinSetOnTop($Form1,"",1)
      9. $Prozessname = GUICtrlCreateInput("", 8, 8, 113, 21)
      10. $Check = GUICtrlCreateButton("Check", 128, 8, 59, 25, $BS_DEFPUSHBUTTON)
      11. $Label1 = GUICtrlCreateLabel("", 8, 40, 136, 17)
      12. $OT = GUICtrlCreateCheckbox("OT", 152, 40, 33, 17)
      13. GUICtrlSetState(-1,$Gui_CHECKED)
      14. GUISetState(@SW_SHOW)
      15. #EndRegion ### END Koda GUI section ###
      16. While 1
      17. $nMsg = GUIGetMsg()
      18. Switch $nMsg
      19. Case $GUI_EVENT_CLOSE
      20. Exit
      21. Case $OT
      22. If GUICtrlRead($OT) = $Gui_CHECKED Then
      23. WinSetOnTop($Form1,"",0)
      24. Else
      25. WinSetOnTop($Form1,"",1)
      26. EndIf
      27. Case $Check
      28. $Process=GUICtrlRead($Prozessname)
      29. If ProcessExists($Process) Then
      30. GUICtrlSetData($Label1,"Der Prozess ist gestartet")
      31. GUICtrlSetColor($Label1, 0x008000)
      32. Else
      33. GUICtrlSetData($Label1,"Der Prozess läuft nicht")
      34. GUICtrlSetColor($Label1, 0xFF0000)
      35. $Frage=MsgBox(4,"","Wollen sie die Anwendung starten?")
      36. If $Frage = 6 Then
      37. ShellExecute($Process)
      38. GUICtrlSetData($Label1,"Der Prozess ist gestartet")
      39. GUICtrlSetColor($Label1, 0x008000)
      40. EndIf
      41. EndIf
      42. EndSwitch
      43. WEnd
      Alles anzeigen


      :wink:
    • Danke, funktioniert soweit :D

      Ich hab mir aber noch überlegt, dass man Punkte bekommt (Sieg = 1, Niederlage = (-1), Gleichstand = 0). Ich schaff das aber nich so ganz xD Die Punkte werden in einem Label angezeigt:

      Quellcode

      1. $Label1 = GUICtrlCreateLabel($var2 & " Punkte", 32, 128, 193, 25, 0)


      Am Anfang natürlich 0 Punkte^^:

      Quellcode

      1. $var2 = "0"


      Und dann soll die Punktzahl, also $var2 verändert werden. ($1 = 1)

      Quellcode

      1. ($var2 - $1) = $var2


      Ich hab alles versucht, Klammern nicht, da, ohne "= $var2" etc... hat nicht geklappt xD Help pls^^
    • Hm geht immernoch nich, denke es liegt daran, dass ganz oben " $var2 = "0" " steht...

      Naja, hier ma mein Script, wird sicher leicht zu fixxen sein ;-)

      "Code"

      #include <ButtonConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <WindowsConstants.au3>

      $var = Random(1, 3, 1)
      $var2 = "0"
      $1 = 1

      #Region ### START Koda GUI section ### Form=
      $Form1 = GUICreate("Form1", 259, 155, 193, 125)
      $Schere = GUICtrlCreateButton("Schere", 32, 32, 193, 25, 0)
      $Stein = GUICtrlCreateButton("Stein", 32, 64, 193, 25, 0)
      $Papier = GUICtrlCreateButton("Papier", 32, 96, 193, 25, 0)
      $Label1 = GUICtrlCreateLabel($var2 & " Punkte", 32, 128, 193, 25, 0)
      GUISetState(@SW_SHOW)
      #EndRegion ### END Koda GUI section ###

      While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
      Case $GUI_EVENT_CLOSE
      Exit
      Case $Schere
      If $var = 1 Then
      MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Papier. 1 Punkt für dich!")
      $var2 +=1
      ElseIf $var = 2 Then
      MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Stein. 1 Punkt Abzug.")
      $var2 -=1
      ElseIf $var = 3 Then
      MsgBox(1, "Gleichstand.", "Der Computer hatte Schere, genau wie du. Kein Punkt.")
      EndIf
      Case $Stein
      If $var = 1 Then
      MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Schere. 1 Punkt für dich!")
      $var2 +=1
      ElseIf $var = 2 Then
      MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Papier. 1 Punkt Abzug.")
      $var2 -=1
      ElseIf $var = 3 Then
      MsgBox(1, "Gleichstand.", "Der Computer hatte Stein, genau wie du. Kein Punkt.")
      EndIf
      Case $Papier
      If $var = 1 Then
      MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Stein. 1 Punkt für dich!")
      $var2 +=1
      ElseIf $var = 2 Then
      MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Schere. 1 Punkt Abzug.")
      $var2 -=1
      ElseIf $var = 3 Then
      MsgBox(1, "Gleichstand.", "Der Computer hatte Papier, genau wie du. Kein Punkt.")
      EndIf
      EndSwitch
      WEnd
    • Berichtigt wäre es dann so:

      C-Quellcode

      1. #include <ButtonConstants.au3>
      2. #include <GUIConstantsEx.au3>
      3. #include <WindowsConstants.au3>
      4. $var2 = "0"
      5. $1 = 1
      6. #Region ### START Koda GUI section ### Form=
      7. $Form1 = GUICreate("Form1", 259, 155, 193, 125)
      8. $Schere = GUICtrlCreateButton("Schere", 32, 32, 193, 25, 0)
      9. $Stein = GUICtrlCreateButton("Stein", 32, 64, 193, 25, 0)
      10. $Papier = GUICtrlCreateButton("Papier", 32, 96, 193, 25, 0)
      11. $Label1 = GUICtrlCreateLabel($var2 & " Punkte", 32, 128, 193, 25, 0)
      12. GUISetState(@SW_SHOW)
      13. #EndRegion ### END Koda GUI section ###
      14. While 1
      15. $nMsg = GUIGetMsg()
      16. Switch $nMsg
      17. Case $GUI_EVENT_CLOSE
      18. Exit
      19. Case $Schere
      20. $var = Random(1, 3, 1)
      21. If $var = 1 Then
      22. MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Papier. 1 Punkt für dich!")
      23. $var2 +=1
      24. ElseIf $var = 2 Then
      25. MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Stein. 1 Punkt Abzug.")
      26. $var2 -=1
      27. If $var2 < 0 Then
      28. $var2=0
      29. EndIf
      30. ElseIf $var = 3 Then
      31. MsgBox(1, "Gleichstand.", "Der Computer hatte Schere, genau wie du. Kein Punkt.")
      32. EndIf
      33. GUICtrlSetData($Label1,$var2 & " Punkte")
      34. Case $Stein
      35. $var = Random(1, 3, 1)
      36. If $var = 1 Then
      37. MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Schere. 1 Punkt für dich!")
      38. $var2 +=1
      39. ElseIf $var = 2 Then
      40. MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Papier. 1 Punkt Abzug.")
      41. $var2 -=1
      42. If $var2 < 0 Then
      43. $var2=0
      44. EndIf
      45. ElseIf $var = 3 Then
      46. MsgBox(1, "Gleichstand.", "Der Computer hatte Stein, genau wie du. Kein Punkt.")
      47. EndIf
      48. GUICtrlSetData($Label1,$var2 & " Punkte")
      49. Case $Papier
      50. $var = Random(1, 3, 1)
      51. If $var = 1 Then
      52. MsgBox(1, "Sieg!", "Glückwunsch! Du hast gewonnen! Der Computer hatte Stein. 1 Punkt für dich!")
      53. $var2 +=1
      54. ElseIf $var = 2 Then
      55. MsgBox(1, "Niederlage...", "Du hast leider verloren. Der Computer hatte Schere. 1 Punkt Abzug.")
      56. $var2 -=1
      57. If $var2 < 0 Then
      58. $var2=0
      59. EndIf
      60. ElseIf $var = 3 Then
      61. MsgBox(1, "Gleichstand.", "Der Computer hatte Papier, genau wie du. Kein Punkt.")
      62. EndIf
      63. GUICtrlSetData($Label1,$var2 & " Punkte")
      64. EndSwitch
      65. WEnd
      Alles anzeigen

      Hab gleich noch eingebaut, dass man nicht ins minus gehen kann :wink:
    • 1. was hast du genau geändert?
      2. es soll aber ins minus gehn xD
      3. wenn ich es starte kommt immer dasselbe ergebnis (z.b. sieg), wenn ich es schließ und wieder öffne kommt ebenfalls immer dasselbe, jedoch irgendein anderes (z.b. gleichstand)

      *EDIT*: 3. hat sich geklärt.
      Ich glaub, ich mach es so, dass man auswählen kann, ob es ins Minus geht oder nicht^^
      *EDIT2*: 1 und 2 haben sich ebenfalls geklärt. du hast lediglich "GUICtrlSetData($Label1,$var2 & " Punkte")" dazu geschrieben. Mir würde es nächstes mal mehr helfen, wenn du einfach sagen würdest "Versuch es mal mit GUICtrlSetData", aber trotzdem danke ;-D
      *EDIT3*: (xD) ok, du hast das random noch überall einzeln hingeschrieben, wodurch auch verschiedene werte kommen :-)