I have created a batch file and its shortcut is in desktop. I created a keyboard shortcut to open the batch file (shortcut). When i press the shortcut key it will not open if i am in desktop (without no windows/applications opened) but if i opened any window/application, the shortcut will work. Is this windows bug ? Help me.
#shortcut not working on batch file
180 messages · Page 1 of 1 (latest)
It sure works for me but I'd say please still open the Feedback Hub and report it, including a short recording when prompted if you can.
the shortcut problem we talked about yesterday appears again
<@&787033266225938472>
If didn't work for me in 10 or 11 consistently, I sent you a video of it
Probably a bug
sorry for late replay, is there any program to bind a key to a program?
I have used powertoys keyboard manager quite a bit to remap keys, but I don't know of any program immediately that would do what these shortcuts are supposed to do and launch a program on a keypress. Other than like keyboards that have remappable keys like a calculate button or such.
https://cmdrkeene.com/reassign-keyboard-media-and-app-keys/
those kinds can be set in the registry
I don't have these additional keys (60% keyboard)
ugh I guess this is a longtime issue
okay top suggestion I see is an app like Auto Hot Key
i need to program it
That'll work, you can set which keystroke shortcut launches which batch file or exe.
in AHK it's basically its version of a batch file
just what instructions to do or what to launch
my keyboard software supports macro
oh cool... its language for them is probably not identical to auto-hot-key but it's probably just what you need
what is windows spy?
you know what's crazy is I'm here on my Win11 machine trying to reproduce this for my own feedback hub entry too, and when I created a shortcut to notepad with ctrl+alt+n shortcut, it's worked like 30x in a row now. Even with discord and explorer and a dozen other notepads launched. No idea why it's working suddenly. This is one of the same computers I tried it on yesterday.
never heard of it
it will appear after installing auto hot key
in system tray
i have used auto hot key before
I have used it once or twice but probably 12+ years ago
how to use macro anyway?
If it's that one that works with the keyboard I'm not sure, their website probably has a manual. What brand is it? or even model if you can find it
cosmic byte (you probably never heard of this brand), i think they sell their products specifically to a country
cbgk 32
nvm i will just download autohotkey
is it safe, right?
oh yeah the program is safe. don't use it with any scripts you are unsure about from other places. simple ones like the one I sent above (from the https://superuser.com/questions/110397/reliable-custom-windows-shortcut-keys answer) is totally safe, but someone could make a AHK script that does something stupid like delete system files and trick you into running it (unlikely, just wanted to be clear)
can you send me the link to this post?
I just did 😉
wdym?
oh sorry i though its a link to another website
Also I know this probably isn't what you want, but the taskbar buttons get automatic keyboard shortcuts based on position. WinKey+3 will always launch your 3rd taskbar button, whatever you keep there. If it's already open, it'll switch to it (or you can use Win+Shift+3 to launch "another copy" of the 3rd icon). It's a pain to use it to open individual files instead of apps, but it can be done. https://cmdrkeene.com/images/ani/TaskbarPins.gif
this is actually useful tip but i already installed autohotkey and also this shortcut is bit inconvenient for me. I will stick to autohotkey
thanks for the help!
why this ain't working? it says error in line 4
Try this out instead....
do you need code or anything?
#Requires AutoHotkey v2.0
;ctrl + alt + \ ... launch NeoVim launcher
^!::
Run "C:\NeoVim.bat"
return
Just a guess but try this for me:
;ctrl + alt + \ ... launch NeoVim launcher
^!\::
Run "C:\Windows\System32\cmd.exe /c C:\NeoVim.bat"
return
I think I got that right
It tells it to run the command line as the exe to run, and specifically that batch file as the "document" to open with that program
Error: Hotkey or hotstring is missing its opening brace.
line 4
hmm I'll check it out in just a minute
i got an idea
got it
;ctrl + alt + \ ... launch NeoVim launcher
^!\::
{
Run "C:\Windows\System32\cmd.exe /c C:\NeoVim.bat"
return
}```
autohotkey version 2 requires a slightly different code, in this case it needed { and } around the portion of what to do when you type the keystroke
save that script file, double-click it so it loads, then try typing Ctrl-Alt-\
seems to be great here, and fires instantly when you type it instead of that delay the windows shortcuts had
it works!
❤️
can you make the program to launch this file in fullscreen
I think for that you could do it inside the batch file, because it's the program the batch launches that you want in full screen right?
maybe i wll create a shortcut of this batch file and change the property to lauch it in fullscreen
that could work
but you need to change the code
i edited the code to launch the shortcut but now its not working, the file opens and closes suddenly like blink of an eye
#Requires AutoHotkey v2.0
;ctrl + alt + \ ... launch NeoVim launcher
^!::
{
Run "C:\Windows\System32\cmd.exe /c C:\Users\XXXXXXX\Desktop\NeoVim.bat"
return
}
yes ofcourse, i included a "\ " between ^! and ::
that sure looks fine to me, just like the original
any changes inside the batch file?
maybe it's running the batch but it's exiting quickly
oh, try adding just the word pause to the end of your batch file
that'll make it stop before it exits
if i launch with my mouse it opens and stays
in fullscreen
also the cmd is waiting for userinput so there is no need to add pause at the end
that is just so it doesn't close on you at the end when you press the hotkey
so you can see what it says
here is file
that one is just a shortcut file (.lnk)
are you trying to launch the link file from either the auto-hot-key macro or your batch? if so, it might work to try adding start in front of it, like start shortcut.lnk
i am trying to launch the shortcut of that batch file which is my desktop using the ahk
wdym?
you mentioned it just flashed for a split second and then closes, I think if you add pause to the end it won't immediately close so you can see what is happening instead of it just flashing quickly
yeah i tried that also but i won't work unless manually lauch using mouse
cmd is looking for userinput which is equivalent to pause is there is no need to add pause
maybe ahk is the problem
if i launch the batch shortcut file using keyboard shortcut it will stay open for split second
but if i launch it through my mouse it works fine
also wdym by this repaly?
if change the code to launch the original batch (not the shortcut file in my desktop) it works
your line that launches the shortcut, does it include "start "?
like
start c:\users\me\desktop\shortcut.lnk
no, here is the code of the ahk
if I'm not wrong (and I might be), start will help launch a shortcut lnk from the command line/batch/script
do i have to include this in my ahk? or batch?
wherever you are launching that shortcut lnk should do it
idk what what you still mean but i included start in my ahk code anyway gives me a new error
it is overwhelming my brain
"windows cannot find C:\Users\xxxxxxxx'. Make sure you typed the name correctly, and then try again.
ahk or batch?
both would probably be helpful honestly
for batch script check previous messages
and also how to paste the code as code in discord? just like you did
just to the left of the 1 key, the single backtick mark.... normally you can just use one of those on each side of a word or phrase like this, but if you want to do it for a full block of code, use three of them at the start and another 3 at the end
like
this```
;ctrl + alt + \ ... launch NeoVim launcher
^!\::
{
Run "C:\Windows\System32\cmd.exe /c start C:\Users\xxxxxxx\Desktop\NeoVim.bat"
return
}```
here is the error message after including start
ah yeah don't use start in the AHK script, let me see your batch file if you don't mind
.
where is that shortcut.lnk in the script though?
oops
i changed the code start to run NeoVim.lnk still opens and closes for split second
hmm so it's not even opening the batch file I guess
or the batch file is somehow taking a default choice at your input prompt and exiting quickly
hmm
I'll try this out in a moment and see what I can get, it's probably just a small tweak somewhere
adding pause before userinput and after userinput will not work either
windows 11 is completely broken.
lol it has nothing to do with windows 11 😄
maybe ahk is broken in windows 11
I sure don't think so
is there is any command in ahk that launches in full screen?
like earlier I had the syntax wrong because I was using AHK version 2 but trying a script based on version 1, which doesnt' work
i guess i have to learn the ahk programming to launch it in fullscreen
searching on google gives me complicated result
i'm going to try it out in a sec, but just to be sure I know what I'm trying to get, you want the batch file to open in full screen right?
like get the choices shown in a full screen view?
yes
lets discuss this tomorrow, its late night here
i am going to bed
I appreciate your efforts though!
anyway bye 👋
hey I think I got it.
• AHK script: runs this:
Run "C:\Windows\System32\cmd.exe /c start /max C:\Users\WDAGUtilityAccount\Desktop\Batch.bat"
The keystroke technically opens CMD.exe, but the /c tells it to then run another command (START in this case. The START command lets you run the batch file and it lets you use /max to start the program maximized.
My shortcut file (far left in picture/GIF) is not used at all.
should i replace WDAGUtilityAccount with my account name?
i tried replacing with my name ans it still not working
i also tried without changing anything but nope
i think i found my problem
my account name has initial at the end (eg: xxxxx x). There is space between this.
so windows is saying that it cannot find C:\Users\xxxxxx and it doesn't mention my initial. I think the problem is the space between name and initial
@waxen citrus
oh, i tried replacing Batch.bat with NeoVim.bat and NeoVim.lnk, nope not working
maybe ahk has bugs with windows 11
Is there any batch command that can fullscreen the batch program itself?
found any solution, post here. i am playing games right now
Yeah that's my username here
Oh okay let me look into this with a space
cool username!
Haha it was just an automatic one in my sandbox
i tried changing the path to the original batch file (not the shortcut file) and IT WORKED!
it launches but its not in fullscreen
When i press the keyboard shortcut for first time it launches in normal window but if i launch more than one times without closing the first window, it opens in fullscreen. The first windows remains in normal window.
The cmd itself has to be in fullscreen and then open the bacth file
Hmmm, I also saw that first cmd opens and opens my batch file and then closes itself and then my batch file opens (no surprise here). Here is the part where it gets intresting, I noticed the transition where my batch file opens in fullscreen and transform into normal window. So that means my batch file opens in fullscreen and switches back to normal window.
After searching up on Google, i found out that to include space in a path, the path must be enclosed within double quotes. The problem is that double quote is already in the ahk script. Adding another double quote makes ahk confused and throws me an error.
Any solution?
okay your username just has a space in it here right?
I looked up inside AHT 2.0 documentation and it says if you need to include additional quote marks like if your user folder has spaces, we can do that using a back tick mark ` before the ", so it'd be like this:
This type of instant run of the batch in a maximized window is what you're looking for right? https://cdn.discordapp.com/attachments/1234884968535035904/1235280111478243450/shortcut.gif?ex=66347480&is=66332300&hm=0890fb408b4e10ee5b0f0ed6a6e611a97314c854ac7356d23541b07653b46c3c&
Again its not working
This time its not opening my batch file instead it just opens cmd.exe
Is my computer broken?
Run "C:\Windows\System32\cmd.exe /c start /max `"C:\Users\MyName MyInitial\Desktop\NeoVim.lnk`"" return
I've been trying this out with a test account that uses a user folder path with a space in it like you have and yeah I'm having the same problem.