thor918 Posted April 16, 2007 Share Posted April 16, 2007 hi. this is probably easy to solve, but how do you have a gui promting the user for information, and when the function gets the info, remove the gui and continue script. I have managed to work some code out, but it dosen't work as I want it just yet.... $auth = _authlogin($username) if $auth <> 0 Then MsgBox(64, "Password entered", $auth[1]) EndIf func _authlogin($username) Dim $resultArray[2] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Ressurs authentisering",260, 125, -1, -1, BitOR($WS_DLGFRAME,$WS_CLIPSIBLINGS)) $brukernavn = GUICtrlCreateInput($username, 88, 8, 161, 21) $passord = GUICtrlCreateInput("", 88, 32, 161, 21,0x0020) $ok = GUICtrlCreateButton("OK", 48, 72, 75, 25, 0) $Avbryt = GUICtrlCreateButton("Avbryt", 144, 72, 75, 25, 0) $Label1 = GUICtrlCreateLabel("Brukernavn", 8, 8, 59, 17) $Label2 = GUICtrlCreateLabel("Passord", 8, 40, 42, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE,$Avbryt GUIDelete() return 0 Case $ok $resultArray[0] = GUICtrlRead($brukernavn) $resultArray[1] = GUICtrlRead($passord) GUIDelete() return $resultArray EndSwitch If _IsPressed('0D') Then Switch ControlGetFocus($Form1) Case 'Edit1','Edit2' $resultArray[0] = GUICtrlRead($brukernavn) $resultArray[1] = GUICtrlRead($passord) GUIDelete() return $resultArray EndSwitch EndIf WEnd EndFunc thanks Link to comment Share on other sites More sharing options...
Zedna Posted April 16, 2007 Share Posted April 16, 2007 (edited) Code looks good.What's the problem exactly?Do you have First main GUI or your main script is nonGUI? If yes (GUI) then you must use GUIGetMsg() with advanced parameter.Post also code for main script...EDIT:Look here and here Edited April 16, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
thor918 Posted April 16, 2007 Author Share Posted April 16, 2007 (edited) I'm using a msn style popup, and it seems that if I remove that include it workshttp://www.autoitscript.com/forum/index.ph...3&hl=GioVitthe problem is that when I push buttons in the authdialog, nothing happens. but if the guimessage include is removed. a messagebox appears whith the entered password..doh!it seems the guimessage have "Opt("GuiOnEventMode",1)"witch seems to be the cause.. any solution?expandcollapse popup#include <guimessage.au3> #include <include/GUIConstants.au3> ; Script Start - Add your code below here $username = "thor" $auth = _authlogin($username) if $auth <> 0 Then MsgBox(64, "Password entered", $auth[1]) EndIf func _authlogin($username) Dim $resultArray[2] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Ressurs authentisering",260, 125, -1, -1, BitOR($WS_DLGFRAME,$WS_CLIPSIBLINGS)) $brukernavn = GUICtrlCreateInput($username, 88, 8, 161, 21) $passord = GUICtrlCreateInput("", 88, 32, 161, 21,0x0020) $ok = GUICtrlCreateButton("OK", 48, 72, 75, 25, 0) $Avbryt = GUICtrlCreateButton("Avbryt", 144, 72, 75, 25, 0) $Label1 = GUICtrlCreateLabel("Brukernavn", 8, 8, 59, 17) $Label2 = GUICtrlCreateLabel("Passord", 8, 40, 42, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE,$Avbryt GUIDelete() return 0 Case $ok $resultArray[0] = GUICtrlRead($brukernavn) $resultArray[1] = GUICtrlRead($passord) GUIDelete() return $resultArray EndSwitch If _IsPressed('0D') Then Switch ControlGetFocus($Form1) Case 'Edit1','Edit2' $resultArray[0] = GUICtrlRead($brukernavn) $resultArray[1] = GUICtrlRead($passord) GUIDelete() return $resultArray EndSwitch EndIf WEnd EndFunc Edited April 16, 2007 by thor918 Link to comment Share on other sites More sharing options...
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