Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Send KeyStroke to CMD



  • Please log in to reply
32 replies to this topic
Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

If you dont want to run cmd.exe as admin then you will need another solution.



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Hi Xtra, I thought you were implying i shouldn't be running it as admin.

 

I have no issues running it as admin and and test it with the same result.

Its just not passing any keystrokes to the cmd.exe window....



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Also looking at the Autohotkey I see the following:Script lines most recently executed (oldest first).  Press [F5] to refresh.  The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0).  The bottommost line's elapsed time is the number of seconds since it executed.

 
001: Return (11.05)
001: ControlSend,,{enter},cmd
001: Return (0.91)
001: ControlSend,,{enter},cmd
001: Return (0.31)
001: ControlSend,,{enter},cmd
001: Return (0.25)
001: ControlSend,,{enter},cmd
001: Return (0.19)
001: ControlSend,,{enter},cmd
001: Return (0.22)
001: ControlSend,,{enter},cmd
001: Return (0.19)
001: ControlSend,,{enter},cmd
001: Return (0.22)
001: ControlSend,,{enter},cmd
001: Return (0.45)
001: ControlSend,,{enter},cmd
001: Return (0.20)
001: ControlSend,,{enter},cmd
001: Return (0.19)
001: ControlSend,,{enter},cmd
001: Return (3.34)
 
Press [F5] to refresh.
 
But nothing i sent to the cmd.exe window.


Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Could you try running the script as admin also.



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Same.....

 

But I found something interesting. While the script is running my Enter key does seem to do anything in other applications.

 

For example if I open up notepad and hit enter it doesnt do anything. Is this normal?



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

add ~ prefix to use as passthrough

 

~$Enter::ControlSend, , {enter}, cmd  ; Send directly to a command prompt window.

 

 

Also if you dont have the current AHK version please download it here: http://ahkscript.org/download/  v1.1.15.04 - August 12, 2014

 

 

 

Edit: added link.


Edited by Xtra, 26 August 2014 - 05:14 AM.


Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

ok that fixed the enter key stroke working on other applications, but its not running sending key stroke to cmd window still

 

I'm sorry mate you must be sick of this now... lol



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Happy to share my screen with you using team viewer if you like.



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Its ok im sure its something simple as it allways is once you know whats wrong.

 

I posted link above just to eliminate that factor if using an older version.

 

It works like it should on my machine.(i know it doesnt help)

 

Im using vista64 with UAC on ,  running cmd.exe as admin and running script as normal using ahk v1.1.15.04

 

-X



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Thanks mate, I did try the link above and used it as well. Still the same thing.

 

Im running Autohotkey and CMD in admin. Its just still not seeing any key strokes in CMD.

 

Im running Windows 8.1 64bit.



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Just to be clear on this sending enter is just like sending enter in the cmd window manually.

There wont be any keystrokes to see other then it showing a new line.

 

Also if you run cmd without admin rights it will show something like C:\Users\yourname>

If running with admin it will show C:\Windows\System32>



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Yep that is correct.

 

I just wanted the CMD.EXE to go to the next line when I pre enter... same as pressing enter in the cmd.exe window.

 

Also the CMD.EXE window does say Administrator in the title.

 

"Administrator C:\Windows\System32\cmd.exe"



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Win8 can cause problems you probably need to do this.

http://www.autohotke...ative-programs/

 

 

From:http://ahkscript.org/docs/FAQ.htm

A common problem when moving from XP to Vista or a later version of Windows is that programs which are "elevated" (run as administrator) block hotkeys or refuse to be automated. There are at least three workarounds:

  • Modify AutoHotkey.exe to enable interaction with administrative programs. This has some drawbacks. For more information see http://www.autohotke...ative-programs/
  • Run the script as administrator. Note that this also causes any programs launched by the script to run as administrator.
  • Disable User Account Control (not recommended); in Windows 8 and later you may also have to disable the security setting "Run all administrators in Admin Approval Mode" (also not recommended).


Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Ok something else to try:

http://www.autohotke...46-consolesend/

 

It works without using cmd.exe as admin.

 

I tested it with this

~$Enter::ConsoleSend("`r", "ahk_class ConsoleWindowClass")

 

Works just like the other way.



Hondo
  • Members
  • 17 posts
  • Last active: Aug 26 2014 11:50 AM
  • Joined: 25 Aug 2014

Ok something else to try:

http://www.autohotke...46-consolesend/

 

It works without using cmd.exe as admin.

 

I tested it with this

~$Enter::ConsoleSend("`r", "ahk_class ConsoleWindowClass")

 

Works just like the other way.

 

 

When I try the above I get the following error when running the script:

 

Error: Call to nonexisting function.

 

Specifically: ConsoleSend("","ahk_class ConsoleWindowClass")

 

I'm yet to try the workarounds for windows 8.