Jump to content

Recommended Posts

Posted

OK, I'll fix it...hang on...

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted

Are you sure? The only "bug" I ran into is when you select a user's parent (eg. A or :wacko:, it changes the username to A or B etc. and leaves the other fields the same. I don't, however, get any 0's returned when I click anywhere else in the treeview area :D Everything just stays the same.

Fixed:

#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>

Dim $Location = @DesktopDir &  "\MSTSC.ini"
;===================================> GUI <=======================================

GUICreate("Verbinding met extern bureaublad", 400, 508)
GUICtrlCreatePic("mstsc.jpg",0,0, 400,70)
GUISetBkColor (0xECE9D8)

;===================================> Buttons <===================================
$Connectbutton = GUICtrlCreateButton("Verbinding maken", 30, 460, 150)
$Cancelbutton = GUICtrlCreateButton("Annuleren", 205, 460, 150)

;===================================> Create Treeview <===========================
$treeview = GUICtrlCreateTreeView(6, 76, 388, 200, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)

;===================================> Labels <====================================
$IP=GUICtrlCreateLabel ("IP Adres :",50 ,320 ,85 ,20)
$Gebruikersnaam=GUICtrlCreateLabel ("Gebruikersnaam :",50 ,360 ,85 ,20)
$Wachtwoord=GUICtrlCreateLabel ("Wachtwoord :",50 ,400 ,85 ,20)

;===================================> Input Fields <==============================
$IPValue=GuiCtrlCreateInput("",150, 318, 150, 20)
$GebruikersnaamValue=GuiCtrlCreateInput("",150, 358, 150, 20)
$WachtwoordValue=GuiCtrlCreateInput("",150, 398, 150, 20);, $ES_PASSWORD

;===================================> Read INI <==================================

$sections = IniReadSectionNames($Location)
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $sections[0]
$keys = IniReadSection($Location, $sections[$i])
$item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)
For $x = 1 To $keys[0][0]
GUICtrlCreateTreeViewItem($keys[$x][0], $item)
Next
Next
EndIf

GUISetState()
;================================> End GUI <======================================
While 1
$msg = GUIGetMsg()
$mouseinfo = GUIGetCursorInfo()

Select

    Case $msg = $gui_event_close
    ExitLoop

    Case $msg = $Connectbutton
    ExitLoop;Some action will come here instead of exitloop
   
    Case $msg = $Cancelbutton
    ExitLoop
   
    Case $mouseinfo[4] = $treeview And $mouseinfo[2] = 1
        $value = GUICtrlRead(GUICtrlRead($treeview), 1)
        If StringLen($value[0]) > 1 Then
            GUICtrlSetData($GebruikersnaamValue, $value[0])
            $temp = IniRead($Location, StringLeft($value[0], 1), $value[0], "")
            $data = StringSplit($temp, "|")
            If IsArray($data) And $data[0] <> 1 Then
                GUICtrlSetData($IPValue, $data[1])
                GUICtrlSetData($GebruikersnaamValue, $data[2])
                GUICtrlSetData($WachtwoordValue, $data[3])
            EndIf
        EndIf
EndSelect

Sleep(10)

WEnd

Edit: it did return 0 if you clicked anywhere, but only the 1st time.

Alzo

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted

Yes thats what i meant, but if you select a item the 0 will be gone. I tried this with a IF statement but then it shows the 0 or it shows nothing :D.

But if i run your code with this ini file:

[A]
Ad=IPadress|Username|Password

[B]
B=IPadress2|Username2|Password2

[C]
C=IPadress3|Username3|Password3

[D]
D=IPadress4|Username4|Password4

and i click on Ad and then i click on B, the inputfields keep showing the information from Ad

Posted (edited)

You should change the keys in your ini file to at least two characters, because my script filters out the ones that have 1 char , eg. B-> BB etc :D

Edit: change B=IPadress2|Username2|Password2 to BB=IPadress2|Username2|Password2 for example

Edited by marfdaman

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted

You should change the keys in your ini file to at least two characters, because my script filters out the ones that have 1 char , eg. B-> BB etc :wacko:

Edit: change B=IPadress2|Username2|Password2 to BB=IPadress2|Username2|Password2 for example

You are right, Offcourse :D

It was just for testing and in a real situation i would never get one character.

Thx for your great help for so far. First i will try to understand the code so i don't have to ask these stupid questions.

Posted

Its getting clear to me, but some weird thing is still happening wich i had before

GUICtrlRead($IPValue, 1)
MsgBox(1024, "Test", $IPValue)
;RunWait(@ComSpec & " /c " & 'mstsc /v:' & $IPValue & ' /f /console', "", @SW_HIDE)

If i put this on the ConnectButton and select a TreeViewItem and click on the button wich execute this part of the script i get the value "10"

So i though i put the ,1 after it what you said before, but that didn't help either.

Is this even possible to do? I ques so but :D . . . .

Posted

Are you sure? This works fine for me:

#include <GUIConstants.au3>
#Include <Constants.au3>
#include <array.au3>

Dim $Location = @DesktopDir &  "\MSTSC.ini"
;===================================> GUI <=======================================

GUICreate("Verbinding met extern bureaublad", 400, 508)
GUICtrlCreatePic("mstsc.jpg",0,0, 400,70)
GUISetBkColor (0xECE9D8)

;===================================> Buttons <===================================
$Connectbutton = GUICtrlCreateButton("Verbinding maken", 30, 460, 150)
$Cancelbutton = GUICtrlCreateButton("Annuleren", 205, 460, 150)

;===================================> Create Treeview <===========================
$treeview = GUICtrlCreateTreeView(6, 76, 388, 200, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)

;===================================> Labels <====================================
$IP=GUICtrlCreateLabel ("IP Adres :",50 ,320 ,85 ,20)
$Gebruikersnaam=GUICtrlCreateLabel ("Gebruikersnaam :",50 ,360 ,85 ,20)
$Wachtwoord=GUICtrlCreateLabel ("Wachtwoord :",50 ,400 ,85 ,20)

;===================================> Input Fields <==============================
$IPValue=GuiCtrlCreateInput("",150, 318, 150, 20)
$GebruikersnaamValue=GuiCtrlCreateInput("",150, 358, 150, 20)
$WachtwoordValue=GuiCtrlCreateInput("",150, 398, 150, 20);, $ES_PASSWORD

;===================================> Read INI <==================================

$sections = IniReadSectionNames($Location)
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $sections[0]
$keys = IniReadSection($Location, $sections[$i])
$item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)
For $x = 1 To $keys[0][0]
GUICtrlCreateTreeViewItem($keys[$x][0], $item)
Next
Next
EndIf

GUISetState()
;================================> End GUI <======================================
While 1
$msg = GUIGetMsg()
$mouseinfo = GUIGetCursorInfo()

Select

    Case $msg = $gui_event_close
    ExitLoop

    Case $msg = $Connectbutton
    MsgBox(0, "IP-address:", GUICtrlRead($IPValue))
   
    Case $msg = $Cancelbutton
    ExitLoop
   
    Case $mouseinfo[4] = $treeview And $mouseinfo[2] = 1
        $value = GUICtrlRead(GUICtrlRead($treeview), 1)
        If StringLen($value[0]) > 1 Then
            GUICtrlSetData($GebruikersnaamValue, $value[0])
            $temp = IniRead($Location, StringLeft($value[0], 1), $value[0], "")
            $data = StringSplit($temp, "|")
            If IsArray($data) And $data[0] <> 1 Then
                GUICtrlSetData($IPValue, $data[1])
                GUICtrlSetData($GebruikersnaamValue, $data[2])
                GUICtrlSetData($WachtwoordValue, $data[3])
            EndIf
        EndIf
EndSelect

Sleep(10)

WEnd

with this ini:

[A]
Ad=IPadress|Username|Password

[B]
BB=IPadress2|Username2|Password2

[C]
CC=IPadress3|Username3|Password3

[D]
DD=IPadress4|Username4|Password4

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Posted

If i copy that code and run it with that ini it does work. But thats almost the same as i had before.

Maybe its to hot to do this kinda work :D

Sorry for bottering you.... :">

Posted

No need to apologize, but if you still need help at some point, feel free to post!

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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...