KegRaider Posted April 6, 2007 Posted April 6, 2007 Hi guys, Its been a while since i have begged for help, so here goes! I have a form that I want automated, and I have the first part of it just peachy, however, if the logged in user isn't known, I would like to open a GUI with a combobox (or radios/checks, i don't care really), then take the data from the GUI and place it in the form it is in front of.....Making sense? I am using 3.2.3.2 (beta) if that helps any. This part of the code is a fair way down, after it pre-checks the PC info etc. I can post the whole code if need be, but I am only having problems here. I have tried using "GUICtrlSetOnEvent( -1, "gobaby")" and calling another function for the combobox data, and it works, providing it is in a script by itself, not with the preceding Func Bypass() at the top here... I'm confused! I need the gui to close, and enter the info i need..... Func Bypass() hotkeyset("{ESC}", "terminate") Opt('GUIOnEventMode', 1) Opt("RunErrorsFatal", 0) GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') $Form1 = GUICreate("PCHC Helper", 217, 168, 364, 245) $Group1 = GUICtrlCreateGroup("Select Technician", 8, 80, 201, 81) $Combo1 = GUICtrlCreateCombo("", 16, 96, 121, 21) GUICtrlSetData(-1,"Tech1|Tech2|Tech3|Tech4|Tech5","Tech1") ; add other item snd set a new default $Group2 = GUICtrlCreateGroup("Attention", 8, 8, 201, 65) GUICtrlCreateLabel("You are logged in as a standard user.", 16, 32, 189, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) $Button1 = GUICtrlCreateButton("OK", 16, 120, 65, 25) While 1 GUICtrlSetOnEvent( -1, "gobaby") $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 $user = GUICtrlRead($Combo1) If $user = "Tech1" Then .... rest continues here.....
KegRaider Posted April 6, 2007 Author Posted April 6, 2007 OK, so i have managed to get a little further along in my form filler. However, I'm now getting a problem when trying to make a variable equal another variable. eg. I want this to happen... "$name = $Tech1". I have attached the entire script to BEG for some guidance from some more gifted giru's. This program WILL launch on all superhero's login from the Domain Controller once completed. It won't run when an ordinary 'citizen' logs in. expandcollapse popup; Script Start - Add your code below here #include <GuiConstants.au3> #include <Array.au3> $Tech1 = "Bruce Wayne" $Tech2 = "Ben Grim" $Tech3 = "Clark Kent" $Tech4 = "Peter Parker" $Tech5 = "Bill Bixby" $TechEmail1 = "Bruce.Wayne@superheros.com" $TechEmail2 = "Ben.Grim@superheros.com" $TechEmail3 = "Clark.Kent@superheros.com" $TechEmail4 = "Peter.Parker@@superheros.com" $TechEmail5 = "Bill.Bixby@superheros.com" ;Excluded PC list If (@Computername = 'BrucePC' or @ComputerName = 'BenPC' or @ComputerName = 'ClarkPC' or @ComputerName = 'PeterPC' or @ComputerName = 'BillPC' or @ComputerName = 'SuperServer1' or @ComputerName = 'SuperServer2') Then Exit EndIf ; ## Program Start ## SplashTextOn("Form Filler-outerer ", "Please standby while data is gathered") sleep (500) SplashOff() ; Jump to "Begin" if the logged in user matches one of the following, otherwise, launch the Userselect GUI If (@Username = 'bwayne' Or @UserName = 'bgrim' Or @UserName = 'ckent' Or @UserName = 'pparker' Or @UserName = 'bbixby') Then call ("begin") EndIf ; Create GUI hotkeyset("{ESC}", "terminate") Opt('GUIOnEventMode', 1) GUISetOnEvent($GUI_EVENT_CLOSE, 'Event_GUIClose') $Form1 = GUICreate("Form Helper", 217, 168, 364, 245) $Group1 = GUICtrlCreateGroup("Select Technician", 8, 80, 201, 81) $Combo1 = GUICtrlCreateCombo("Bruce", 16, 96, 121, 21) GUICtrlSetData(-1,"Ben|Clark|Peter|Bill","Bruce") ; add other item snd set a new default $Button = GUICtrlCreateButton("OK", 16, 120, 65, 25) GUICtrlSetOnEvent(-1, 'SelectUser') GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Attention", 8, 8, 201, 65) GUICtrlCreateLabel("You have not logged in as a super hero.", 16, 32, 189, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) func terminate() ;exit Exit 0 EndFunc Func Event_GUIClose() Exit EndFunc While 1 Sleep(250) WEnd Call ("SelectUser") ; Determine who was selected, close the message box, and enter the information into the PCHC form. Func SelectUser() $selected = GUICtrlRead($Combo1) GUISetState(@SW_HIDE) Switch $selected Case "Bruce" $name = $Tech1 $email = $TechEmail1 Case "Ben" $name = $Tech2 $email = $TechEmail2 Case "Clark" $name = $Tech3 $email = $TechEmail3 Case "Peter" $name = $Tech4 $email = $TechEmail4 Case "Bill" $name = $Tech5 $email = $TechEmail5 EndSwitch Call ("Begin") EndFunc ;==>function ;; Main program start. Func Begin() Run("AssetNumber.exe") ; Look for PCHC active window. sleep (1000) WinWait ( 'Asset Number', 'Enter the ASSET NUMBER of this computer.' ) if NOT WinActive ( 'Asset Number', 'Enter the ASSET NUMBER of this computer.' ) then WinActivate ( 'Asset Number', 'Enter the ASSET NUMBER of this computer.' ) endif WinWaitActive ( 'Asset Number', 'Enter the ASSET NUMBER of this computer.' ) ; Insert PC name as Asset Number sleep (500) send (@computername) sleep (150) send ('{TAB}') ; Find the logged in user and insert Technician name accordingly (or from ComboBox earlier) If (@UserName = 'bwayne' Or @UserName = $name) Then sleep (150) send ($name) sleep (150) send ('{TAB}') sleep (150) send ($email) sleep (150) send ('{ENTER}') EndIf If (@UserName = 'bgrim' Or @UserName = $name) Then sleep (150) send ($name) sleep (150) send ('{TAB}') sleep (150) send ($email) sleep (150) send ('{ENTER}') EndIf If (@UserName = 'ckent' Or @UserName = $name) Then sleep (150) send ($name) sleep (150) send ('{TAB}') sleep (150) send ($email) sleep (150) send ('{ENTER}') EndIf If (@UserName = 'pparker' Or @UserName = $name) Then sleep (150) send ($name) sleep (150) send ('{TAB}') sleep (150) send ($email) sleep (150) send ('{ENTER}') EndIf If (@UserName = 'bbixby' Or @UserName = $name) Then sleep (150) send ($name) sleep (150) send ('{TAB}') sleep (150) send ($email) sleep (150) send ('{ENTER}') EndIf ; This concludes the first part of the program, entering Assetnumber and Technician ; Main Window Asset window information WinWait ( 'Asset Form v9.5', 'View Proxy Settings...' ) if NOT WinActive ( 'Asset Form v9.5', 'View Proxy Settings...' ) then WinActivate ( 'Asset Form v9.5', 'View Proxy Settings...' ) endif WinWaitActive ( 'Asset Form v9.5', 'View Proxy Settings...' ) send ('Audit') sleep (150) send ('{TAB}') sleep (150) send ('4') sleep (150) send ('{TAB}') sleep (150) send ('{TAB}') sleep (150) send ('n') send ('{TAB}') sleep (150) send ('{TAB}') Exit 0 EndFunc ;==>function Exit I know the problem lies within the "Select User" area, but I don't know how to fix it :S I spent the better half of 2 hours trolling the search box for "ComboBox" ideas, and I can't seem to get it to work in my script. Basic flow of events. 1. Check PC for exclusion, if excluded - exit 2. Check logged in user, if matches hero's, skip to main form (4) for autofill 3. Display GUI if user unknown. Select User from Combobox and continue with autofill 4. Fill in all the details to match the hero's details (whether autodetected, or combo selected) 4. Exit. I sincerely hope this makes sense. --> KegRaider.
KegRaider Posted April 6, 2007 Author Posted April 6, 2007 YAY! Fixed it Pondered over a Hot Cross Bun, and hot cup of Moccona and the answer hit me like a bus! changed $Tech1 = "Bruce Wayne" $Tech2 = "Ben Grim" $Tech3 = "Clark Kent" $Tech4 = "Peter Parker" $Tech5 = "Bill Bixby" $TechEmail1 = "Bruce.Wayne@superheros.com" $TechEmail2 = "Ben.Grim@superheros.com" $TechEmail3 = "Clark.Kent@superheros.com" $TechEmail4 = "Peter.Parker@@superheros.com" $TechEmail5 = "Bill.Bixby@superheros.com" $name = "0" $email = "0" oÝ÷ Ù©Ýr§çZ[.¥êázº7öËh¶¬jëh×6 If ($name = 'bwayne' Or @UserName = 'bwayne') Then sleep (150) send ($Tech1) sleep (150) send ('{TAB}') sleep (150) send ($TechEmail1) sleep (150) send ('{ENTER}') EndIf Works a treat now Thanks for being my "sounding board"....maybe next time i beg someone will answer
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