Sign in to follow this  
Followers 0
Dirk98

Open My Computer / Control Panel

17 posts in this topic

Guys, again very basic question, sorry.

How can I open Control Panel or My Computer or Network Connections with a line in the script?

Can't think of anything but RUN function. But don't know how to invoke those windows above.

Thank you.

Share this post


Link to post
Share on other sites



Guys, again very basic question, sorry.

How can I open Control Panel or My Computer or Network Connections with a line in the script?

Can't think of anything but RUN function. But don't know how to invoke those windows above.

Thank you.

Look at Dx21 site for reference to open the particular control panel applet with Run().

:)

Share this post


Link to post
Share on other sites

Look at Dx21 site for reference to open the particular control panel applet with Run().

:)

MHz, thank you very much. I really hope I'll dig it out there. In the meantime if someone could give an exemplary line will be much appreciated.

Share this post


Link to post
Share on other sites

Look at Dx21 site for reference to open the particular control panel applet with Run().

:)

Mhz, I've found it, but can not "connect" to AutoIt:

Syntax

:

RunDll32.exe shell32.dll,Control_RunDLL

Anyone, pls? The line is so long. Can anyone please adapt it to AutoIT's RUN?

Thank you.

Share this post


Link to post
Share on other sites

Mhz, I've found it, but can not "connect" to AutoIt:

:

RunDll32.exe shell32.dll,Control_RunDLL

Anyone, pls? The line is so long. Can anyone please adapt it to AutoIT's RUN?

Thank you.

Turns out it's obvious:

Run("RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl")

Run("RunDll32.exe shell32.dll,Control_RunDLL")

Thanks again, MHZ!

Share this post


Link to post
Share on other sites

@Dirk98 - Good job! You're making some nice progress. :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

:) you can just Run('control panel') or Run(@SystemDir&'\control.exe')... no need for dll

to open network connections just Run(@SystemDir&'\ncpa.cpl') .... for the rest of control panel see files in system32 ending in .cpl

Edited by Gif

Share this post


Link to post
Share on other sites

:) you can just Run('control panel') or Run(@SystemDir&'\control.exe')... no need for dll

to open network connections just Run(@SystemDir&'\ncpa.cpl') .... for the rest of control panel see files in system32 ending in .cpl

Excellent advice, Gif. I've checked them, just Run(@SystemDir&'\ncpa.cpl') doesn't work. Any ideas?

Any chance you know how to invoke this particular windows panel by a script:

Posted Image

Many thanks.

Share this post


Link to post
Share on other sites

@Dirk98 - Good job! You're making some nice progress. :)

You're laughing at my titanic effort of thought, ssubirias3! :P

By chance, do YOU know how to bring that window up (see above)?

Thanks, guys, I appreciate the time you spend on noobs like me. :)

Share this post


Link to post
Share on other sites

You're laughing at my titanic effort of thought, ssubirias3! :)

By chance, do YOU know how to bring that window up (see above)?

Thanks, guys, I appreciate the time you spend on noobs like me. :)

My friend you misunderstood my comment. I wasn't laughing at you. I was applauding/dancing for you because you figured it out on your own! You went from having your script use

RunDll32.exe shell32.dll,Control_RunDLL

TO

Run("RunDll32.exe shell32.dll,Control_RunDLL ncpa.cpl")

I personally don't know how to get that exact window pulled up by itself. I'm guessing its possible using DllCall() but I don't know which Windows .dll or the function within the dll to do it for you. If a developer wants to tell me which .dll I'd be more than happy to try and figure it out for you. btw, I'm a noob just like you and the others. You can't go by the number of post or joined date or member number and say someone knows (or doesn't know) what they are talking about. Unless they are an Admin, Moderator, or MVP... that's like talking to a god (little g)!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

...I personally don't know how to get that exact window pulled up by itself...

I don't know how to go straight to that window either... but I do know that someone is going to suggest netsh.exe instead of scripting the operating system's screens.

Dirk98,

Search the forum for netsh and you will find several examples of how to change network settings.... that said, here is some code for you to look thru:

AutoItSetOption("WinWaitDelay", 1)  ;(milliseconds)
AutoItSetOption("TrayIconDebug", 1)  ;0-off

Run("rundll32.exe shell32,Control_RunDLL ncpa.cpl")
WinWait("Network Connections")
WinActivate("Network Connections")
WinWaitActive("Network Connections")

$ret1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")
If $ret1 = -1 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

$ret2 = ControlListView("Network Connections", "", "SysListView321", "Select", $ret1)
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")
If $ret2 = -1 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

$ret3 = ControlFocus("Network Connections", "", $ret2)
If $ret3 = 0 Then
    MsgBox(0, "AutoIt", 'No connection named "Wireless Network Connection" could be found.')
    Exit
EndIf

WinWait("Network Connections", "Wireless")
WinActivate("Network Connections", "Wireless")
WinWaitActive("Network Connections", "Wireless")
Send("!{ENTER}")

WinWait("Wireless Network Connection Properties", "General")
WinActivate("Wireless Network Connection Properties", "General")
WinWaitActive("Wireless Network Connection Properties", "General")
$item_number = ControlListView("Wireless Network Connection Properties", "General", 16012, "FindItem", "Internet Protocol (TCP/IP)")
If $item_number = -1 Then
    MsgBox(0, "AutoIt", "Item not found")
    Exit
EndIf
ControlListView("Wireless Network Connection Properties", "General", 16012, "Select", $item_number)
ControlSend("Wireless Network Connection Properties", "General", 16012, "!r")

WinWait("Internet Protocol (TCP/IP) Properties", "General")
WinActivate("Internet Protocol (TCP/IP) Properties", "General")
WinWaitActive("Internet Protocol (TCP/IP) Properties", "General")
ControlCommand("Internet Protocol (TCP/IP) Properties", "General", "Button3", "Check", "")

;Static IP
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit4", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit3", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit2", "3")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit1", "35")

;Subnet Mask
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit8", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit7", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit6", "255")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit5", "0")

;Default Gateway
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit12", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit11", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit10", "3")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit9", "1")


ControlCommand("Internet Protocol (TCP/IP) Properties", "General", "Button6", "Check", "")

;DNS 1
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit16", "212")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit15", "188")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit14", "4")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit13", "10")

;DNS 2
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit20", "192")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit19", "168")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit18", "9")
ControlSetText("Internet Protocol (TCP/IP) Properties", "General", "Edit17", "17")

ControlClick("Internet Protocol (TCP/IP) Properties", "General", "Button8") ;enter

;turn off Windows control of wireless card
WinWait("Wireless Network Connection Properties", "General")
WinActivate("Wireless Network Connection Properties", "General")
WinWaitActive("Wireless Network Connection Properties", "General")

ControlCommand("Wireless Network Connection Properties", "General", "SysTabControl321", "TabRight", "")
If @error = 1 Then MsgBox(0, "AutoIt", "Control could not be found.")

If WinWait("Wireless Network Connection Properties", "Wireless Networks", 1) = 1 Then
    WinActivate("Wireless Network Connection Properties", "Wireless Networks")
    WinWaitActive("Wireless Network Connection Properties", "Wireless Networks")

    ControlCommand("Wireless Network Connection Properties", "Wireless Networks", "Button1", "UnCheck", "")
    ControlClick("Wireless Network Connection Properties", "Wireless Networks", "Button11")
Else
    ControlClick("Wireless Network Connection Properties", "Advanced", "Button9")
EndIf

WinClose("Network Connections")
I would suggest that you not run the code until you understand what each line/section does --- i.e. the code is for working with a wireless card and it turns off Windows' control over that card --- you may not want that.

Just look up each function that you need help understanding. If you still don't get it, post back and/or PM me.

Once you get this code working like you want it - you can move on to netsh - then you will wonder why you ever bothered with the code above.

BTW, bits and pieces of the code above came from others' posts --- I seem to recall a line of code that did not follow what the help file said you could do with a function... but I could not find it at a glance. If you find it, PM me.

-MSP-

Edited by herewasplato

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Just look up each function that you need help understanding. If you still don't get it, post back and/or PM me.

Thank you so much, herewasplato. The most of the code looks all Greek to me, so I'll start asking right from the beginning: :)

AutoItSetOption("WinWaitDelay", 1);(milliseconds)
- it sets out that the script should briefly pause for 1 ms after a successful operation with a window. Don't know what it gives since 1 ms is too short anyway. What if I just removed it? (I will not, of course :) )

AutoItSetOption("TrayIconDebug", 1);0-off
- don't know if I'll need this line (I guess I won't need any debugging at this stage)

Run("rundll32.exe shell32,Control_RunDLL ncpa.cpl")
WinWait("Network Connections")
WinActivate("Network Connections")
WinWaitActive("Network Connections")

The above should just open windows' NETWORK CONNECTION window and activate it.

Edited by Dirk98

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

This part is completely beyond me:

$ret1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")

What is:

$ret1 =

ControlListView is said to send a command to ListView32 control. What is ListView32 control? Why do we need it here?

Edited by Dirk98

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

In

$ret1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")

what is SysListView321 and FindItem?

I understand "Network Connections" is the title of the window to access.

Where does SysListView321 fit into? Is it a text or controlID or command? Same for FindItem.

Thanks.

Edited by Dirk98

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

In

$ret1 = ControlListView("Network Connections", "", "SysListView321", "FindItem", "Wireless Network Connection")

what is SysListView321 and FindItem?

I understand "Network Connections" is the title of the window to access.

Where does SysListView321 fit into? Is it a text or controlID or command? Same for FindItem.

Thanks.

SysListView321 is the ClassnameNN of that window... take a look at controls and Au3Info

for 'finditem' look at ControlListView()

Edited by Gif

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

there is also another way to easily open network connections (works):

#include <process.au3>
_RunDOS('start '&@SystemDir&'\ncpa.cpl')

if you want some detailes about adaptors look at adapter list bu A.Percy

Edited by Gif

Share this post


Link to post
Share on other sites

If you remove this line:

AutoItSetOption("WinWaitDelay", 1)

then AutoIt will revert to using the default of 250 milliseconds and the script runs slower... but it still runs. Either way is fine - with or without it.

I would leave this line in - at least until you get the script working as you like:

AutoItSetOption("TrayIconDebug", 1)

If the script seems to halt, then move your mouse over the AutoIt icon in the system tray and it should tell you what line of code the script halted on. Maybe a WinWait line with a bad title in the code.

Run("rundll32.exe shell32,Control_RunDLL ncpa.cpl")

WinWait("Network Connections")

WinActivate("Network Connections")

WinWaitActive("Network Connections")

The above should just open windows' NETWORK CONNECTION window and activate it.......yep

-MSP-


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

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
Sign in to follow this  
Followers 0