简体   繁体   中英

How to detect if the user is naming/renaming a file/folder in AutoHotKey

I don't want hotkeys to fire up when this or this is happening. How can I do that?

Something I'm expecting:


#IfWinActive ahk_exe Explorer.exe

.::

if(!namingfile){

    run, "C:\Users\david\AppData\Local\Programs\Microsoft VS Code\bin\code"

}

return

#IfWinActive

How do I check for !namingfile ?

EDIT: I forgot to mention I also want it to ignore in the file address bar. I guess it should try to detect if I'm editing some text? I'm trying to achieve this question.

Thank you /u/jcunews1 for helping me! Here's the answer:

#IfWinActive ahk_exe Explorer.exe
.::
    if (focused == "Edit1") {
        controlget hwndEdit, hwnd, , %focused%, a
        hwndparent:= dllcall("GetParent", "ptr", hwndEdit, "ptr")
        wingetclass parentclass, ahk_id %hwndparent%
        isNotRenaming:= parentClass == "CtrlNotifySink"
    } else isNotRenaming:= false
    if (isNotRenaming) {
        EnvGet LocalAppData, LOCALAPPDATA
                Run % LocalAppData "\Programs\Microsoft VS Code\bin\code"
    } else {
        Send .
    }
    return

#IfWinActive

I tested it and it works very well like I described in the first question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM