CygnusX1 Posted July 11, 2008 Share Posted July 11, 2008 All I'm trying to do is send ALT + F4. For some reason I can seem to get it to work. Please give me an example, yes, I did look and help and still couldn't figure it out :-/ Thanks Cygnus Link to comment Share on other sites More sharing options...
Andreik Posted July 11, 2008 Share Posted July 11, 2008 All I'm trying to do is send ALT + F4. For some reason I can seem to get it to work.Please give me an example, yes, I did look and help and still couldn't figure it out :-/ThanksSend ( "!{F4}") Link to comment Share on other sites More sharing options...
machalla Posted July 11, 2008 Share Posted July 11, 2008 All I'm trying to do is send ALT + F4. For some reason I can seem to get it to work.Please give me an example, yes, I did look and help and still couldn't figure it out :-/ThanksBased on the documentation for Send in the help file I put this togetherSend("#r")WinWaitActive("Run")Send("notepad.exe{Enter}")WinWaitActive("Untitled -")Send("!+{F4}",0)It seems to work fine for me. Good luck with it. dnanetwork 1 Link to comment Share on other sites More sharing options...
CygnusX1 Posted July 11, 2008 Author Share Posted July 11, 2008 Thank you! My brain still hurts, glad it's Friday. Cygnus Link to comment Share on other sites More sharing options...
Andreik Posted July 11, 2008 Share Posted July 11, 2008 (edited) Based on the documentation for Send in the help file I put this together Send("#r") WinWaitActive("Run") Send("notepad.exe{Enter}") WinWaitActive("Untitled -") Send("!+{F4}",0) It seems to work fine for me. Good luck with it. A good practice WinTitleMatchMode AutoItSetOption ( "WinTitleMatchMode",2) Send("#r") WinWaitActive("Run") Send("notepad.exe {Enter}") WinWaitActive("Notepad") Send("!+{F4}",0) Edited July 11, 2008 by Andreik Link to comment Share on other sites More sharing options...
archgriffin Posted July 11, 2008 Share Posted July 11, 2008 (edited) A good practice WinTitleMatchMode AutoItSetOption ( "WinTitleMatchMode",2) Send("#r") WinWaitActive("Run") Send("notepad.exe {Enter}") WinWaitActive("Notepad") Send("!+{F4}",0) Would not even better practice be to use ControlSend if possible? Although I am probably thinking more advanced then it has to be... AutoItSetOption ( "WinTitleMatchMode",2) Send("#r") WinWaitActive("Run") ControlSend("Run", "", "", "notepad.exe {Enter}") WinWaitActive("Notepad") ControlSend("Untitled - Notepad", "", "", "!+{F4}") Edited July 11, 2008 by archgriffin "Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend. Link to comment Share on other sites More sharing options...
Andreik Posted July 11, 2008 Share Posted July 11, 2008 Would not even better practice be to use ControlSend if possible? Although I am probably thinking more advanced then it has to be... AutoItSetOption ( "WinTitleMatchMode",2) Send("#r") WinWaitActive("Run") ControlSend("Run", "", "", "notepad.exe {Enter}") WinWaitActive("Notepad") ControlSend("Untitled - Notepad", "", "", "!+{F4}") My first impression is that CygnusX1 want to know how work Send(). muttley Link to comment Share on other sites More sharing options...
CygnusX1 Posted July 11, 2008 Author Share Posted July 11, 2008 I was desperate. I had this Explorer Server and I could not get it to close after clicking on some links. So I was trying to do ALT+F4 to see if that would close the window. So I was indeed thinking about Send() Thanks again. Cygnus Link to comment Share on other sites More sharing options...
FreeFry Posted July 11, 2008 Share Posted July 11, 2008 (edited) Why not practice the use of Run, WinClose, and the advanced window mode instead?: Run("notepad.exe") WinWait("[CLASS:Notepad]") WinClose("[LAST]") Or why not really make it really accurate, and do this: expandcollapse popup; Run Notepad $iPid = Run("notepad.exe") ;wait for the process to load up ProcessWait("notepad.exe") ;Wait for the window we're looking for to pop up, and aquire its window handle Do $hNotepad = _ProcessGetWinEx($iPid, "Notepad") Until $hNotepad[0] > 0 And WinExists($hNotepad[1]) ; Close the window WinClose($hNotepad[1]) Func _ProcessGetWinEx($ivPid, $svClass = "", $svTitle = "", $svText = "") $ivPid = ProcessExists($ivPid) If Not $ivPid Then Return(SetError(1, 0, 0)) Local $avwArray = WinList() Local $avRet[1] = [0] For $i = 1 To $avwArray[0][0] $avClass = DllCall("User32.dll", "int", "GetClassName", "hwnd", $avwArray[$i][1], "str", "", "int", 4096) If WinGetProcess($avwArray[$i][1]) = $ivPid Then If $svClass = "" Or (IsArray($avClass) And $avClass[2] = $svClass) Then If ($svTitle = "" Or StringInStr($avwArray[$i][0], $svTitle)) And ($svText = "" Or StringInStr(WinGetText($avwArray[$i][1]), $svText)) Then $avRet[0] += 1 ReDim $avRet[$avRet[0]+1] $avRet[$avRet[0]] = $avwArray[$i][1] EndIf EndIf EndIf Next Return $avRet EndFunc Sorry... little to do.. Edited July 11, 2008 by FreeFry Link to comment Share on other sites More sharing options...
dnanetwork Posted October 2, 2017 Share Posted October 2, 2017 On 7/11/2008 at 4:52 PM, machalla said: Thnx for the help. it worked like a charm... Based on the documentation for Send in the help file I put this together Send("#r") WinWaitActive("Run") Send("notepad.exe{Enter}") WinWaitActive("Untitled -") Send("!+{F4}",0) It seems to work fine for me. Good luck with it. 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