lebisol Posted March 30, 2005 Posted March 30, 2005 Hello everyone! This is my 1st attempt to venture into V3 and GUI creatons so I appologise for my ignorance. My goal is to use the treeview and segment some of the user interactivty.....eg. user will -point to the applciation.exe and -then provide the login cridentials used on this application -and run this "compiled sript" I am hvaing some issue of "hiding" the lable retured after the user has browsed to the application. The logic would be that label is shown ONLY If the user selcts "notepad.exe" and show it any time "browse item" was clicked. In hand, my second question: Is there a way to build a 1 label/vatiable of muplitple parts instead of breaking into parts. eg. $UserLoginLabel = GUICtrlCreateLabel ("Please Enter your Login",140,20,300,60) $UserName = GUICtrlCreateLabel ("User Name:",180,72,80,60) $tfUserName = GUICtrlCreateInput ("", 240, 70, 80, 20) $Password = GUICtrlCreateLabel ("Password:",180,103,80,60) $tfPassword = GUICtrlCreateInput ("", 240, 100, 80, 20,$ES_PASSWORD) vs. $UserLoginLabel = GUICtrlCreateLabel ("Please Enter your Login",140,20,300,60) GUICtrlCreateLabel ("User Name:",180,72,80,60) GUICtrlCreateInput ("", 240, 70, 80, 20) GUICtrlCreateLabel ("Password:",180,103,80,60) GUICtrlCreateInput ("", 240, 100, 80, 20,$ES_PASSWORD) the issue with my latter attempt is tha I can only show/hide the 1st line.... In any case here is my code: expandcollapse popup#include <GUIConstants.au3> ;----------------- Create a Tree ------------------------------------ GUICreate("Browse & Login",450,212) $treeview = GUICtrlCreateTreeView (6,6,120,150,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) $CompanyItem = GUICtrlCreateTreeViewitem ("Company",$treeview) $BrowseItem = GUICtrlCreateTreeViewitem ("Browse...",$CompanyItem) $UserLoginItem = GUICtrlCreateTreeViewitem ("User Login",$CompanyItem) $CompanyLabel = GUICtrlCreateLabel ("Open to your Company!",140,20,200,60) $BrowseLabel = GUICtrlCreateLabel ("Browse to your App.exe file to start...",140,20,200,60) GUICtrlSetState(-1,$GUI_HIDE) $BrowseButton = GUICtrlCreateButton ("Browse...",240,80,70,20) GUICtrlSetState(-1,$GUI_HIDE) ;----------------- UserName & Login Fields ------------------------------------ $UserLoginLabel = GUICtrlCreateLabel ("Please Enter your Login",140,20,300,60) $UserName = GUICtrlCreateLabel ("User Name:",180,72,80,60) $tfUserName = GUICtrlCreateInput ("", 240, 70, 80, 20) $Password = GUICtrlCreateLabel ("Password:",180,103,80,60) $tfPassword = GUICtrlCreateInput ("", 240, 100, 80, 20,$ES_PASSWORD) ;--------- hide fields as default -------------- GUICtrlSetState ($UserLoginLabel ,$GUI_HIDE) GUICtrlSetState ($UserName ,$GUI_HIDE) GUICtrlSetState ($tfUserName ,$GUI_HIDE) GUICtrlSetState ($Password ,$GUI_HIDE) GUICtrlSetState ($tfPassword ,$GUI_HIDE) ;---------- Main Buttons to Run the script ---------------- $okbutton = GUICtrlCreateButton ("START",140,185,70,20) $exitbutton = GUICtrlCreateButton ("Exit",220,185,70,20) ;---------------------------------------------------------- GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $exitbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $CompanyItem GUIChangeItems($BrowseLabel,$UserLoginLabel,$CompanyLabel,$CompanyLabel) Case $msg = $BrowseItem GUIChangeItems($BrowseLabel,$UserLoginLabel,$BrowseLabel,$BrowseLabel) GUICtrlSetState ($BrowseButton,$GUI_SHOW) GUICtrlSetState ($CompanyLabel,$GUI_HIDE) GUICtrlSetState ($UserLoginLabel ,$GUI_HIDE) GUICtrlSetState ($UserName ,$GUI_HIDE) GUICtrlSetState ($tfUserName ,$GUI_HIDE) GUICtrlSetState ($Password ,$GUI_HIDE) GUICtrlSetState ($tfPassword ,$GUI_HIDE) Case $msg = $BrowseButton $file = FileOpenDialog("Choose file...","C:\WINNT\System32\","All (*.*)",1+2) ;------ grab the file path into a string ----- $file = StringReplace($file , "|", @CRLF) $filename = StringRight($file,11) GUICtrlCreateLabel ("Your App will run from location:",140,20,200,60) GUICtrlCreateLabel("" & $file ,140,40,200,20) If @error Then MsgBox(4096,"","WARNING! You MUST Select a file!") Else ;------ check the app name -------- If $filename <> "notepad.exe" Then MsgBox(4096,"","This is not a Notepad Application!") Else EndIf EndIf Case $msg = $UserLoginItem GUICtrlSetState ($BrowseButton ,$GUI_HIDE) GUICtrlSetState ($UserLoginLabel ,$GUI_SHOW) GUICtrlSetState ($UserLoginLabel ,$GUI_SHOW) GUICtrlSetState ($UserName ,$GUI_SHOW) GUICtrlSetState ($tfUserName ,$GUI_SHOW) GUICtrlSetState ($Password ,$GUI_SHOW) GUICtrlSetState ($tfPassword ,$GUI_SHOW) EndSelect WEnd GUIDelete() Exit Func GUIChangeItems($hidestart,$hideend,$showstart,$showend) Local $idx,$hidestart,$hideend,$showstart,$showend For $idx = $hidestart To $hideend GUICtrlSetState ($idx,$GUI_HIDE) Next For $idx = $showstart To $showend GUICtrlSetState ($idx,$GUI_SHOW) Next EndFunc Any pointer or advice would be apprechaited being that I am not much of a programmer. Many thanx in advance!
sylvanie Posted April 1, 2005 Posted April 1, 2005 hello, I think that a part of ypur problem is here : Case $msg = $BrowseButton $file = FileOpenDialog("Choose file...","C:\WINNT\System32\","All (*.*)",1+2) ;------ grab the file path into a string ----- $file = StringReplace($file , "|", @CRLF) $filename = StringRight($file,11) GUICtrlCreateLabel ("Your App will run from location:",140,20,200,60) GUICtrlCreateLabel("" & $file ,140,40,200,20) If @error Then when you have choosen your file file, you create 2 Label, and you don't control the display of them after. A second problem is that you don't consider if you have or not already choosen a file (the labels are not the same) so I have modified your code with these remarks : expandcollapse popup#include <GUIConstants.au3> ;----------------- Create a Tree ------------------------------------ GUICreate("Browse & Login",450,212) $treeview = GUICtrlCreateTreeView (6,6,120,150,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) $CompanyItem = GUICtrlCreateTreeViewitem ("Company",$treeview) $BrowseItem = GUICtrlCreateTreeViewitem ("Browse...",$CompanyItem) $UserLoginItem = GUICtrlCreateTreeViewitem ("User Login",$CompanyItem) $CompanyLabel = GUICtrlCreateLabel ("Open to your Company!",140,20,200,60) $BrowseLabel = GUICtrlCreateLabel ("Browse to your App.exe file to start...",140,20,200,60) GUICtrlSetState(-1,$GUI_HIDE) $BrowseButton = GUICtrlCreateButton ("Browse...",240,80,70,20) GUICtrlSetState(-1,$GUI_HIDE) ;----------------- UserName & Login Fields ------------------------------------ $UserLoginLabel = GUICtrlCreateLabel ("Please Enter your Login",140,20,300,60) $UserName = GUICtrlCreateLabel ("User Name:",180,72,80,60) $tfUserName = GUICtrlCreateInput ("", 240, 70, 80, 20) $Password = GUICtrlCreateLabel ("Password:",180,103,80,60) $tfPassword = GUICtrlCreateInput ("", 240, 100, 80, 20,$ES_PASSWORD) $location=GUICtrlCreateLabel ("Your App will run from location:",140,20,200,60) $exename=GUICtrlCreateLabel("" ,140,40,200,20) ;--------- hide fields as default -------------- GUICtrlSetState ($UserLoginLabel ,$GUI_HIDE) GUICtrlSetState ($UserName ,$GUI_HIDE) GUICtrlSetState ($tfUserName ,$GUI_HIDE) GUICtrlSetState ($Password ,$GUI_HIDE) GUICtrlSetState ($tfPassword ,$GUI_HIDE) GUICtrlSetState($location,$GUI_HIDE) ; **********creation of fields which containslocation and name of the application choosen GUICtrlSetState($exename,$GUI_HIDE) ;**********/////////////////// $filechoosen=0; ************ variable to monitor if we have already choosen an exe ;---------- Main Buttons to Run the script ---------------- $okbutton = GUICtrlCreateButton ("START",140,185,70,20) $exitbutton = GUICtrlCreateButton ("Exit",220,185,70,20) ;---------------------------------------------------------- GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $exitbutton Or $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $CompanyItem GUIChangeItems($BrowseLabel,$UserLoginLabel,$CompanyLabel,$CompanyLabel) GUICtrlSetState($location,$GUI_HIDE) GUICtrlSetState($exename,$GUI_HIDE) Case $msg = $BrowseItem if $filechoosen=0 Then; check if we have not choosen a file GUIChangeItems($BrowseLabel,$UserLoginLabel,$BrowseLabel,$BrowseLabel) Else GUICtrlSetState($location,$GUI_SHOW) GUICtrlSetState($exename,$GUI_SHOW) EndIf GUICtrlSetState ($BrowseButton,$GUI_SHOW) GUICtrlSetState ($CompanyLabel,$GUI_HIDE) GUICtrlSetState ($UserLoginLabel ,$GUI_HIDE) GUICtrlSetState ($UserName ,$GUI_HIDE) GUICtrlSetState ($tfUserName ,$GUI_HIDE) GUICtrlSetState ($Password ,$GUI_HIDE) GUICtrlSetState ($tfPassword ,$GUI_HIDE) Case $msg = $BrowseButton $file = FileOpenDialog("Choose file...","C:\WINNT\System32\","All (*.*)",1+2) ;------ grab the file path into a string ----- $file = StringReplace($file , "|", @CRLF) $filename = StringRight($file,11) ;******** If @error Then MsgBox(4096,"","WARNING! You MUST Select a file!") Else ;------ check the app name -------- If $filename <> "notepad.exe" Then MsgBox(4096,"","This is not a Notepad Application!") Else GUICtrlSetState($location,$GUI_SHOW);**** the file name is good, so we show and update data GUICtrlSetState($exename,$GUI_SHOW);**** GUICtrlSetData($exename,$file);****** $filechoosen=1 EndIf EndIf ;******** Case $msg = $UserLoginItem GUICtrlSetState ($BrowseButton ,$GUI_HIDE) GUICtrlSetState ($UserLoginLabel ,$GUI_SHOW) GUICtrlSetState ($UserLoginLabel ,$GUI_SHOW) GUICtrlSetState ($UserName ,$GUI_SHOW) GUICtrlSetState ($tfUserName ,$GUI_SHOW) GUICtrlSetState ($Password ,$GUI_SHOW) GUICtrlSetState ($tfPassword ,$GUI_SHOW) GUICtrlSetState($location,$GUI_HIDE);****** GUICtrlSetState($exename,$GUI_HIDE);***** EndSelect WEnd GUIDelete() Exit Func GUIChangeItems($hidestart,$hideend,$showstart,$showend) Local $idx,$hidestart,$hideend,$showstart,$showend For $idx = $hidestart To $hideend GUICtrlSetState ($idx,$GUI_HIDE) Next For $idx = $showstart To $showend GUICtrlSetState ($idx,$GUI_SHOW) Next EndFunc I have used *** to indicate where I have added and removed lines I hope that it'll help you
lebisol Posted April 8, 2005 Author Posted April 8, 2005 Hi sylvanie! Many thanx for corrections! this is exacly what needed... many thanx again and sorry for not responding sooner... All the best!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now