Enter on popup Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Enter on popup

15 Nov 2018, 15:07

Hello,
I would like to make a script that sends "enter", or "y" on a pop up. I used the Window Spy to get the ahk_class. When renaming files with duplicate names, I receive a pop up where I would like the script to send "y". This is the code that I am using with no luck. What am I doing wrong?

Code: Select all

#IfWinActive ahk_class #32770 	
Send, y 
return
All help is appreciated.
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Enter on popup

15 Nov 2018, 19:06

Hi,

Not fully sure, but I don't think you need the # here.
Also, probably you will have to add either #persistent
or a loop.
Because if it works the first time it does not automatically mean it will work the other times.

But it's an interested question, and I hope this thread will be solved.

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Enter on popup  Topic is solved

15 Nov 2018, 19:43

- Try this, although I would advise using it with caution, and I would avoid using such a script.
- (I would rename files manually, or use an AHK script for complicated renaming: Loop File and FileMove. Also, I use timestamps in file names to avoid name collisions: FormatTime and SendInput.)
- To test properly: uncomment the ControlSend line and comment out the SoundPlay line.

Code: Select all

;clicks Yes every time an Explorer 'Rename File' dialog appears
OnRenameFileDlg(hWinEventHook, vEvent, hWnd)
{
	local
	;EVENT_OBJECT_SHOW := 0x8002
	static vFunc := "OnRenameFileDlg", _ := DllCall("user32\SetWinEventHook", UInt,0x8002, UInt,0x8002, Ptr,0, Ptr,RegisterCallback(vFunc), UInt,0, UInt,0, UInt,0, Ptr)
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	if !(vWinTitle = "Rename File")
		return
	WinGet, vPName, ProcessName, % "ahk_id " hWnd
	if !(vPName = "explorer.exe")
		return
	SoundPlay, *64
	;ControlSend, Button1, y, % "ahk_id " hWnd
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Re: Enter on popup

16 Nov 2018, 08:59

jeeswg wrote:
15 Nov 2018, 19:43
- Try this, although I would advise using it with caution, and I would avoid using such a script.
- (I would rename files manually, or use an AHK script for complicated renaming: Loop File and FileMove. Also, I use timestamps in file names to avoid name collisions: FormatTime and SendInput.)
- To test properly: uncomment the ControlSend line and comment out the SoundPlay line.

Code: Select all

;clicks Yes every time an Explorer 'Rename File' dialog appears
OnRenameFileDlg(hWinEventHook, vEvent, hWnd)
{
	local
	;EVENT_OBJECT_SHOW := 0x8002
	static vFunc := "OnRenameFileDlg", _ := DllCall("user32\SetWinEventHook", UInt,0x8002, UInt,0x8002, Ptr,0, Ptr,RegisterCallback(vFunc), UInt,0, UInt,0, UInt,0, Ptr)
	WinGetTitle, vWinTitle, % "ahk_id " hWnd
	if !(vWinTitle = "Rename File")
		return
	WinGet, vPName, ProcessName, % "ahk_id " hWnd
	if !(vPName = "explorer.exe")
		return
	SoundPlay, *64
	;ControlSend, Button1, y, % "ahk_id " hWnd
}
Thank you so much for all your help :bravo:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: NinjoOnline and 291 guests