OrangeCoder

Alt C not working

23 posts in this topic

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

Share this post


Link to post
Share on other sites



Try putting a delay between the window opening and the button press.

Share this post


Link to post
Share on other sites

hey mark

 

I would do that with  Sleep ("XX")  right?

Share this post


Link to post
Share on other sites

Yep or use a method like winwaitactive ().

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

So I tried this

Run('control.exe sysdm.cpl')
Sleep(2000)
Send("!c")

still not working - thanks for your help 

Edited by OrangeCoder

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by AutoBert

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

For getting Computername you can use macro @ComputerName

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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.  

 

 

#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 by AdamUL

Share this post


Link to post
Share on other sites

Thanks for that Adam - however being a complete and total Newbie you lost me 

Share this post


Link to post
Share on other sites

I couldn't agree more - was just expressing i was lost jos

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

It maybe possible that you need to use {LALT} or {RALT}.  It could also be possible that the window is not active?   

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Controlsend ()

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now