Jump to content

make the truth of "pressed some keys" longer in a local case


Recommended Posts

Hi,

I have a script like the following:

......(a little bit long)
While WinActive("B")
While NOT WinActive(" A")
                
  sleep(100)
                
  If ProcessExists("A.exe") = 0  Then
    ProcessClose("B.exe")
    Exit
EndIf                   
                
  If _isPressed( Hex(17), $dll) AND _isPressed( Hex(18), $dll) AND _isPressed( Hex(37), $dll) Then
    WinActivate("A")
    ExitLoop
  EndIf
WEnd
WEnd
...A little bit long.....

The above part is "to change WinB to WinA by a key press ctrl+alt+left"

When WinB is active and do nothing, then there is a 1% cpu (sometimes go back to 0% then back to 1%) used. Although this is not a problem, but I would like to know if there is a way to avoid this. Of course, one can use sleep(1000) instead. But in that case, when I press ctrl+alt+right, It doesn't activate WinA, since it doesn't detect the key is pressed. So one solution may be to make the fact "a key is pressed" longer, 1 second in the above example.

I am not sure if there is a big script that has a lot of parts similar to the above, and which has a heavy CPU usage. But since many programs use 0% cpu when they are idle, but they can respond immediately, so I am curious how can we do the same thing with autoit.

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