dj_frunza
dj_frunza

Reputation: 1593

How to create AutoHotKey which starts script (i.e .bat) using Cmder command line arguments?

I am trying to create an autohotkey which starts a script (i.e .bat):

#!g::
  Run "Path\To\script\script.bat" debug
  Return

The AutoHotKey works properly. However, I would like the .bat to be opened using Cmder instead of the default windows cmd.

I tried to set the Cmder as the default cmd by going to Settings-> Integration -> Default term and by checking the "Force ConEmu as default terminal for console applications", but this did not change anything in my particular case, and the script is still being ran in windows cmd.

Upvotes: 0

Views: 1763

Answers (3)

Tyarel
Tyarel

Reputation: 1

I made it work with this

Run, C:\path\Cmder\vendor\conemu-maximus5\ConEmu64.exe C:\path\to\script.exe

Upvotes: 0

dj_frunza
dj_frunza

Reputation: 1593

In the end I used below script to make it work:

; Win+Alt+y - Start script
#!y::
Run "d:\cmder\Cmder.exe" "d:\somePath\FolderContainingTheBat\"
sleep 1000
send script.bat debug{enter}

Return

EDIT

Another solution for this does not involve AutoHotKey and works only with default windows cmd. I did the following:

  1. Create a .bat file which contains the following

    script.bat debug
    
  2. Create shortcut for the newly created bat file and assign to it a "keyboard shortcut": Right click on the created shortcut -> Properties -> "Shortcut" tab -> Shortcut key

Upvotes: 1

PGilm
PGilm

Reputation: 2312

Assuming Cmder can take a command line parameter, make it explicit:

Run "Path\To\exe\Cmder.exe Path\To\script\script.bat" debug

Else, run Cmder and then use AHK to file open the script.

EDIT: Based on OP's solution, could try:

Run "Path\To\exe\Cmder.exe /Task ""Path\To\script\script.bat debug"""

or

Run "Path\To\exe\Cmder.exe /Start ""Path\To\script"" /Task ""script.bat debug"""

The exact syntax and whether and where to surround things with quotes is tbd, but try and see.

Upvotes: 1

Related Questions