Jump to content

ESC as ALT+F4


danusko
 Share

Recommended Posts

Hi everybody,

sorry for my English but i am helpless :( . I want to install on my computer this action.

Everytime i press the ESC (Escape) key, i want send ALT+F4 (close) except, when i am in Microsoft Office (Excel or Word - is active window), i want to send clasical ESC.

I write this script, but it doesnt works right.

It works when i close window of folder or other windows - but when i want to send ESC in Excel, it doesnt do nothing and after a few second show erorr info:

"Recursion level has been exceeded - Autoit will quit to prevent stack overflow"

Can you help me pls.

Thank you very much. This is my script:

-----------------------------------

$a=1

do

HotKeySet("{ESC}", "CloseWin");ESC

until $a=0

Func CloseWin()

if WinActive("Microsoft Excel","") then

Send("{ESC}")

else

Send("!{F4}")

endif

EndFunc

-----------------------------------

Link to comment
Share on other sites

The problem is Send("{ESC}") triggers the HotKeySet function which calls itself...... Based on the HotKeySet help file example/remarks:

HotKeySet("{Esc}", "CloseWindow")
While 1
sleep(100)
Wend

Func CloseWindow()
  ; ... can do stuff here
    HotKeySet("{Esc}");unregister hotkey
    If WinActive("Microsoft Excel") Then
       Send("{Esc}")
    Else
        Send("!{F4}")
    EndIf 
    HotKeySet("{Esc}", "CloseWindow");re-register
EndFunc
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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...