Sign in to follow this  
Followers 0
sbp

newbee question hotkeyset?

7 posts in this topic

Hi, I have been using many hours trying to make a very simple script, but now I give up - and ask for a little help

I would like to start my script by pressing a key. Then the script should do some more keypress. But I can't get my script to start when I press the hotkey I have defined.

Here is my script.

HotKeySet("{Pause}", "test")

Func test()

Run("notepad.exe")

WinWaitActive("Unavngivet - Notesblok")

Send("This is some text.")

EndFunc

So for now I would like to press the Pause key, and then the script should start.

Thanks

Steen

Share this post


Link to post
Share on other sites



The problem is that the script finishes and quits immediately.

Try this instead:

HotKeySet("{Pause}", "test")

while 1
  Sleep(100)
WEnd

Func test()
  Run("notepad.exe")
  WinWaitActive("Untitled - Notepad") 
  Send("This is some text.")
EndFunc

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

The larger you set the delay in your idling loop, the less CPU usage:

While 1
    Sleep(0x7FFFFFFF)
WEnd

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I use tetimers as testing tools

Dim $Sleeper = 500

While 1

Sleep($Sleeper)

Wend

haven't seen this one before

Sleep(0x7FFFFFFF)

????

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
0x7FFFFFFF is basically the largest positive value that can be stored in AutoIt's numeric data type. I use hex notation because it's easier to remember than 2,147,483,647 (at least for me!).

Share this post


Link to post
Share on other sites

Thank you for helping me out. This seems like a very friendly and helpsom community.

I used Bluebearr's suggestion - and eveything is fine. However, I don't quite get the logic - why should I need this:

while 1

Sleep(100)

WEnd

Thank you

Steen

Share this post


Link to post
Share on other sites

Thank you for helping me out. This seems like a very friendly and helpsom community.

I used Bluebearr's suggestion - and eveything is fine. However, I don't quite get the logic - why should I need this:

while 1

Sleep(100)

WEnd

Thank you

Steen

As Bluebear said without the loop to keep your script active it just closes without waiting for any input.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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