Xonos Posted June 23, 2008 Posted June 23, 2008 Hi, I am having issue with this script. Basically I want to be able to type something into an input box. Click install and have it open my System Properties, go to the computer name and send the variable defined by the input box. So if I typed in.. "Jenkin's Computer" in the input box, it would send that to the "send($inv)". But I am just having syntax issues now. Any clue? #include <GUIConstants.au3> GUICreate("ZenRenameiT", 255, 85, 255, 255) GUICtrlCreateLabel("Type in the computer TE number and click rename.", 5, 5) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $inv = GUICtrlCreateInput("", 75, 25, 100, 20) $btn = GUICtrlCreateButton("Rename", 95, 55, 60, 20) GUICtrlSetData($btn, $inv) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn If GUICtrlRead($btn) = $inv Then _Rename() EndIf ExitLoop EndSelect WEnd Func _Rename() Run(@ComSpec & " /c sysdm.cpl", "", @SW_HIDE) WinWaitActive("System Properties") Send("{RIGHT}") Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{ENTER}") Send($inv) EndFunc [center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center]
Kiti Posted June 23, 2008 Posted June 23, 2008 (edited) This works #include <GUIConstants.au3> GUICreate("ZenRenameiT", 255, 85, 255, 255) GUICtrlCreateLabel("Type in the computer TE number and click rename.", 5, 5) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $inv = GUICtrlCreateInput("", 75, 25, 100, 20) $btn = GUICtrlCreateButton("Rename", 95, 55, 60, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn _Rename() ExitLoop EndSelect WEnd Func _Rename() Run(@ComSpec & " /c sysdm.cpl", "", @SW_HIDE) WinWaitActive("System Properties") Send("{RIGHT}") Send("{TAB}") Send("{TAB}") Send("{TAB}") Send("{ENTER}") $x = GUICtrlRead($inv) Send($x) EndFunc ;==>_Rename Edit: I removed some useless things... Now the button is called how it should. Edited June 23, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30
Xonos Posted June 23, 2008 Author Posted June 23, 2008 ahhh I see! Thank you so much! [center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center]
Kiti Posted June 23, 2008 Posted June 23, 2008 (edited) ahhh I see! Thank you so much! You're welcome ! The thing to remember from here is that you always have to use GuiCtrlRead($ControlID) when you want to do something with some data obtained from the user. Edited June 23, 2008 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30
dmob Posted June 24, 2008 Posted June 24, 2008 You could replace this: CODERun(@ComSpec & " /c sysdm.cpl", "", @SW_HIDE) WinWaitActive("System Properties") Send("{RIGHT}") Send("{TAB}").... with this: CODERun(@ComSpec & " /c sysdm.cpl,1", "", @SW_HIDE) WinWaitActive("System Properties") Send("{TAB}")....
weaponx Posted June 24, 2008 Posted June 24, 2008 (edited) There are more reliable ways to do this:$strDomain = "domainname" $strPassword = "password" $strUser = "username" $strNewComputerName = "newName" $objNetwork = ObjCreate("WScript.Network") $strComputer = $objNetwork.ComputerName $objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\" & $strComputer & "\root\cimv2:Win32_ComputerSystem.Name=" & $strComputer & "") $ErrCode = $objComputer.Rename($strNewComputerName, $strPassword, $strUser) If $ErrCode = 0 Then MsgBox (0,"","Computer renamed correctly.") Else MsgBox (0,"","Eror changing computer name. Error code: " & $ErrCode) EndIfEven easier:http://www.autoitscript.com/forum/index.ph...script++network Edited June 24, 2008 by weaponx
GEOSoft Posted June 24, 2008 Posted June 24, 2008 Remember that changing the computer name requires a restart before it takes effect. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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