Jump to content
Sign in to follow this  
danusko

ESC as ALT+F4

Recommended Posts

danusko

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

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

Share this post


Link to post
Share on other sites
CyberSlug

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!

Share this post


Link to post
Share on other sites
danusko

great :())))

it works

thanks

Share this post


Link to post
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
Sign in to follow this  

×