Sign in to follow this  
Followers 0
Alterego

Logging cmd.exe

5 posts in this topic

Man..there has to be a way! If I can get this text to the clipboard via left click, {s}, {ENTER}, i can start logging this stuff. is cmd.exe onto fake mouse clicks? it doesnt appear to work at all.

AutoItSetOption("TrayIconDebug", 1)
;;unfortunately cmd.exe gives us no controls with which to interact. very crude, this.
Do
   If ProcessExists("cmd.exe") Then
      $a = WinGetTitle(@SystemDir & "\cmd.exe")
      WinActivate($a)
      WinWaitActive($a)
      WinSetState($a, "", @SW_MAXIMIZE)
      MouseMove(50, 50)
      MouseDown("left")
      Sleep(200)
      MouseUp("left")
      Sleep(750)
      Send("{s}")
      Sleep(750)
      Send("{ENTER}")
      $b = ClipGet()
      MsgBox(1, "", $b)
   EndIf
   Sleep(1000)
Until 1 = 0

Is there any way to use something like VBs Keybd_Event? I dont know but have read that the OS cant tell the difference between real and nonreal events when used with that.

*sigh*

Share this post


Link to post
Share on other sites



ahh, here it is on the MSDN site: link

The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function.

It's too bad though, it can't be done with just the keyboard. Need a damn mouse click!

/me searches for a mouse equivalent

anyone tried this before?

Share this post


Link to post
Share on other sites

/me continues conversation with self

hey, i got it to work! can you believe that?

AutoItSetOption("TrayIconDebug", 1)
;;unfortunately cmd.exe gives us no controls with which to interact. very crude, this.
Do
   If ProcessExists("cmd.exe") Then
      $a = WinGetTitle(@SystemDir & "\cmd.exe")
      WinActivate($a)
      WinWaitActive($a)
      WinSetState($a, "", @SW_MAXIMIZE)
      MouseMove(5, 5)
      MouseDown("left")
      Sleep(200)
      MouseUp("left")
      Sleep(750)
      Send("{e}")
      Sleep(750)
      Send("{s}")
      Sleep(750)
      Send("{ENTER}")
      $b = ClipGet()
      MsgBox(1, "", $b)
   EndIf
   Sleep(1000)
Until 1 = 0

ideally you wouldn't have to activate the window and could interact with a control...but there just isnt anything. still...i can log everything that goes across a server's cmd.exe with this :lmao:

Share this post


Link to post
Share on other sites

Here is another way to do this.

I used the windows hotkeys for the command window.

AutoItSetOption("TrayIconDebug", 1)
;;unfortunately cmd.exe gives us no controls with which to interact. very crude, this.
;;uses the windows hotkeys
Do
   If ProcessExists("cmd.exe") Then
      $a = WinGetTitle(@SystemDir & "\cmd.exe")
      WinActivate($a)
      WinWaitActive($a)
      Send("!{SPACE}{UP 3}{RIGHT}{UP 3}{ENTER 2}")

      $b = ClipGet()
      MsgBox(1, "", $b)
   EndIf
   Sleep(1000)
Until 1 = 0

:lmao:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here is another way to do this.

I used the windows hotkeys for the command window.

AutoItSetOption("TrayIconDebug", 1)
;;unfortunately cmd.exe gives us no controls with which to interact. very crude, this.
;;uses the windows hotkeys
Do
   If ProcessExists("cmd.exe") Then
      $a = WinGetTitle(@SystemDir & "\cmd.exe")
      WinActivate($a)
      WinWaitActive($a)
      Send("!{SPACE}{UP 3}{RIGHT}{UP 3}{ENTER 2}")

      $b = ClipGet()
      MsgBox(1, "", $b)
   EndIf
   Sleep(1000)
Until 1 = 0

:lmao:

<{POST_SNAPBACK}>

Ok, one better...

AutoItSetOption("TrayIconDebug", 1)
;;unfortunately cmd.exe gives us no controls with which to interact. very crude, this.
;;uses the windows hotkeys
Do
   If ProcessExists("cmd.exe") Then
      $a = WinGetTitle(@SystemDir & "\cmd.exe")
      WinActivate($a)
      WinWaitActive($a)
      Send("!{SPACE}ES{ENTER}")

      $b = ClipGet()
      MsgBox(1, "", $b)
   EndIf
   Sleep(1000)
Until 1 = 0

Why use all those keystrokes when you don't have to? E is for the Edit section, and the S is for the Select All

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0