Closing save prompts automatically

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ghrrum
Posts: 2
Joined: 26 Jan 2023, 10:11

Closing save prompts automatically

Post by ghrrum » 26 Jan 2023, 10:18

Code: Select all

SetTitleMatchMode, 2
Loop {
  Sleep 100
  ifWinExist, AutoCAD, Save, {
    WinActivate, AutoCAD, Save,
    Send, n
    return
  }

  ifWinExist, Autodesk Inventor Professional, Save, 2023, {
    WinActivate, Autodesk Inventor Professional, Save, 2023,
    Send, n
    return
  }
}
[Mod edit: [code][/code] tags added. Please use them yourself, next time!]

I want it to hit 'n' when either Inventor or AutoCAD pop up asking if I'm sure I want to save. If I can't make that happen with ifWinExist, can I do so with something like:
WinWait, , Save, 2023
?

User avatar
mikeyww
Posts: 27139
Joined: 09 Sep 2014, 18:38

Re: Closing save prompts automatically

Post by mikeyww » 26 Jan 2023, 12:09

Welcome to this AutoHotkey forum!

Why not just try it? Testing is fast.

Yes, WinWait will wait for a window to exist. You can use it inside a loop if you like.

If you are new to AutoHotkey, you may wish to use AHK v2 instead of the old version.

ghrrum
Posts: 2
Joined: 26 Jan 2023, 10:11

Re: Closing save prompts automatically

Post by ghrrum » 26 Jan 2023, 12:20

Apologies for not accurately explaining.

I have tested it, and it doesn't work as written. I'm missing something here and don't know what.

User avatar
mikeyww
Posts: 27139
Joined: 09 Sep 2014, 18:38

Re: Closing save prompts automatically

Post by mikeyww » 26 Jan 2023, 17:01

I would avoid commands that are deprecated. The documentation tells you.

GroupAdd can be used to define a window group. You can refer to the group in your other commands.

Code: Select all

#Requires AutoHotkey v1.1.33
#SingleInstance Force
GroupAdd n, ahk_class #32770
GroupAdd n, Save As
Loop {
 WinWaitActive % "ahk_group n"
 Send n
 SoundBeep 1500
 WinWaitNotActive
}

Code: Select all

#Requires AutoHotkey v2.0
GroupAdd 'n', 'ahk_class #32770'
GroupAdd 'n', 'Save As'
Loop {
 WinWaitActive "ahk_group n"
 Send 'n'
 SoundBeep 1500
 WinWaitNotActive
}

Post Reply

Return to “Ask for Help (v1)”