Nova Posted February 2, 2005 Share Posted February 2, 2005 The following code is just an example of something im trying to do, so do not advise me on an easier way to shutdown mycomputer becasue thats now what im after, its the method im intrested in. The following code waits untill a cmd window is active and then it sends the command shutdown -s Run(@SystemDir & '\cmd') WinWaitActive(@SystemDir & '\cmd') Sleep(250) ControlSend(@SystemDir & '\cmd', "", "", "shutdown -s{Enter}") while 1 sleep (10) WEnd I want this to happen inhidden mode so for example Run(@SystemDir & '\cmd', "", @sw_hide) WinWaitActive(@SystemDir & '\cmd') Sleep(250) ControlSend(@SystemDir & '\cmd', "", "", "shutdown -s{Enter}") while 1 sleep (10) WEnd It appears the problem is WinWaitActive dose not detect hidden active windows. Dose anyone have a work around for this ? Link to comment Share on other sites More sharing options...
Developers Jos Posted February 2, 2005 Developers Share Posted February 2, 2005 are you using opt("WinDetectHiddenText",1) ?WinDetectHiddenText Specifies if hidden window text can be "seen" by the window matching functions.0 = Do not detect hidden text (default)1 = Detect hidden text SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nova Posted February 2, 2005 Author Share Posted February 2, 2005 (edited) are you using opt("WinDetectHiddenText",1) ?Just tested the below script with your above idea !opt("WinDetectHiddenText",1) Run(@SystemDir & '\cmd',"",@SW_HIDE) WinWaitActive(@SystemDir & '\cmd') Sleep(250) ControlSend(@SystemDir & '\cmd', "", "", "shutdown -s{Enter}") while 1 sleep (10) WEndIts still not working. Edited February 2, 2005 by Nova Link to comment Share on other sites More sharing options...
SlimShady Posted February 2, 2005 Share Posted February 2, 2005 A hidden window CAN be active but that's not always the case especially if the user is clicking while the script is running. This is probably how you want it. Run(@ComSpec & " /k TITLE HideCmd","",@SW_HIDE) WinWait('HideCmd') Sleep(250) ControlSend('HideCmd', "", "", "shutdown -s{Enter}") This is what I would do. Run(@ComSpec & " /c shutdown -s", @SystemDir, @SW_HIDE) Link to comment Share on other sites More sharing options...
Nova Posted February 2, 2005 Author Share Posted February 2, 2005 This is probably how you want it.Run(@ComSpec & " /k TITLE HideCmd","",@SW_HIDE) WinWait('HideCmd') Sleep(250) ControlSend('HideCmd', "", "", "shutdown -s{Enter}")Thats perfect, just what I wanted, but can u explain how it works ?I want to do the same with other shell windows.For example what im actually trying to do is start a netcat session on my computer which connects to another computer on my network.Once the connection is made I geta remote CMD prompt for that computer So I want my script to wait for the netcat shell window to become active in hidden mode, and send the command shutdown -s, which should shutdown the remote computer.Thats why the following wont work This is what I would do.CODERun(@ComSpec & " /c shutdown -s", @SystemDir, @SW_HIDE)Taking your above example, how would that apply to the following code ?Ive tryed many different versions of your example and cannot get it to work for this situation. Run(@ScriptDir & '\Utilities\Netcat.exe Comp2 4444') WinWait(@ScriptDir & '\Utilities\Netcat.exe) Sleep(250)ControlSend(@ScriptDir & '\Utilities\Netcat.exe', "", "", "shutdown -s{Enter}") while 1 sleep (10)WEnd Link to comment Share on other sites More sharing options...
SlimShady Posted February 2, 2005 Share Posted February 2, 2005 (edited) Three scripts you can test out. ;Test 1 Run(@ComSpec & ' /c TITLE HideCmd & "' & @ScriptDir & '\Utilities\Netcat.exe" Comp2 4444') WinWait('HideCmd') Sleep(1000) ControlSend('HideCmd', "", "", "shutdown -s{Enter}") while 1 sleep (10) WEnd ;Test 2 Run(@ComSpec & ' /c TITLE HideCmd && "' & @ScriptDir & '\Utilities\Netcat.exe" Comp2 4444') WinWait('HideCmd') Sleep(1000) ControlSend('HideCmd', "", "", "shutdown -s{Enter}") while 1 sleep (10) WEnd ;Test 3 Opt("WinTitleMatchMode", 2) Run(@ComSpec & ' /c "' & @ScriptDir & '\Utilities\Netcat.exe" Comp2 4444') WinWait('Utilities\Netcat.exe) Sleep(1000) ControlSend('Utilities\Netcat.exe, "", "", "shutdown -s{Enter}") while 1 sleep (10) WEnd Let us know if th above examples work for you. Once it works, you can add the @SW_HIDE parameter. Edited February 2, 2005 by SlimShady Link to comment Share on other sites More sharing options...
Nova Posted February 2, 2005 Author Share Posted February 2, 2005 Let us know if th above examples work for you.The first 2 work flawlessly :"> the 3rd one however dosent work.Tnx a million slim. Link to comment Share on other sites More sharing options...
SlimShady Posted February 2, 2005 Share Posted February 2, 2005 I'm glad. No problem, you're welcome. 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