MeepZero Posted July 17, 2012 Share Posted July 17, 2012 This is going to be attached to another script to collect login info so I can automate some things. What I'm trying to figure out is how can I take the text or whatever being typed into one of the fields and output it as typed text into something else. At the moment this is the only way I've been able to get it to output text as referencing $AUser just spits out the number 6 instead of the stuff typed in the box. At the moment it's set to output the text to notepad, but I'll probably store it as a variable or something. I'm just trying to get the mechanics down first. expandcollapse popup#include <GUIConstantsEx.au3> Global $mainwindow, $AUser, $Password, $NewUser Global $var = 1 Func GUICollectData() Local $BTNEXIT Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Need Login Credentials", 300, 200) ;Creates a window and assigns it a handle GUICtrlCreateLabel("Enter Information Here...", 30, 10) $okbutton = GUICtrlCreateButton("OK", 125, 150, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISwitch($mainwindow) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Your Domain Username...", 10, 30, 180) $AUser = GUICtrlCreateInput("", 10, 45, 275, 20) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetTip(-1, "The title of the message box.") GUICtrlCreateLabel("Your Password...", 10, 70, 180) $Password = GUICtrlCreateInput("", 10, 85, 275, 20) GUICtrlSetTip(-1, "The title of the message box.") GUICtrlCreateLabel("Machine Owner's Username...", 10, 110, 180) $NewUser = GUICtrlCreateInput("", 10, 125, 275, 20) GUICtrlSetTip(-1, "The title of the message box.") While($var) Sleep(1000) ;Sleep around WEnd EndFunc Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton ConsoleWrite(GUICtrlRead($AUser) & @CRLF) $BUser = (GUICtrlRead($AUser)) ConsoleWrite(GUICtrlRead($Password) & @CRLF) ConsoleWrite(GUICtrlRead($NewUser) & @CRLF) Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("test" & @CRLF) Send($Buser,1) $var = 0 EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow If @GUI_WINHANDLE = $mainwindow Then Exit EndIf EndFunc GUICollectData() Apologies for the ugly text, for some reason this form won't accept my indents when I copy paste this in. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2012 Moderators Share Posted July 17, 2012 MeepZero,I would like a better explanation of why you want to "collect login info" than merely saying "so I can automate some things". M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MeepZero Posted July 18, 2012 Author Share Posted July 18, 2012 Sorry, this is going to be plugged into another script so I can add a user to the local admin group on our domain. This section of script, when run, should prompt for the tech's user name and password (for domain authentication) and the user account that the machine is going to be attached to. So it should prompt for 3 fields. After this runs it will plug the login / password data typed in into the authenticate domain admin screen and then plug in the end user's login to the local administrator window. I was using the notepad to output as a test to see if I could get the script to push the text back out into a field / form / whatever. Let me know if you have further questions. Link to comment Share on other sites More sharing options...
rvn Posted July 18, 2012 Share Posted July 18, 2012 (edited) Yes u can push the text back out into a field / form / whatever,,, but first activate "it".WinActivate, WinActive etc combination... Send or ControlSend combinationThe problem is,,, if you activate "it" you dont need your login script anymore,,, am i right?! maybe what you need (please search examples in forum) Edited July 18, 2012 by rvn Link to comment Share on other sites More sharing options...
MeepZero Posted July 18, 2012 Author Share Posted July 18, 2012 Thats not quite the problem, the output window is active when the text is firing, the problem is without rassigning the text to a new variable it just comes up as "6" in the output. What I'm trying to figure out, is is this the correct way to handle text coming from a field that a user types into? Do I need to do this.... Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton ConsoleWrite(GUICtrlRead($AUser) & @CRLF) $BUser = (GUICtrlRead($AUser)) ;Assign the $Auser content to $Buser ConsoleWrite(GUICtrlRead($Password) & @CRLF) ConsoleWrite(GUICtrlRead($NewUser) & @CRLF) Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("test" & @CRLF) Send($Buser,1) ;Push Buser out as text $var = 0 EndFunc When I could be doing something like this somehow... Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton ConsoleWrite(GUICtrlRead($AUser) & @CRLF) ConsoleWrite(GUICtrlRead($Password) & @CRLF) ConsoleWrite(GUICtrlRead($NewUser) & @CRLF) Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("test" & @CRLF) Send($Auser,1) ;Pull directly from the $Auser variable $var = 0 EndFunc Link to comment Share on other sites More sharing options...
rvn Posted July 18, 2012 Share Posted July 18, 2012 (edited) ;Wrong sintax here, $BUser = blank string $BUser = (GUICtrlRead($AUser)) ;Assign the $Auser content to $Buser ;use this $BUser = GUICtrlRead($AUser) Edited July 18, 2012 by rvn Link to comment Share on other sites More sharing options...
rvn Posted July 18, 2012 Share Posted July 18, 2012 Here your script, only change function OKButton() expandcollapse popup#include Global $mainwindow, $AUser, $Password, $NewUser Global $var = 1 Func GUICollectData() Local $BTNEXIT Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Need Login Credentials", 300, 200) ;Creates a window and assigns it a handle GUICtrlCreateLabel("Enter Information Here...", 30, 10) $okbutton = GUICtrlCreateButton("OK", 125, 150, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISwitch($mainwindow) GUISetState(@SW_SHOW) GUICtrlCreateLabel("Your Domain Username...", 10, 30, 180) $AUser = GUICtrlCreateInput("", 10, 45, 275, 20) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetTip(-1, "The title of the message box.") GUICtrlCreateLabel("Your Password...", 10, 70, 180) $Password = GUICtrlCreateInput("", 10, 85, 275, 20) GUICtrlSetTip(-1, "The title of the message box.") GUICtrlCreateLabel("Machine Owner's Username...", 10, 110, 180) $NewUser = GUICtrlCreateInput("", 10, 125, 275, 20) GUICtrlSetTip(-1, "The title of the message box.") While($var) Sleep(1000) ;Sleep around WEnd EndFunc Func OKButton() ;Note: at this point @GUI_CTRLID would equal $okbutton $BUser = GUICtrlRead($AUser) ConsoleWrite($BUser & @CRLF) $BPassword = GUICtrlRead($Password) ConsoleWrite($BPassword & @CRLF) $BNewUser = GUICtrlRead($NewUser) ConsoleWrite($BNewUser & @CRLF) Run("notepad.exe") WinWaitActive("Untitled - Notepad") ;Send("test" & @CRLF) Send($BUser & @CRLF) Send($BPassword & @CRLF) Send($BNewUser & @CRLF) $var = 0 EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow If @GUI_WINHANDLE = $mainwindow Then Exit EndIf EndFunc GUICollectData() Link to comment Share on other sites More sharing options...
MeepZero Posted July 18, 2012 Author Share Posted July 18, 2012 Thanks for the clarification, that should be a big help to me.On a related note, I found this elsewhere, seems like it might be applicable to my task... Link to comment Share on other sites More sharing options...
rvn Posted July 18, 2012 Share Posted July 18, 2012 nice to hear it Another sugestion DriveMapAdd from help file,,, map admin share or some thing 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