INIRead durchsuch variable aus ComboBox

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

JoKu
Posts: 2
Joined: 04 Aug 2018, 10:44

INIRead durchsuch variable aus ComboBox

04 Aug 2018, 17:31

Hallo Leute um es kurz zu fassen, habe erst vor 2 Wochen angefangen mit AHK ein rum zu Spielen.
Ich habe leider auch keiner leid Vorkenntnisse von Script Sprachen. Dennoch hat es mir AHK angetan und ich habe richtig spass dabei. Vor 5 Tagen hab ich nun angefangen eine Hardware Inventarisierung Skript um zu setzen.
Ich benötige Hilfe bei dem Problem, wenn ich über die ComboBox vAbteilungen die Auswahl z.B. Marketing wähle. Möchte ich erreichen dass genau dieser Wert an das Ende Von Iniread als variables Gesetz wird. IniRead, SoftZuweisung, UserVerwaltung.ini, Settings, %Abteilungen% und diese Werte daraus dann an die Software ListBox übergeben.

Ich habe festgestellt dass wenn ich normale v Variable nehme werden mir alle Angaben aus der ini Gelistet und nicht nur Marketing.
Über die Globale Variable schaffe ich es nicht die Variabel zu übergeben und das GUI zu aktualisieren damit die neuen werte geladen werden.

Ich Hoffe dass versteht was ich möchte :roll: und mir helfen kann.

Danke schon einmal gruss JoKu







Code: Select all

#SingleInstance force       ; Bei Neustart des Scriptes die alte Instanz ohne Nachfrage ersetzen
 
MyXML:=new XML("Hardware","lib\PC-Server.xml")

GUI:
;############################### GUI ############################################
Gui, Color,
gui, font, s10 w700 q5, HandelGotDLig 
Gui +LastFound  

Gui, Add, Tab3, x10 y10 w600 h372 , PC|Drucker|Server|Eticketten-Drucker

IniRead, Betrieb, HardwareVerwaltung.ini, Settings, Betriebssystem   
IniRead, Mdl, HardwareVerwaltung.ini, Settings, ModellTyp
IniRead, Her, HardwareVerwaltung.ini, Settings, Hersteller
IniRead, Disp, HardwareVerwaltung.ini, Settings, Displayanschluss
IniRead, DDRRAM, HardwareVerwaltung.ini, Settings, RAM
IniRead, HDD, HardwareVerwaltung.ini, Settings, Speicher
IniRead, Proz, HardwareVerwaltung.ini, Settings, Prozessor
IniRead, Abt, UserVerwaltung.ini, Settings, Abteilung
IniRead, SoftZuweisung, UserVerwaltung.ini, Settings, %Abteilungen%           [color=#0000BF] ;Mit diesem IniRead versuchte die Auswahl Von vAbteilungen aus der ComboBox zu erhalten oder aus dem Label Abteilung:[/color]

       
{
    Gui, Tab, PC
    gui, font, s9 w600 q5, HandelGotDLig
    Gui, Add, Text, x20 y50 w100 h25 ,PcName
    Gui, Add, ComboBox, x20 y65 w100 h20 gPcName,
        Gui, Add, Text, x130 y50 w100 h25 ,Kaufdatum
        Gui, Add, DateTime, x130 y65 w100 h20 gKaufdatum ChooseNone, dd.mm.yyyy
            Gui, Add, Text, x260 y50 w100 h25 ,Hersteller
            Gui, Add, ComboBox, X260 y65 w100 h15 r5 gHersteller, %Her%           
                Gui, Add, Text, X390 y50 w100 h25, Model-Typ
                Gui, Add, ComboBox, X390 y65 w100 h15 r10 gModellTyp, %Mdl%
                
    Gui, Add, Text, x20 y135 w100 h25 ,Prozessor
    Gui, Add, ComboBox, x20 y150 w100 h20 r5 gProzessor, %Proz%
        Gui, Add, Text, x130 y135 w50 h25 ,RAM
        Gui, Add, ComboBox, x130 y150 w100 h20 r10 gRAM, %DDRRAM%
            Gui, Add, Text, x260 y135 w100 h25 ,HDD/SSD
            Gui, Add, ComboBox, x260 y150 w100 h20 r10 gHDDSSD, %HDD%  
                    Gui, Add, Text, x390 y135 w100 h25 ,Betriebssystem
                    Gui, Add, ComboBox, X390 y150 w100 h15 r5 gBetriebssystem, %Betrieb%
    Gui, Add, CheckBox, x30 y195 w100 h20 vWANModul,WAN Modul
    Gui, Add, Text, x20 y235 w100 h25, Displayanschluss
    Gui, Add, ComboBox, x20 y250 w100 h15 gDisplayAnschluss, %Disp%
    
            Gui, Add, Text, X200 y280 W100 h25 ,Serien Nr.
            Gui, Add, Edit, X200 y300 w200 h25 ,
                   
    Gui, Add, Button, x20 y350 w125 h20 gAuswahlHinzufuegen, HardwareHinzufügen

    
}


Gui, Add, Tab3, x630 y10 w600 h372 , Benutzer|Software|Zubehör
Gui, Tab, Benutzer
                                                     
    gui, font, s9, HandelGotDLig
    Gui, Add, Text, x650 y50 w100 h25 ,Benuzerzuweisen
    Gui, Add, Edit, x650 y65 w100 h20
        Gui, Add, Text, X760 y50 w100 h25, Geräte Abgabe
        Gui, Add, DateTime, x760 y65 w100 h20 vAbgabedatum ChooseNone,dd.mm.yyyy
             Gui, Add, Text, X870 y50 w100 h25, Rückgabe
             Gui, Add, DateTime, X870 Y65 w100 h20 vRückgabedatum ChooseNone,dd.mm.yyyy
    Gui, Add, Text, X650 y135 w100 h25,
    Gui, Add, ComboBox, X650 y150 w100 h15 r5 vAbteilungen gAbteilung ChooseNone , %Abt%   [color=#0000FF] ;In der ComboBox wird die auswahl getroffen für die weitergabe an das IniRead[/color]
        Gui, Add, Text, x760 y135 w120 h25, Telefon Nr.
        Gui, Add, Edit, x760 y150 w120 h20 vTelefonNr,
              
              
         
        Gui, Tab, Software
        Gui, Add, ListBox, x650 y40 w350 h350 gSofwareListe 8,%AktuelleStdSW%        [color=#0000FF];End ziel hier sollte das resultat von der auswahl VAbteilungen ComboBox angezeigt werden[/color]
        
        
        
Gui, Add, Tab3, x10 y390 w1220 h372 , Verlauf|Statistik
Gui, Tab, Verlauf
    
Gui, Show, w1240 h768, Hardware Verwaltung
                                          

;############################### Labels #########################################

Abteilung:
GuiControlGet, Abteilung,,
Msgbox, %Abteilung%
IniRead, AktuelleStdSW, UserVerwaltung.ini, Settings, %Abteilung%
GuiControl,, SoftwareListe, %AktuelleStdSW%
MsgBox, %AktuelleStdSW%

return
SofwareListe:
return           
AuswahlHinzufuegen:
{
run, AuswahlHinzufuegen.ahk
return
}             
    

PcName:
{
AutoComplete(A_GuiControl)
;ode:=MyXML.Add("Hardware",{Attribute:"ComputerName"},"%PcName%",0) ;Create a new Node Element
Return
}


Kaufdatum:
{
AutoComplete(A_GuiControl)
Return
}


Hersteller:
{    
AutoComplete(A_GuiControl)
Return
}


ModellTyp:
{
AutoComplete(A_GuiControl)
Return
}


Prozessor:
{
AutoComplete(A_GuiControl)
Return
}


RAM:
{
AutoComplete(A_GuiControl)
Return
}


HDDSSD:
{
AutoComplete(A_GuiControl)
Return
}


Betriebssystem:
{
AutoComplete(A_GuiControl)
Return
}


DisplayAnschluss:
{
AutoComplete(A_GuiControl)
Return
}





;############################### Autovervollständigen ##################################### 
AutoComplete(ctrl) 
{ 
      static lf = "`n"
       
          If GetKeyState("Delete") or GetKeyState("Backspace") 
          Return 
          
      SetControlDelay, -1 
      SetWinDelay, -1 
      GuiControlGet, h, Hwnd, %ctrl% 
      ControlGet, haystack, List, , , ahk_id %h% 
      GuiControlGet, needle, , %ctrl% 
      StringMid, text, haystack, pos := InStr(lf . haystack, lf . needle) 
      , InStr(haystack . lf, lf, false, pos) - pos

     If text !=
     {
        if pos != 0
        { 
           ControlSetText, , %text%, ahk_id %h% 
           ControlSend, , % "{Right " . StrLen(needle) . "}+^{End}", ahk_id %h% 
        } 
     }
} 
Return
GuiClose:
;MyXML.Transform() ;Makes the XML Pretty
;MyXML.Transform() ;Sometimes needed.
;mMyXML[] ;Shows a MsgBox with the contents of the new node
;          1 is to "Make the XML pretty"
;MyXML.Save(1) ;Saves the xml
ExitApp
Mod edit: Code-Tags hinzugefügt.
Attachments
UserVerwaltung.ini
(1.17 KiB) Downloaded 33 times
HardwareVerwaltung.ini
(760 Bytes) Downloaded 31 times
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: INIRead durchsuch variable aus ComboBox

05 Aug 2018, 03:39

Moin JoKu,

wenn man Gui-Controls ansprechen will, braucht man einen eindeutigen Bezeichner. Normalerweise nimmt man dafür die v vName oder die Hwnd HwndName Option. Das hast Du ja teilweise auch schon gemacht.

Zum konkreten Skript:

Code: Select all

IniRead, SoftZuweisung, UserVerwaltung.ini, Settings, %Abteilungen% ;Mit diesem IniRead versuchte die Auswahl Von vAbteilungen aus der ComboBox zu erhalten oder aus dem Label Abteilung:
bringt an dieser Stelle zumindest beim Start des Skripts nichts, weil die Variable Abteilungen leer ist.

Code: Select all

Gui, Add, ComboBox, X650 y150 w100 h15 r5 vAbteilungen gAbteilung ChooseNone , %Abt% ;In der ComboBox wird die auswahl getroffen für die weitergabe an das IniRead
ist an sich nicht schlecht. Der in der v-Option verwendete Name Abteilungen sollte aber in der Subroutine auch genutzt werden:

Code: Select all

Abteilung:
GuiControlGet, Abteilung,, <<<<< ???

Code: Select all

Gui, Add, ListBox, x650 y40 w350 h350 gSofwareListe 8,%AktuelleStdSW% ;End ziel hier sollte das resultat von der auswahl VAbteilungen ComboBox angezeigt werden
hat weder die v- noch die Hwnd-Option.

Code: Select all

GuiControl,, SoftwareListe, %AktuelleStdSW%
zielt deshalb nicht auf dieses Control.

Code: Select all

HDDSSD:
{
AutoComplete(A_GuiControl)
Return
}
Auf überflüssige {...} (Block) Klammern solltest Du verzichten, auch wenn die im Augenblick nicht stören. Es ist nicht garantiert, dass sie in späteren AHK-Versionen nicht zu Fehlern führen.
JoKu
Posts: 2
Joined: 04 Aug 2018, 10:44

Re: INIRead durchsuch variable aus ComboBox

05 Aug 2018, 10:01

Besten dank für die Antwort just me ich werde mich mal in die Hwnd-Option einlesen. Nun Konnte ich das ganze lösen

IniRead, Abt, UserVerwaltung.ini, Benutzer, Abteilung

Gui, Add, Text, X650 y135 w100 h25, Abteilung
Gui, Add, ComboBox, X650 y150 w100 h15 r5 vAbteilungen gAbteilung Choose1,Stantard|%Abt%
Gui, Add, Text, x760 y135 w120 h25, Telefon Nr.
Gui, Add, Edit, x760 y150 w120 h20 vTelefonNr,



Gui, Tab, Software
Gui, Add, ListBox, x650 y40 w560 h600 vSofwareListe 8,|

Abteilung:
GuiControlGet, Stw, , Abteilungen
IniRead, Soft, UserVerwaltung.ini, Benutzer, %Stw%,
Soft=|%Soft%
GuiControl, , SofwareListe, %Soft%
Return

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 30 guests