Jump to content

Keeping The Script Open


Recommended Posts

My script is just a lot of Hotkeys and Functions for the things i repeat throughout the day.

The problem is there is really nothing to "run"; ideally, it would just stay open all day untill i use one of the hotkeys. Im not sure what to put in it to make it run all day.

I tried a:

While 1
    If 1 Then ContinueLoop
WEnd

which seemed to work somewhat, but half the hotkeys didn't work and after using 3-4 AutoIt would crash.

How can I just keep it open all the time? I would hope to be able to run it atleast 6-8 hours through my entire day.

thx

Link to comment
Share on other sites

My script is just a lot of Hotkeys and Functions for the things i repeat throughout the day.

The problem is there is really nothing to "run"; ideally, it would just stay open all day untill i use one of the hotkeys. Im not sure what to put in it to make it run all day.

I tried a:

While 1
    If 1 Then ContinueLoop
WEnd

which seemed to work somewhat, but half the hotkeys didn't work and after using 3-4 AutoIt would crash.

How can I just keep it open all the time? I would hope to be able to run it atleast 6-8 hours through my entire day.

thx

try

While 1
   Sleep ( 200 )
Wend

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I assume that a 200ms delay would be put on every action? Could I just snip it down to <100ms? Or would that cause some slowdown

You'll have to play with it, I usually use 100, keeps the cpu usage from being consumed.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

I assume that a 200ms delay would be put on every action? Could I just snip it down to <100ms? Or would that cause some slowdown

To would cause you to have a max of a 200ms delay before it ran the function linked to your hotkey. If 200ms is to long of a delay for you then lower the number, but be sure to test it by watching your cpu usage.
Link to comment
Share on other sites

To would cause you to have a max of a 200ms delay before it ran the function linked to your hotkey. If 200ms is to long of a delay for you then lower the number, but be sure to test it by watching your cpu usage.

I think that this is not the case. Have you tested it with some code and a very long sleep?Edit1:
HotKeySet("+!d", "ShowMessage");Shift-Alt-d

While 1
    Sleep(10000000000)
WEnd

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc ;==>ShowMessage

Edit2:From this thread: http://www.autoitscript.com/forum/index.ph...ndpost&p=160319

Interesting find: the order of execution goes hotkey, sleep, adlib, guievent, .... That's why you can press a hotkey and it will interrupt a sleep. NICE.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I stand corrected, ...

Please, have a seat.... :-)

Did not mean for it is come across too harshly - I was posting between real work.

Anyway, this is another post that I was looking for:

http://www.autoitscript.com/forum/index.ph...ndpost&p=117534

that talks of large sleep values for idle loops...

Rather than add that link in as yet another edit to my other post, I'll add it to this - my "apology post".

Edit1: Sample of LxP's code with a long sleep:

http://www.autoitscript.com/forum/index.ph...ndpost&p=135749

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I have a script that may help give you a direction. In my program, I have case statements that will go hot only when a window is active:

;<:::Keys for Request Detail:::>
   case WinActive("Request Detail - Unicenter ServicePlus Service Desk") 
        _win1_func() 
    continueloop
           
;<:::Keys for Incident Detail:::>
   Case WinActive("Incident Detail - Unicenter ServicePlus Service Desk")
        _win2_func()
    continueloop
   
;<:::Keys for Problem Detail:::>
   Case WinActive("Problem Detail - Unicenter ServicePlus Service Desk")
    _win3_func()
    continueloop

when a window is active, such as "Request Detail", It will run _win1_func():

Func _win1_func()
    HotKeySet("{F1}", "_F1A_Func");turns key on for help
    HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket
    HotKeySet("{PRINTSCREEN}", "_key2a_Func"); Print ticket
      Do
        Sleep(10)
    Until Not WinActive("Request Detail - Unicenter ServicePlus Service Desk")
    _key_clean_1();resets keys back to default

EndFunc

This program has over 1000 lines of code, and works with 28 different windows, turning on or off hotsetkeys when needed. If you need the entire script to get how this works, let me know. Hope this helps.

Link to comment
Share on other sites

I stand corrected, I always thought it waited until the next loop to execute the function.

It only matters if you are doing other things in the loop, then there would be a wait between each time that is done for example

HotKeySet("+!d", "ShowMessage");Shift-Alt-d

While 1
    Sleep(5000)
    ConsoleWrite("Still In Loop" & @LF)
WEnd

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc;==>ShowMessage

The consolewrite would be done every 5 seconds

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

My problem is also having to manually go back and forth and edit values. I just recently found a month ago that a couple managers actually used AutoIt on their boxes for shifts. To press a single button and go directly back to what I need to edit will save me about 10 seconds per edit, which at the end of the day should be about 2 hours lol

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