Jump to content

help with beginner script


Recommended Posts

Hi everyone,

I'm experimenting with writing a new script and was hoping to get some direction.

What I am trying to achieve is the following:

0. Script activates/deactivates script when user toggles it with CTRL+SHIFT+T

1. Every 10 minutes, switch to a window named "notepad.txt"

2. While the window is being switched over, I want to lock out all keyboard and mouse inputs, so user does not inadvertently interfere with the next step (I'm not sure if this feature is available to AutoIt.)

3. Enter some text, let's say "hello world"

4. Switch back to the last window that was in focus before Step 1 happened.

5. Unlock keyboard/mouse inputs

6. Repeat in a loop infinitely back to Step 1 until user hits CTRL+SHIFT+T

2. Alternatively, if keyboard/mouse input lockout (Step 2) is not available, perhaps display an alert box and play a sound file named "c:\ding.wav" until Step 4. The alert box will say "Please do not enter any inputs. Script is active."

Thanks so much for your help. I know a little bit of Javascript programming but am completely new to syntax regarding Windows.

Link to comment
Share on other sites

Hi everyone,

I'm experimenting with writing a new script and was hoping to get some direction.

What I am trying to achieve is the following:

0. Script activates/deactivates script when user toggles it with CTRL+SHIFT+T

1. Every 10 minutes, switch to a window named "notepad.txt"

2. While the window is being switched over, I want to lock out all keyboard and mouse inputs, so user does not inadvertently interfere with the next step (I'm not sure if this feature is available to AutoIt.)

3. Enter some text, let's say "hello world"

4. Switch back to the last window that was in focus before Step 1 happened.

5. Unlock keyboard/mouse inputs

6. Repeat in a loop infinitely back to Step 1 until user hits CTRL+SHIFT+T

2. Alternatively, if keyboard/mouse input lockout (Step 2) is not available, perhaps display an alert box and play a sound file named "c:\ding.wav" until Step 4. The alert box will say "Please do not enter any inputs. Script is active."

Thanks so much for your help. I know a little bit of Javascript programming but am completely new to syntax regarding Windows.

Hi, and welcome!

For activating/deactivating you can use HotkeySet("^!t","myfunction") to set it to ctrl+shit+t. See help for (way) more info. Then make a Func myfunction() that sets a boolean variable to the opposite ($var = NOT $var). Then have your main loop, only doing the stuff when $var is true.

For sending strings to a notepad window, you COULD open it, block user input, sound waves, etc. but what would be way easier is to just use something like ControlSend("Untitled - Notepad","",15,"this is a test string" to send the text to the notepad window. You can send strings even to a minimized window, and do not need to open it etc..

But what is this string sending for? If it is for logging or something, wouldn't it be easier to write to a text file instead of notepad?

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

ControlSend("Untitled - Notepad","",15,"this is a test string")

WinWaitActive("Untitled - Notepad")

ControlSend("Untitled - Notepad","","Edit1","this is a test string")

have a look at the helpfile and search the forums...

Link to comment
Share on other sites

Thanks for the help so far everyone. You're definitely sending me in the right direction. I'm going to dig some more into the documentation and experiment a bit before coming back with more specific code I might need help with.

Link to comment
Share on other sites

WinWaitActive("Untitled - Notepad")

ControlSend("Untitled - Notepad","","Edit1","this is a test string")

have a look at the helpfile and search the forums...

Both will work. I tested my code with 15 too.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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...