Jump to content

Send ALT F4


Recommended Posts

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

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

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 by Andreik
Link to comment
Share on other sites

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

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

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

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:

; 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 by FreeFry
Link to comment
Share on other sites

  • 9 years later...
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

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