Jump to content

Recommended Posts

Posted

Hallo Leute!

Ich bin ganz neu und versuche mich mit AutoIt :D

Ich habe erfolgreich meine erste GUI erstellt und möchte das ich, wenn ich einen Button klicke, ein anderes "programm" ausgeführt wird.

Mit @ScriptDir funktioniert es, aber warum nicht mit @TempDir?

 

mehr im Anhang!

Danke im vorhinein :3

Unbenannt1.JPG

Unbenannt2.JPG

Unbenannt3.JPG

Posted (edited)

Könntest Du bitte das vollständige Skript posten. Verwende dazu das Code-Tag < > und keinen Screenshot. Ich hoffe mal, die unkenntlich gemachten Dateinamen deuten nicht auf eine Spieleautomation hin ;).

Could you please post the entire script. Use the code tag < > and not a screenshot. I hope the obscured file names do not indicate a game automation.

 

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
FileInstall("C:\Users\Startklar\Desktop\skripten\heinrich.jpg", @TempDir & "\heinrich.jpg",1)
FileInstall("C:\Users\Startklar\Desktop\skripten\divi.jpg", @TempDir & "\divi.jpg",1)
FileInstall("C:\Users\Startklar\Desktop\skripten\Program1.exe", @ScriptDir & "\Program1.exe")
FileInstall("C:\Users\Startklar\Desktop\skripten\Program2.exe", @ScriptDir & "\Program2.exe")
FileInstall("C:\Users\Startklar\Desktop\skripten\Program3.exe", @ScriptDir & "\Program3.exe")



#include <GUIConstantsEx.au3>

SplashTextOn("AYE", "Neubienen wissen nichts über Krautchan", 500, 120)
Sleep(10000)
SplashOff()


Example ()

Func Example()

    Local $hGUI = GUICreate("AYE", 325, 400, 1300, 200)

    Local $beenden = GUICtrlCreateButton("Exit", 230, 370, 85, 25)

    Local $B7 = GUICtrlCreateButton("Program1", 5, 160, 85, 25)
    Local $B11= GUICtrlCreateButton("Program2", 5, 40, 85, 25)
    Local $B12 = GUICtrlCreateButton("Program3", 5, 10, 85, 25)

    Local $pic1 = GUICtrlCreatePic(@TempDir & "\heinrich.jpg", 95, 10, 220, 355)
    Local $pic2 = GUICtrlCreatePic(@TempDir & "\divi.jpg", 5, 370, 220, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE, $beenden
                ExitLoop
             Case $B7
                Run("C:\User\Startklar\Desktop\Skripten\Program1.exe")
             Case $B11
                ShellExecute("C:\Users\Startklar\Desktop\skripten\Program2", @TempDir & "\Program2.exe")
             Case $B12
                ShellExecute("C:\Users\Startklar\Desktop\skripten\Program3.exe", @TempDir & "\Program3.exe")
        EndSwitch
    WEnd



    GUIDelete($hGUI)

   FileDelete("C:\Users\Startklar\Desktop\Program1.exe")
   FileDelete("C:\Users\Startklar\Desktop\Program2.exe")
   FileDelete("C:\Users\Startklar\Desktop\Program3.exe")
   FileDelete("C:\Users\Startklar\Desktop\heinrich.jpg")
   FileDelete("C:\Users\Startklar\Desktop\divi.jpg")

 EndFunc

 

Posted

(Apology to the other members that I answer here in German)

Vorab : Dein Code ist etwas Kraut und Rüben :lol:.

In welchem Verzeichnis befindet sich dein Skript (danach orientiert sich ja "@ScriptDir" ?

Du verwendest FileInstall um Dateien aus C:\Users\Startklar\Desktop\skripten\ einzubinden und nach "@temp" zu installieren. Dann musst Du sie aber auch von dort starten und später wieder entfernen.

Nebenbei : Eigene Skripte unter C:\Users\Startklar\Desktop\skripten\ zu entwickeln ist ggf. auch nicht der beste Ort.

Dieser Code funktioniert (allerdings mit Demografiken, da ich Deine ja nicht habe) :

#include <GUIConstantsEx.au3>

FileInstall("C:\Users\Startklar\Desktop\skripten\heinrich.jpg", @TempDir & "\heinrich.jpg", 1)
FileInstall("C:\Users\Startklar\Desktop\skripten\divi.jpg", @TempDir & "\divi.jpg", 1)
FileInstall("C:\Users\Startklar\Desktop\skripten\Program1.exe", @TempDir & "\Program1.exe", 1)
FileInstall("C:\Users\Startklar\Desktop\skripten\Program2.exe", @TempDir & "\Program2.exe", 1)
FileInstall("C:\Users\Startklar\Desktop\skripten\Program3.exe", @TempDir & "\Program3.exe", 1)

ConsoleWrite(@TempDir & @CRLF)
If FileExists(@TempDir & "\heinrich.jpg") Then
    ConsoleWrite("File exists" & @CRLF)
Else
    ConsoleWrite("File not exists" & @CRLF)
EndIf

SplashTextOn("AYE", "Neubienen wissen nichts über Krautchan", 500, 120)
Sleep(2000)
SplashOff()

Example()

Func Example()

    Local $hGUI = GUICreate("AYE", 325, 400, 130, 200)

    Local $beenden = GUICtrlCreateButton("Exit", 230, 370, 85, 25)

    Local $B7  = GUICtrlCreateButton("Program1", 5, 10, 85, 25)
    Local $B11 = GUICtrlCreateButton("Program2", 5, 40, 85, 25)
    Local $B12 = GUICtrlCreateButton("Program3", 5, 70, 85, 25)

    Local $pic1 = GUICtrlCreatePic(@TempDir & "\heinrich.jpg", 95, 10, 220, 355)
    Local $pic2 = GUICtrlCreatePic(@TempDir & "\divi.jpg", 5, 370, 220, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE , $beenden
                ExitLoop
            Case $B7
                Run(@TempDir & "\Program1.exe", "", @SW_MAXIMIZE)
            Case $B11
                Run(@TempDir & "\Program2.exe", "", @SW_MAXIMIZE)
            Case $B12
                Run(@TempDir & "\Program3.exe", "", @SW_MAXIMIZE)
        EndSwitch
    WEnd

    GUIDelete($hGUI)

    FileDelete(@TempDir & "\heinrich.jpg")
    FileDelete(@TempDir & "\divi.jpg")
    FileDelete(@TempDir & "\Program1.exe")
    FileDelete(@TempDir & "\Program2.exe")
    FileDelete(@TempDir & "\Program3.exe")
EndFunc   ;==>Example

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

Lieber Musashi,

Ich hab mir diese GUI zusammengebaut aus allem möglichen was das Internet so hergibt .. xD

Nein Ich will ja kein @ScriptDir, Ich will eim @TempDir, das alle Programme nach dem schliessen gelöscht werden!

Es funktioniert alles einwandfrei. ja natürlich könnte man es besser machen, aber ich bin anfängerin & will einfach das es funktioniert:3

 

Mein Problem; ich starte das Program also die GUI, dann klick ich auf einen Button z.B. Program1 aber es öffnet/ startet nicht, warum?

ich hab schon so vieles versucht, ob ich zu dumm bin?

 

Das mit FileDelete ist unnötig wenn ich es im @TempDir habe, oder?

 

Grüsse Vika

Posted

Musashi :D

Vielen Dank für deine Hilfe!

Nun funktioniert es & ich glaube ich habe es verstanden wie es funktioniert  :D

 

hast du verbesserungsvorschläge?

würde mich gern verbessern :3

 

  • Moderators
Posted (edited)

@TmF_Viktorija As this is an English speaking forum, please use Google translate to help you post in English.

If that is difficult for you, what you should have received above is a link to the German forum: https://autoit.de/

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...