Cabler Posted May 13, 2013 Share Posted May 13, 2013 (edited) Hi Im Ricky I have been trying set something up for a long time now many months and have done a lot of googling and reading the forums/researching gleaming info here and there before coming here and asking for some help I am of the older generation not long before I draw my pension but after a couple of heart attacks and two strokes do stuggle at times with trying to figure out some of the script stuff but I do try to keep the grey matter alive.. Ok down to buisiness.. I need access to my pc remotely when I am away from home so I use wol to start my pc remotely over the internet, the router I use I have to enable telnet mode by accessing a hidden web page on the router and log in then I have telnet access..I then set up a static arp to my pc so as it knows where to send the wol magic packet to wake it up if I dont do this then when the pc is shut down the router clears the arp cache and doesnt know where to send the magic packet..ok so far this is all well and good but if I have a power failure of the router reboots then all is lost and it goes back to default no telnet acces and no static arp route to my pc so no remote access.. Ok I decided to write a script that when the computer is auto powered on early in the am it runs a script that opens an ie windows and navigates to the enable telnet page logs in with user name and password then closes it then it calls a program/script called arse (Automatic Router Scripting Engine is a tool to send command scripts to your router automatically via telnet)written in autoit by cor a very nice utility.. which sets the static arp.. thats it.. The problem I am having is that it works fine half a dozen or so times then for some reason it seems to lose focus of the login window and does nothing unless I click anyware in the login window the it logs in and closes the ie session and then runs arse as it should do. What I was hopeing for was someone to cast an eye over the script and see if theres any faults or maybe a better way to do this so as it is reliable and doesnt loose focus on the login popup.. anyways thanks for your time heres the script regards Ricky #AutoIt3Wrapper_UseX64=N $uNAME = "user" ;Change to your username to your router username $uPASS = "pass" ;Change to your password to your router password $oIE = ObjCreate ( "InternetExplorer.Application" ) $oIE.Visible = 1 $oIE.Left = 600 $oIE.Top = 300 $oIE.Width = @DesktopWidth /4.4 $oIE.Height = @DesktopHeight /3.4 $oIE.Menubar = 0 $oIE.Toolbar = 0 $oIE.Statusbar = 0 $oIE.Resizable = 0 $uRL = "192.168.1.2/setup.cgi?todo=debug" ;Send the command to enable telnet on dgnd3700v2 $oIE.Navigate ($uRL) Sleep (800) WinWaitActive ("Windows Security", "" ,1000000) WinActivate ("Windows Security") ControlSetText("Windows Security", "", "Edit1", ($uNAME)) Sleep (500) ControlSetText("Windows Security", "", "Edit2",($uPASS)) Sleep (500) ControlClick ("Windows Security", "", "Button2") Sleep (500) controlfocus("http://192.168.1.2/setup.cgi?todo=debug - Windows Internet Explorer", "Class:IEFramehttp://192.168.1.2/setup.cgi?todo=debug - Windows Internet Explorer", "Internet Explorer_Server1");Focus on the finished ie window Sleep (100) WinClose("http://192.168.1.2/setup.cgi?todo=debug - Windows Internet Explorer") ;Close the finished ie window Sleep (600) ShellExecute("NetSet.arse") ;Set static arp Exit Edited May 13, 2013 by Cabler Xandy and Nilywxywml 2 Link to comment Share on other sites More sharing options...
Xandy Posted May 13, 2013 Share Posted May 13, 2013 My first thought, is set focus. Maybe get the window position, and force a click with in the window area. (I've had to do that before.) I have to get to work for the next 2 hours, then I'll take a look back here and see what I can do for you. Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
JohnOne Posted May 13, 2013 Share Posted May 13, 2013 To make that script a little more robust, I would put each of your functions in a loop and test them until they are correct. For example. Do WinActivate ("Windows Security") Sleep(500) Until WinActive("Windows Security") Same with Others. ControlSetText and ControlGetText ControlFocus and ControlGetFocus etc... And also check for whatever is supposed to occur after your ControlClick. Cabler and Xandy 2 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Xandy Posted May 14, 2013 Share Posted May 14, 2013 (edited) If for some reason IE shows on winactivate(), but does not receive focus. After winactivate (so the window is visible) $po= wingetpos("The_IE_Window_Title"); specificly the title of your window in question. mouseclick("left", $po[0]+45, $po[1]+45); or something like that That should force input focus. Bare in mind that the +45 to x and y may need adjusted. edit: I did something like that for a Chrome window, and the $po[0], [1], [2], [3] (x, y, w, h) values returned by wingetpos() were incorrect. I was able to use the values to find a point within the window. What I am saying is it might not be as straight forward as it should be. Regardless, I'd like to hear more about how this goes for you. Edited May 14, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Cabler Posted May 14, 2013 Author Share Posted May 14, 2013 Gentlemen thank you both for your prompt replies and suggestions.. I tested both and have decided to use the loop idea that John suggested. I will run it for a while and see if I have any issues.. thank you.. on another note I spoke to a real nice guy "cor" who wrote arse and he aslo gave me some ideas for furthur additions to add some other stuff to my script so will enjoy playing around with some things to try and furthur my knowlege once again many thanks gentlemen regards Ricky Link to comment Share on other sites More sharing options...
Solution Cabler Posted May 14, 2013 Author Solution Share Posted May 14, 2013 Just an update..further to my last post I have spend a few more hours tweaking this script..I added the winactivate loop in a few places and it seems to be very stable now even if I click elsewhere on the screen it returns to the pop up, after my chat with cor I now instead of calling arse to set the router up I create a tcp socket and telnet into the router to set the static arp up and show a progress bar just to waste a few seconds while the telnet is established and cmds sent and to finish it all at the end have a msgbox popup to show the script has completed and play the std windows alert.. next is to do some error checking on the telnet session by pinging the router first to make sure connection is established like cor does in arse.. regards Ricky Xandy 1 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