Jump to content

>.< Diff way to do this


Zaum
 Share

Recommended Posts

I wanted to make and autoit script that would chage your menu display settings.

This is what i wrote:

send("{rwindown}")
send("r")
send("{rwinup}")
send("regedit")
sleep(2000)
send("{enter}")
WinWaitActive("Registry Editor")
send("m")
send("{down}")
send("{down}")
send("c")
send("c")
send("{right}")
send("d")
mouseclick("left", 659, 572, 1)
sleep(1000)
send("m")
send("{enter}")
sleep(2000)
send("0")
send("{enter}")
winclose("Registry Editor")

I know it's simple, but i want to learn better. I thought about it, and i figured not many peoples regedit will be set the same way or positioned in the right space. How could i write this in better code?

Link to comment
Share on other sites

well firstly you could replace the top part with:

Run(@WindowsDir&"\regedit.exe")

//edit

you could replace this whole script with a single call to 'RegWrite'

Yah i knwo i could, but i want to learn better things in autoit then regwrite lol even thos this isn't much harder..

Anyhow, what exaclty does & do? i always see it in peoples commands.

Link to comment
Share on other sites

Yah i knwo i could, but i want to learn better things in autoit then regwrite lol even thos this isn't much harder..

Anyhow, what exaclty does & do? i always see it in peoples commands.

IT JUST combines to strings or variables together

like:

$var = 'Hello'
MsgBox(0,"Title",$var&" This is my messagebox")

would produce/is the same as:

MsgBox(0,"Title","Hello This is my messagebox")

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

IT JUST combines to strings or variables together

like:

$var = 'Hello'
MsgBox(0,"Title",$var&" This is my messagebox")

would produce/is the same as:

MsgBox(0,"Title","Hello This is my messagebox")
Awesome. Thanks i was trying to figure out how to do that with msgbox so it shows what they input lol.
Link to comment
Share on other sites

Okay - so you just want to learn - what a dangerous place to play - in regedit!

Regedit might open to the last key that it was on - if you let it.

Since you did not add comment lines to your code...

I have to guess what you were hoping to do with these lines:

WinWaitActive("Registry Editor")

send("m")

try:

WinWaitActive("Registry Editor")

send("{HOME}")

and hopefully you will always start at the top...

Now, what code are you going to use to get to the correct HKEY_...

Do

Send("{DOWN}")

Sleep(100)

Until WinExists("Registry Editor","HKEY_...")

Replace HKEY_... with the HKEY of interest.

That Do/Until loop could take a few seconds or it could take hours...

but you said you were just doing this to learn - right?

You can probably replace that mouse click with a tab and arrow down/up then enter.

Post your code again with comments telling us what each line was supposed to do.

later...

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Ok heres the new changed script. Thanks to all those who helped.

send("{rwindown}")              ;Runs the windows key + clicks are to open run command box then lets go of windows key
send("r")
send("{rwinup}")
send("regedit")             ;Types regedit in the run box then presses enter
sleep(2000)
send("{enter}")
WinWaitActive("Registry Editor")            ;When regedit opens it will wait until this window title appears
Do                      ; Does a do loop until the registry key is found
send("{home}")
send("{down}")
send("{down}")
send("c")
send("c")
send("{right}")
send("d")
send("{tab}")
Until WinExists ("Registry Editor", "HKEY_CURRENT_USER\Control Panel\Desktop")
sleep(1000)
Send("m")                   ; Sends the key "M" to choose the MenuDisplayDelay key then presses "Enter"
send("{enter}")
Sleep(2000)
send("0")               ;Sets the value inside the key to 0 then presses enter
Send("{enter}")
winclose("Registry Editor");Closes the registry editor
shutdown        ;Shuts down your pc to make the change take place
Edited by Zaum
Link to comment
Share on other sites

If the Registry Editor opens to HKEY_CLASSES_ROOT\.au3\ShellNew

...then your code will never get to the key of interest.

I would suggest that you move the Send("{HOME}") line just above the loop.

Then move the Send("{TAB}") line just below the loop.

(There is no need to tab to the right pane of the editor unless you are where you want to be.)

Also, you would not want to send 0 to the wrong window.

What if someone had an entry named "Main"...

...then your send "m" line would reach "Main" instead of "MenuShowDelay"

and your script would happly set "Main" to 0

change:

Send("m") ; Sends the key "M" to choose the MenuDisplayDelay key then presses "Enter"

send("{enter}")

Sleep(2000)

send("0") ;Sets the value inside the key to 0 then presses enter

Send("{enter}")

to:

Send("m") ; Sends the key "M" to choose the MenuDisplayDelay key then presses "Enter"

send("{enter}")

WinWait("Edit String","MenuShowDelay")

WinActivate("Edit String","MenuShowDelay")

WinWaitActive("Edit String","MenuShowDelay")

Send("0") ;Sets the value inside the key to 0 then presses enter

Send("{enter}")

Yes, all three "Win lines" are overkill, but this is the registry that you are playing with. As written, those three "Win lines" would halt your script if some entry other than "MenuShowDelay" was located. You could add a timeout to one of the "Win lines" above, check for that timeout error and use a function to deal with the unexpected entry.

The start of your script does not open regedit for me. I never get the Windows Menu, so the "r" does not bring up the run dialog box and so on. I'll let others work with you on that section of your code.

later...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I would replace the first 3 lines of your script with

Send("#r")
WinWait("Run")


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...