Jump to content

Script won't send characters to a window


Recommended Posts

This script isn't sending the characters (Line 8) to the window I select (Line 7) in the script.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
If Not WinActive("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti") Then WinActivate("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
WinWaitActive("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
Send("1921681689")
Sleep(100)
Send("{TAB}")
Send("2552552550")
Sleep(100)
Send("{TAB}192168168168")
Sleep(100)
Send("{TAB}{TAB}66{SPACE}51{SPACE}205100")
Sleep(100)
Send("{TAB}66{SPACE}51{SPACE}206100{ENTER}")
Sleep(100)
WinWait("Local Area Connection Properties","This c&onnection use")
If Not WinActive("Local Area Connection Properties","This c&onnection use") Then WinActivate("Local Area Connection Properties","This c&onnection use")
WinWaitActive("Local Area Connection Properties","This c&onnection use")
Send("{TAB}{TAB}{TAB}{ENTER}")
WinWait("Local Area Connection Status","IPv4 Connectivity:")
If Not WinActive("Local Area Connection Status","IPv4 Connectivity:") Then WinActivate("Local Area Connection Status","IPv4 Connectivity:")
WinWaitActive("Local Area Connection Status","IPv4 Connectivity:")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")

 

This is the Info from the settings window I am trying to send characters to:

SettingsAutoItInfo.jpg

This is the settings window I am trying to send characters to:

SettingsWindow.jpg

What happens is nothing gets sent to the window.

How can I make it work?

Thank you,

Docfxit

Edited by Docfxit
[spoiler='Example Spoiler'] Your code text goes here.[/spoiler] doesn't work
Link to comment
Share on other sites

standard rule of thumb in windows scripting - use controlsend and not send when possible. Much more stable for if your window loses focus, the script breaks.

Second - the best way to go here is use command line. Look here: https://www.google.com/search?q=setting+dns+by+command+line&ie=utf-8&oe=utf-8

 

Link to comment
Share on other sites

4 hours ago, Docfxit said:

This script isn't sending the characters (Line 8) to the window I select (Line 7) in the script.

  Reveal hidden contents

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
If Not WinActive("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti") Then WinActivate("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
WinWaitActive("Internet Protocol Version 4 (TCP/IPv4) Properties","You can get IP setti")
Send("1921681689")
Sleep(100)
Send("{TAB}")
Send("2552552550")
Sleep(100)
Send("{TAB}192168168168")
Sleep(100)
Send("{TAB}{TAB}66{SPACE}51{SPACE}205100")
Sleep(100)
Send("{TAB}66{SPACE}51{SPACE}206100{ENTER}")
Sleep(100)
WinWait("Local Area Connection Properties","This c&onnection use")
If Not WinActive("Local Area Connection Properties","This c&onnection use") Then WinActivate("Local Area Connection Properties","This c&onnection use")
WinWaitActive("Local Area Connection Properties","This c&onnection use")
Send("{TAB}{TAB}{TAB}{ENTER}")
WinWait("Local Area Connection Status","IPv4 Connectivity:")
If Not WinActive("Local Area Connection Status","IPv4 Connectivity:") Then WinActivate("Local Area Connection Status","IPv4 Connectivity:")
WinWaitActive("Local Area Connection Status","IPv4 Connectivity:")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")

This is the Info from the Internet settings window:

SettingsAutoItInfo.jpg

This is the settings window.  When I start the script I have the cursor in the IP address: field

SettingsWindow.jpg

What happens when I run the script is nothing gets written to the settings screen above.

I tried running the GUI debugger.  When I step through the code the debugger won't let the settings window stay focused to send the characters to the settings window.

How can I get this to send the characters to the window?

 

Thank you,

Docfxit

Thank you for sending me in the right direction.

I modified the script to send the command line.

I found two different ways of doing it.  The first way on line 8 I get a cmd window saying:

"The filename, directory name, or volume label syntax is incorrect."

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Opt("TrayIconDebug", 1) ;0-off
; Set so that tray displays current line number

$CMD = "Netsh interface ip set address ”Wireless Network Connection” static 192.168.168.6 255.255.255.0 192.168.168.168"
RunWait(@ComSpec & " /k " & $CMD)
_DosRun('netsh interface ipv4 delete dns "Wireless Network Connection" all')

MsgBox(32, "Set DNS 1", _DosRun('netsh interface ipv4 add dns "Wireless Network Connection" 8.8.8.8'))
MsgBox(32, "Set DNS 2", _DosRun('netsh interface ipv4 add dns "Wireless Network Connection" 66.51.206.100 index=2'))

WinWait("Local Area Connection Properties","This c&onnection use")
If Not WinActive("Local Area Connection Properties","This c&onnection use") Then WinActivate("Local Area Connection Properties","This c&onnection use")
WinWaitActive("Local Area Connection Properties","This c&onnection use")
Send("{TAB}{TAB}{TAB}{ENTER}")
WinWait("Local Area Connection Status","IPv4 Connectivity:")
If Not WinActive("Local Area Connection Status","IPv4 Connectivity:") Then WinActivate("Local Area Connection Status","IPv4 Connectivity:")
WinWaitActive("Local Area Connection Status","IPv4 Connectivity:")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")

Func _DosRun($sCommand)
    Local $nResult = Run('"' & @ComSpec & '" /c ' & $sCommand, @SystemDir, @SW_HIDE, 6)
    ProcessWaitClose($nResult)
    Return StdoutRead($nResult)
EndFunc   ;==>_DosRun

Does anyone have any idea how to change the syntax to make it correct?

 

Thanks,

Docfxit

Edited by Docfxit
Link to comment
Share on other sites

I would like to try ControlSend as you suggested.

Local $hWnd = WinWait("[CLASS:#32770]", "", 10)
Sleep(2000)
ControlSend($hWnd, "", "&IP address:", "1921681688")
WinClose($hWnd)

This code isn't working.  I'm guessing it's because I don't remember how to get the IP address control input field.

The input field I need can be seen in Win7 by opening the network connection properties, double clicking on the IPv4 protocol, Use the following IP address, IP address.

Thank you,

Docfxit

Link to comment
Share on other sites

Line 8,

$CMD = "Netsh interface ip set address ”Wireless Network Connection” static 192.168.168.6 255.255.255.0 192.168.168.168"

looks to me like it has a quote problem.  When you quote Wireless Network Connection, it's a quote within a quote.  To do that you would type ""Wireless Network Connection"", using double quote marks twice around the phrase.

I saw where you used single quotation marks and double quotation marks within the same line.  Not sure, but I suspect that could give the same problem.  Two single quote marks is not the same as a double quote mark.

Someone correct me if I'm wrong.  I use double quote marks (") exclusively to avoid this issue, but it would be an addition to my knowledge if single vs double quote marks made a surprising (and probably confusing) difference.

_aleph_

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

Thanks for the reply...

I found this to work for the IP address:

netsh interface ipv4 set address "Wireless Network Connection" static 192.168.168.6 255.255.255.0 192.168.168.168

I didn't use Two single quote marks.

The problem on this line turned out to be I had used IP when I should have used IPv4.

I'd like to figure out what I am doing wrong using ControlSend

ControlSend("Internet Protocol Version 4 (TCP/IPv4) Properties", '', '&IP address:', '1921681688' & '{TAB}')

I can't get it to work.

Thank you,

Docfxit

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...