sbp Posted October 8, 2005 Posted October 8, 2005 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
bluebearr Posted October 8, 2005 Posted October 8, 2005 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.
LxP Posted October 9, 2005 Posted October 9, 2005 The larger you set the delay in your idling loop, the less CPU usage: While 1 Sleep(0x7FFFFFFF) WEnd
Valuater Posted October 9, 2005 Posted October 9, 2005 (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 October 9, 2005 by Valuater
LxP Posted October 9, 2005 Posted October 9, 2005 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!).
sbp Posted October 9, 2005 Author Posted October 9, 2005 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
BigDod Posted October 9, 2005 Posted October 9, 2005 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 1Sleep(100)WEndThank you SteenAs Bluebear said without the loop to keep your script active it just closes without waiting for any input. 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now