Deutsches AutoHotkey Homepage AutoHotkey Community
Wir helfen uns gegenseitig aus der Patsche
 
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

Variable von script1 zu script2 übergeben

 
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe!
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
syswar



Anmeldedatum: 24.12.2007
Beiträge: 14

BeitragVerfasst am: Mi Jan 30, 2008 2:31 pm    Titel: Variable von script1 zu script2 übergeben Antworten mit Zitat

Hallo,

ich habe hier zwei seperat laufende Scripte.

Ist es möglich eine Variable von Script1 zu Script2 zu übergeben außer mit Clipboard.

Hintergrund: Ich möchte mit Script1 ( ohne gui ) ein Listvieweintrag in Script 2 ( mit Gui) anstoßen.

Clipboard funktioniert zwar, ist mir aber zu unsicher.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Amiga-Falcon



Anmeldedatum: 24.12.2006
Beiträge: 215

BeitragVerfasst am: Mi Jan 30, 2008 3:52 pm    Titel: Antworten mit Zitat

Wie wär´s mit einer (Art) INI-datei ?
Schau Dir mal "IniRead / INIWrite" in der Hilfe an...

Andernfalls ginge das noch über eine AHK-Script- oder eine BATch-Datei.

Script 1 schreibt in diese Datei.
Script 2 prüft alle x Sekunden/Minuten/Stunden das Vorhandensein eben dieser Datei, startet, bzw. verarbeitet sie und löscht sie anschließend wieder.

Das war jetzt "so auf die Schnelle aus´m Hut" eine Idee...

Amiga-Falcon
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
IsNull



Anmeldedatum: 20.12.2006
Beiträge: 1326
Wohnort: CH

BeitragVerfasst am: Mi Jan 30, 2008 8:37 pm    Titel: Antworten mit Zitat

Code:
; Example: Send a string of any length from one script to another.  This is a working example.
; To use it, save and run both of the following scripts then press Win+Space to show an
; InputBox that will prompt you to type in a string.

; Save the following script as "Receiver.ahk" then launch it:
OnMessage(0x4a, "Receive_WM_COPYDATA")  ; 0x4a is WM_COPYDATA
return

Receive_WM_COPYDATA(wParam, lParam)
{
    lpDataAddress := lParam + 8  ; This is the address of CopyDataStruct's lpData member.
    lpData := 0  ; Init prior to accumulation in the loop.
    Loop 4  ; For each byte in the lpData integer
    {
        lpData := lpData | (*lpDataAddress << 8 * (A_Index - 1))  ; Build the integer from its bytes.
        lpDataAddress += 1  ; Move on to the next byte.
    }
    ; lpData contains the address of the string to be copied (must be a zero-terminated string).
    DataLength := DllCall("lstrlen", UInt, lpData)
    if DataLength <= 0
        ToolTip %A_ScriptName%`nA blank string was received or there was an error.
    else
    {
        VarSetCapacity(CopyOfData, DataLength)
        DllCall("lstrcpy", "str", CopyOfData, "uint", lpData)  ; Copy the string out of the structure.
        ; Show it with ToolTip vs. MsgBox so we can return in a timely fashion:
        ToolTip %A_ScriptName%`nReceived the following string:`n%CopyOfData%
    }
    return true  ; Returning 1 (true) is the traditional way to acknowledge this message.
}
Code:

; Save the following script as "Sender.ahk" then launch it.  After that, press the Win+Space hotkey.
TargetScriptTitle = Receiver.ahk ahk_class AutoHotkey

#space::  ; Win+Space hotkey. Press it to show an InputBox for entry of a message string.
InputBox, StringToSend, Send text via WM_COPYDATA, Enter some text to Send:
if ErrorLevel  ; User pressed the Cancel button.
    return
result := Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
if result = FAIL
    MsgBox SendMessage failed. Does the following WinTitle exist?:`n%TargetScriptTitle%
else if result = 0
    MsgBox Message sent but the target window responded with 0, which may mean it ignored it.
return

Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle)  ; ByRef saves a little memory in this case.
; This function sends the specified string to the specified window and returns the reply.
; The reply will be 1 if the target window processed the message or 0 if it ignored it.
{
    VarSetCapacity(CopyDataStruct, 12, 0)  ; Set up the structure's memory area.
    ; First set the structure's cbData member to the size of the string, including its zero terminator:
    NumPut(StrLen(StringToSend) + 1, CopyDataStruct, 4)  ; OS requires that this be done.
    NumPut(&StringToSend, CopyDataStruct, 8)  ; Set lpData to point to the string itself.
    Prev_DetectHiddenWindows := A_DetectHiddenWindows
    Prev_TitleMatchMode := A_TitleMatchMode
    DetectHiddenWindows On
    SetTitleMatchMode 2
    SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle%  ; 0x4a is WM_COPYDATA. Must use Send not Post.
    DetectHiddenWindows %Prev_DetectHiddenWindows%  ; Restore original setting for the caller.
    SetTitleMatchMode %Prev_TitleMatchMode%         ; Same.
    return ErrorLevel  ; Return SendMessage's reply back to our caller.
}
Cool

Arrow http://www.autohotkey.com/docs/commands/OnMessage.htm
_________________

http://securityvision.ch
www.forum.securityvision.ch
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
syswar



Anmeldedatum: 24.12.2007
Beiträge: 14

BeitragVerfasst am: Do Jan 31, 2008 2:12 pm    Titel: Antworten mit Zitat

@Amiga-Falcon

Eine weitere Datei wollte ich eigentlich nicht nutzen.

Trotzdem vielen Dank für deinen Vorschlag

@IsNull

Das muss ich mir mal genauer ansehen.

Auch dir vielen Dank
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    AutoHotkey Community Foren-Übersicht -> Ich brauche Hilfe! Alle Zeiten sind GMT
Seite 1 von 1

 
Gehe zu:  
Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.


Powered by phpBB © 2001, 2005 phpBB Group
Deutsche Übersetzung von phpBB.de