Jump to content

loop until Ctrl+C


Recommended Posts

you can use the hotkeyset, create an infinite while loop (while 1 ... wend)

call the function you want when ctrl-c is pressed (due to the hotkeyset)

In the beginning there was nothing and then even that exploded - anonymous

Link to comment
Share on other sites

I didn't succeed to make it work. When I press Ctrl+C on the keyboard, the script will give this error:

% Invalid input detected at '^' marker.

and then will continue to loop

This is my code :

CODE

AutoItSetOption ( "WinTitleMatchMode" , 2)

#include <file.au3>

Dim $ipfile="IP.txt"

Dim $ipadress

HotKeySet('^C', "ExitProgram")

_FileReadToArray ($ipfile, $ipadress)

Run ("telnet " & $ipadress)

WinActivate("Telnet " & $ipadress)

WinWaitActive("Telnet " & $ipadress)

Send ("admin" & "{Enter}")

Send ("ena" & "{Enter}")

Send ("tmp_pwd" & "{Enter}")

While 1

Send ("show ip mobile binding summary" & "{Enter}")

WEnd

Func ExitProgram()

Exit (0)

EndFunc

Edited by mentosan
Link to comment
Share on other sites

  • 2 weeks later...

Can you tell us WHAT you are making?

If it is a script for key logging:

People would not be happy if you were trying to make a keylogger! :)

Easiest way I could think of:

CODE: AutoIt

===========

#include <misc.au3>

$dll = DllOpen("user32.dll")

Do

Sleep(10)

Until _IsPressed("11", $dll) And _IsPressed("43", $dll)

Keyloggers use that type of function (_isPressed) to record keys that were pressed

Do you know which code I shall use in the script to copy its output in a logfile?

Well this sounds like you are trying to make a keylogger output log file.

Link to comment
Share on other sites

I didn't succeed to make it work. When I press Ctrl+C on the keyboard, the script will give this error:

% Invalid input detected at '^' marker.

and then will continue to loop

This is my code :

CODE

AutoItSetOption ( "WinTitleMatchMode" , 2)

#include <file.au3>

Dim $ipfile="IP.txt"

Dim $ipadress

HotKeySet('^C', "ExitProgram")

_FileReadToArray ($ipfile, $ipadress)

Run ("telnet " & $ipadress)

WinActivate("Telnet " & $ipadress)

WinWaitActive("Telnet " & $ipadress)

Send ("admin" & "{Enter}")

Send ("ena" & "{Enter}")

Send ("tmp_pwd" & "{Enter}")

While 1

Send ("show ip mobile binding summary" & "{Enter}")

WEnd

Func ExitProgram()

Exit (0)

EndFunc

In the hotkeyset you wrote HotKeySet('^C', "ExitProgram") which will cause an error when you're using these: ' for the first parameter and these: " for the next.

Your script will work fine if you just write:

HotKeySet("^C", "ExitProgram") instead of

HotKeySet('^C', "ExitProgram")

Good Luck :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...