OrangeCoder Posted April 1, 2016 Share Posted April 1, 2016 hey Guys I have this running an my script Run('control.exe sysdm.cpl') it opens the system properties window without issue However when I follow Run('control.exe sysdm.cpl') Send("!c") Alt + C is now pressed in that window I am obviously missing something simple here - I'd apreciate the help Link to comment Share on other sites More sharing options...
markyrocks Posted April 1, 2016 Share Posted April 1, 2016 Try putting a delay between the window opening and the button press. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 hey mark I would do that with Sleep ("XX") right? Link to comment Share on other sites More sharing options...
markyrocks Posted April 1, 2016 Share Posted April 1, 2016 Yep or use a method like winwaitactive (). Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 (edited) So I tried this Run('control.exe sysdm.cpl') Sleep(2000) Send("!c") still not working - thanks for your help Edited April 1, 2016 by OrangeCoder Link to comment Share on other sites More sharing options...
AutoBert Posted April 1, 2016 Share Posted April 1, 2016 (edited) I can't see that you assign cliboard data ($data=ClipGet) ) to var, so what is not working and what are you expect from your snipet? Edited April 1, 2016 by AutoBert Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 That the computer name / domain window would appear - because if the COmputer Properties window is open and you press ALT +C you get the Computer name / domain window So I am trying to replicate that with autoit Link to comment Share on other sites More sharing options...
AutoBert Posted April 1, 2016 Share Posted April 1, 2016 For getting Computername you can use macro @ComputerName Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 thank you for that - however I don't want the computer name. In this case that doesn't help for my intended purposes I am trying to write an autoit script to change the name and domain newly setup computers Link to comment Share on other sites More sharing options...
AdamUL Posted April 1, 2016 Share Posted April 1, 2016 (edited) This can be done without automating the GUI for the system properties. Please look at the AD UDF for adding computer to a domain, and below is a function to change the computer name. expandcollapse popup#RequireAdmin _RenameComputer("New-Comp") ;The new computer's name is "New-Comp." Func _RenameComputer($sCompName, $sUserName = "", $sPassword = "") ;Uses WMI Win32_ComputerSystem Local $oMyError = ObjEvent("AutoIt.Error", "_ComError") ;COM Error Handler #forceref $oMyError Local $objWMIService = ObjGet("winmgmts:\root\cimv2") If @error Then Return SetError(1, 0, 0) EndIf For $objComputer In $objWMIService.InstancesOf("Win32_ComputerSystem") Local $oReturn = $objComputer.Rename($sCompName, $sPassword, $sUserName) If $oReturn <> 0 Then Return SetError(2, 0, 0) Else Return 1 EndIf Next EndFunc ;==>_RenameComputer Func _ComError($oMyError) ;COM Error function defined in COM Error Handler used in COM functions. SplashOff() BlockInput(0) ;Enable the Keyboard and Mouse. MsgBox(16, "AutoItCOM ERROR!", "COM Error Intercepted!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc ;==>_ComError Adam Edited April 1, 2016 by AdamUL Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 Thanks for that Adam - however being a complete and total Newbie you lost me Link to comment Share on other sites More sharing options...
Developers Jos Posted April 1, 2016 Developers Share Posted April 1, 2016 Sounds like an opportunity to learn rather than telling us you are lost after 5 minutes. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 I couldn't agree more - was just expressing i was lost jos Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 let me ask this - using the function I was provided for remaining the computer and joining it to the domain My question is that - can changing the computer name and domaining it be done without rebooting the system In other words is it change name - reboot then domain or change name and domain then reboot ? If you do the process manually - it can be done in one step - trying to avoid a two step / reboot process Hope that makes snese Link to comment Share on other sites More sharing options...
willichan Posted April 1, 2016 Share Posted April 1, 2016 Yes. You can do both before rebooting, as long as the PC is not already on a domain. I would recommend doing the machine name first. This will work MOST of the time. I have encountered exceptions, but in general, you should be fine. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 Thank You guys - back to my original question though - what am I doing wrong that the key command of ALT + C isn't being executed for that window ? I will look into this new approach suggested - but curious though Link to comment Share on other sites More sharing options...
markyrocks Posted April 1, 2016 Share Posted April 1, 2016 It maybe possible that you need to use {LALT} or {RALT}. It could also be possible that the window is not active? Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
OrangeCoder Posted April 1, 2016 Author Share Posted April 1, 2016 I am pretty sure the window is active - cause I see it front and center when I run the script You know it's funny for WEEKS I was trying to figure out how to name and domain a PC via a script and decided on three bat files that run and automate the while process - the first gets the parts started and the rest take it from there However I was so confused after reading yes it can be done - no it can't be done. So I was happy I got it done with three files and several reboots However now I am excited to learn it can be done in ONE step / script/ reboot! Link to comment Share on other sites More sharing options...
willichan Posted April 1, 2016 Share Posted April 1, 2016 You could use WinWaitActive() before sending characters to be sure. Key sends are a rather less than reliable way to go. Try using ControlClick() instead. You can use the "AutoIt Window Info" tool (that installs with AutoIt) to get the info you need for the ControlClick() parameters. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
markyrocks Posted April 2, 2016 Share Posted April 2, 2016 Controlsend () Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" 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