Moved to Windows 11 - Script not working

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
revel
Posts: 15
Joined: 23 Nov 2016, 17:08

Moved to Windows 11 - Script not working

Post by revel » 22 May 2024, 14:32

I have a script i was using in Windows 10 on AHK V1. I moved to Windows 11 and it no longer work. I installed v2 and it doesn't take it and I'm not sure how to build one.

Help here is much appreciated. In this script my thumb button on my mouse is Enter while in 2 applications. It appears to be working fine in Photoshop but it doesn't work in 3dsMax.



Code: Select all

;========================================================================================
;--------------------------------------------------------------------3dsMax-----------------------------------------------------------------------
;========================================================================================
{
#ifWinActive ahk_exe 3dsmax.exe
Xbutton1::
Send {Enter}
Sleep, 100
return
}


;========================================================================================
;--------------------------------------------------------------------PHOTOSHOP-----------------------------------------------------------------------
;========================================================================================
{
#ifWinActive ahk_exe Photoshop.exe
Xbutton1::
Send {Enter}
Sleep, 100
return
}

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: Moved to Windows 11 - Script not working

Post by boiler » 22 May 2024, 14:40

@revel - AHK v2 has different syntax than v1. To learn how to write v2 code, see the v2 documentation. Are you also asking for help translating this to v2, or do you just want help with the v1 version? If the latter, I'll move the thread to the v1 section of the forum.

Also, please use [code][/code] tags around your code when posting code on the forum.

revel
Posts: 15
Joined: 23 Nov 2016, 17:08

Re: Moved to Windows 11 - Script not working

Post by revel » 22 May 2024, 15:06

Thanks! Sorry on the code tags.
I was thinking it would be good or best to move to V2 if possible, help would be good - I've had problems getting things to work for me in the past
If somebody knows how to translate it to V2 and get the effect i'm going for that would be great!

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: Moved to Windows 11 - Script not working

Post by boiler » 22 May 2024, 15:15

Here's the v2 translation:

Code: Select all

#Requires AutoHotkey v2.0
;========================================================================================
;--------------------------------------------------------------------3dsMax-----------------------------------------------------------------------
;========================================================================================

#HotIf WinActive('ahk_exe 3dsmax.exe')
Xbutton1:: {
	Send '{Enter}'
	Sleep 100
}



;========================================================================================
;--------------------------------------------------------------------PHOTOSHOP-----------------------------------------------------------------------
;========================================================================================

#HotIf WinActive('ahk_exe Photoshop.exe')
Xbutton1:: {
	Send '{Enter}'
	Sleep 100
}

It can actually be consolidated to this since they're both doing the same thing and you just want to allow it when either window is active:

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive('ahk_exe 3dsmax.exe') || WinActive('ahk_exe Photoshop.exe')
Xbutton1:: {
	Send '{Enter}'
	Sleep 100
}

I don't see how a Sleep at the end helps either since nothing happens after it, so it really could just be this:

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive('ahk_exe 3dsmax.exe') || WinActive('ahk_exe Photoshop.exe')
Xbutton1::Send '{Enter}'

That's not likely to solve your issue, though. You might want to try running the script as administrator or otherwise addressing UAC.

revel
Posts: 15
Joined: 23 Nov 2016, 17:08

Re: Moved to Windows 11 - Script not working

Post by revel » 22 May 2024, 16:24

Thanks! I was curious about the Sleep myself. Somebody I used to work with built it for me originally quite a ways back.
Hrm, still isn't working in 3dsmax.exe. That is the executable. In task manager its "3ds Max 2022" if that could perhaps help.

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: Moved to Windows 11 - Script not working

Post by boiler » 22 May 2024, 17:50

Did you try running the script as administrator?

revel
Posts: 15
Joined: 23 Nov 2016, 17:08

Re: Moved to Windows 11 - Script not working

Post by revel » 22 May 2024, 18:11

OOF! Thank you. Add it to the list of that type of stuff going on since moving to Windows 11 just the other day. I had been running the same Windows 10 machine for ages.

Post Reply

Return to “Ask for Help (v2)”