Icons per relativer Pfadangabe in ein Script einbinden, welches in ein anderes eingebunden wird

  • Hallo zusammen,

    ich habe ein Script, was ich so erstellt habe, dass es per #include in ein anderes Script eingebunden werden kann. In dem Script, was eingebunden werden soll, ist auch eine GUI enthalten, die Icons besitzt. Es ist so konzepiert, dass ich es auch anderen zugänglich machen möchte...
    Nun habe ich aber folgendes Problem: Die Pfadangaben zu den Icons müssten jedes Mal angepasst werden, da das Script sie nicht selbst ermitteln kann.
    Gibt es eine Möglichkeit, wie ich das Script so gestalten kann, dass es selbst weiß, wo die Icons sind, egal wo man das ganze hinkopiert?
    Ich weiß ja, dass das geht, sofern die Icons sich in einem Ordner oder Unterordner mit dem Script befinden. Leider ist das ja nicht von dem einzubindenden Script, sondern von dem Script abhängig, in das es eingebunden wird.

    Kann mir da vielleicht jemand weiterhelfen?

    LG FKFK

  • Hi,

    also #include ist ja das selbe, wie einfach den code aus der include in das originalscript zu kopieren. (soweit ich weiss).
    Das heisst, wenn du erst beispielsweise eine Variable $Pfad anlegst ( im Hauptscript ), danach das andere Unterscript includest, müsstest du in dem Unterscript auf die Variable Pfad zugreifen können.
    Beispiel:

    [autoit]

    ;Hauptscript
    $Pfad = @scriptdir
    Msgbox(0,"","Ich bin das hauptscript.")
    #include "unterscript.au3"

    [/autoit][autoit]

    ;unterscript.au3
    Msgbox(0,"","Pfad des Hauptscriptes: " & $Pfad)

    [/autoit]

    Hoffe hab dich richtig verstanden.
    greetz

  • Hm, genau das ist das Problem: Es wird kopiert.
    Leider sollen die Pfade zu den Icons im Unterscript liegen, was reinkopiert wird. Daher ist es wahrscheinlich auch nicht möglich, die Pfade per Variable zu übernehmen oder?

  • das verstehe ich jetzt nicht, der pfad kann doch auch in der include sein Oo
    Beispiel:

    [autoit]

    ;die include.au3
    $Pfad = "blalala" ;oder @scriptdir oder whatever

    [/autoit][autoit]

    ;Hauptscript
    #include "include.au3"
    Msgbox(0,"",$Pfad)

    [/autoit]

    @scriptdir ist allerdings egal wo man es aufruft immer das selbe, weils nunmal ein und das selbe script is un auch ein und die selbe exe sein wird.

  • Hm, das mit der Variable müsste natürlich gehen, aber dann muss es halt immer auf jedem PC angepasst werden.
    Da sich das Unterscript mit den Icons an einem anderen Ort, als das Hauptscript befindet, wird Scriptdir nicht funktionieren. Ich überlege mir aber, ob ich es vielleicht so konzipieren soll, dass es in den AutoIT-Include-Ordner kopiert werden muss, weil dann alle Pfad-Dateien feststehen...

  • Hier mal ein Auszug aus dem Script:

    Mein Script
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    ;Declares the PIN
    Global $_PIN

    [/autoit] [autoit][/autoit] [autoit]

    #Region GUI/Func
    Func _PIN_Win($left = -1, $top = -1, $timeout = "")
    If Not IsNumber($timeout) And Not $timeout == "" Or $timeout < 0 Then Return SetError(1, 0, 0)
    If $left < -1 Or $top < -1 Then Return SetError(1, 0, 0)
    Local $btn, $msg, $btn1, $btn2, $btn3, $btn4, $btn5, $btn6, $btn7, $btn8, $btn9, $btn0, $E, $OldCoord, $begin, $activate
    $activate = 1
    If $timeout == 0 Or $timeout == "" Then $activate = 0

    [/autoit] [autoit][/autoit] [autoit]

    $OldCoord = Opt("GUICoordMode", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $_PIN = "" ;PIN beeing deleted
    $begin = TimerInit() ;the timer beeing started
    GUICreate("", 109.5, 148, $left, $top)
    ;Button1
    $btn1 = GUICtrlCreateButton("", -1, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_1.ico")
    ;Button2
    $btn2 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_2.ico")
    ;Button3
    $btn3 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_3.ico")
    ;Button4
    $btn4 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_4.ico")
    ;Button5
    $btn5 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_5.ico")
    ;Button6
    $btn6 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_6.ico")
    ;Button7
    $btn7 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_7.ico")
    ;Button8
    $btn8 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_8.ico")
    ;Button9
    $btn9 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_9.ico")
    ;Button0
    $E = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_E.ico")
    ;E-Button
    $btn0 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_0.ico")
    ;C-Button (OK-Button)
    $btn = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @ScriptDir & "/Images/_C.ico")
    GUISetState()
    ;Check which buttons are pressed and react proportionally
    $msg = 0
    While 1
    $msg = GUIGetMsg()
    If $msg == $GUI_EVENT_CLOSE Then Exit
    Select
    Case $msg = $btn
    ExitLoop
    Case $msg = $btn1
    $_PIN &= 1
    Case $msg = $btn2
    $_PIN &= 2
    Case $msg = $btn3
    $_PIN &= 3
    Case $msg = $btn4
    $_PIN &= 4
    Case $msg = $btn5
    $_PIN &= 5
    Case $msg = $btn6
    $_PIN &= 6
    Case $msg = $btn7
    $_PIN &= 7
    Case $msg = $btn8
    $_PIN &= 8
    Case $msg = $btn9
    $_PIN &= 9
    Case $msg = $btn0
    $_PIN &= 0
    Case $msg = $E
    $_PIN = ""
    Case $timeout < TimerDiff($begin) And $activate == 1
    ExitLoop
    EndSelect
    WEnd
    GUIDelete()
    Opt("GUICoordMode", $OldCoord)
    EndFunc
    #EndRegion GUI/Func

    [/autoit]


    Wie man vielleicht erkennt, soll es ein PIN-Pad darstellen, welches in verschiedene Scripte eingebunden werden soll...

    Wenn ich mir es recht überlege: Wenn ich eine exe erstelle, dann muss ich doch die Icons wahrscheinlich in die Exe integrieren oder? Wie mache ich das am besten?

  • Schau dir mal Fileinstall in der Hilfe an, damit kannst du Dateien in die Exe einbinden und nachher an einen beliebigen Ort entpacken ;)

    Ja, stimmt. Danke!
    Gibt es eigentlich noch eine Alternative dazu, dass man das Unterscript entweder in den AutoIT-Include Ordner kopieren muss oder den Pfad zu den Icons dort selbst eintragen muss?

  • So, hier nochmal der aktuelle Stand:

    mein Script
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.6.0
    Author: Florian Kurrle
    Sript Version: 2.1
    Version: 1.0-The main features was developed
    2.0-English is mainlanguage and now the buttons are icons and look how a real code-pad
    2.1-The time-function was developed

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Creates a Window, where you can enter a PIN with your mouse and which can output the PIN as variable

    [/autoit] [autoit][/autoit] [autoit]

    Syntax: _PIN_Win([left[, top[, timeout]]])
    timeout = the time after that the window will be closed in milliseconds
    Return values: Success 1
    Failure 0 and set @error to 1. This can happend only when there beeing passed wrong parameters.

    [/autoit] [autoit][/autoit] [autoit]

    Usage: #include <PINPad\PINPad.au3> (at first you must copy the hole folder in the standart include-folder)
    $_PIN is the entered PIN
    When you press the E-button, you delete the entered PIN
    When you press the C-butto, you confirm the entered PIN

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ButtonConstants.au3>
    #include-once

    [/autoit] [autoit][/autoit] [autoit]

    #Region File Install
    DirCreate(@TempDir & "/PINPad/")
    FileInstall(@AutoItExe & "..\Include\PINPad\Images\_0.ico", @TempDir & "/PINPad/_0.ico", 1)
    FileInstall("Images\_1.ico", @TempDir & "/PINPad/_1.ico", 1)
    FileInstall("Images\_2.ico", @TempDir & "/PINPad/_2.ico", 1)
    FileInstall("Images\_3.ico", @TempDir & "/PINPad/_3.ico", 1)
    FileInstall("Images\_4.ico", @TempDir & "/PINPad/_4.ico", 1)
    FileInstall("Images\_5.ico", @TempDir & "/PINPad/_5.ico", 1)
    FileInstall("Images\_6.ico", @TempDir & "/PINPad/_6.ico", 1)
    FileInstall("Images\_7.ico", @TempDir & "/PINPad/_7.ico", 1)
    FileInstall("Images\_8.ico", @TempDir & "/PINPad/_8.ico", 1)
    FileInstall("Images\_9.ico", @TempDir & "/PINPad/_9.ico", 1)
    FileInstall("Images\_C.ico", @TempDir & "/PINPad/_C.ico", 1)
    FileInstall("Images\_E.ico", @TempDir & "/PINPad/_E.ico", 1)
    #EndRegion File Install

    [/autoit] [autoit][/autoit] [autoit]

    ;Declares the PIN
    Global $_PIN

    [/autoit] [autoit][/autoit] [autoit]

    #Region GUI/Func
    Func _PIN_Win($left = -1, $top = -1, $timeout = "")
    If Not IsNumber($timeout) And Not $timeout == "" Or $timeout < 0 Then Return SetError(1, 0, 0)
    If $left < -1 Or $top < -1 Then Return SetError(1, 0, 0)
    Local $btn, $msg, $btn1, $btn2, $btn3, $btn4, $btn5, $btn6, $btn7, $btn8, $btn9, $btn0, $E, $OldCoord, $begin, $activate
    $activate = 1
    If $timeout == 0 Or $timeout == "" Then $activate = 0

    [/autoit] [autoit][/autoit] [autoit]

    $OldCoord = Opt("GUICoordMode", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $_PIN = "" ;PIN beeing deleted
    $begin = TimerInit() ;the timer beeing started
    GUICreate("", 109.5, 148, $left, $top)
    ;Button1
    $btn1 = GUICtrlCreateButton("", -1, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_1.ico")
    ;Button2
    $btn2 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_2.ico")
    ;Button3
    $btn3 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_3.ico")
    ;Button4
    $btn4 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_4.ico")
    ;Button5
    $btn5 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_5.ico")
    ;Button6
    $btn6 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_6.ico")
    ;Button7
    $btn7 = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_7.ico")
    ;Button8
    $btn8 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_8.ico")
    ;Button9
    $btn9 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_9.ico")
    ;Button0
    $E = GUICtrlCreateButton("", -74, 37, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_E.ico")
    ;E-Button
    $btn0 = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_0.ico")
    ;C-Button (OK-Button)
    $btn = GUICtrlCreateButton("", 37, -1, 37, 37, 0x0040)
    GUICtrlSetImage(-1, @TempDir & "/PINPad/_C.ico")
    GUISetState()
    ;Check which buttons are pressed and react proportionally
    $msg = 0
    While 1
    $msg = GUIGetMsg()
    If $msg == $GUI_EVENT_CLOSE Then Exit
    Select
    Case $msg = $btn
    ExitLoop
    Case $msg = $btn1
    $_PIN &= 1
    Case $msg = $btn2
    $_PIN &= 2
    Case $msg = $btn3
    $_PIN &= 3
    Case $msg = $btn4
    $_PIN &= 4
    Case $msg = $btn5
    $_PIN &= 5
    Case $msg = $btn6
    $_PIN &= 6
    Case $msg = $btn7
    $_PIN &= 7
    Case $msg = $btn8
    $_PIN &= 8
    Case $msg = $btn9
    $_PIN &= 9
    Case $msg = $btn0
    $_PIN &= 0
    Case $msg = $E
    $_PIN = ""
    Case $timeout < TimerDiff($begin) And $activate == 1
    ExitLoop
    EndSelect
    WEnd
    GUIDelete()
    Opt("GUICoordMode", $OldCoord)
    EndFunc
    #EndRegion GUI/Func

    [/autoit]

    Wie gesagt: Folgendes Problem existiert:
    1. es gibt ein Script, dass ein Pin-Pad darstellt 2. dieses hat icons für die Tasten 3. die icons befinden sich in einem Ordner, der beim Pin-Pad-Script dabei ist 4. das Pin-Pad-Script soll in ein andres Script eingebunden werden 5. nun ist aber das Problem, wie ich die Icons ansteuern soll, da sich das Script ja eingebunden in einem andren befindet

    Ein Beispiel-Test-Script:

    Test-Script
    [autoit]

    #include <PINPad\PINPad.au3>
    Opt("GUICoordMode", 1)
    _PIN_Win(-1, -1)

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(64, "", $_PIN)

    [/autoit]
  • 2 Wege

    1. Icons alle in eine Dll packen und diese als Binärstring in die UDF einfügen. Beim Aufruf Dll temporär erstellen und Icons laden.
    2. Analog zu 1. aber ohne Dll sondern für jede ICO-Datei eigener Binärstring.

    Was genau meinst du mit Binärstring?