Jump to content

Inconsistent Send Key


Recommended Posts

I tried to run the script/executable, for the send keys. it worked for the first run. Then after 3 seconds, I run again, it doesn't run the function. It needs to be wait a while, then the script will work again. I tried to processClose $process still can't produce consistent output.

 

$process = ProcessList(@ScriptName)
If ProcessExists($process) Then
    ProcessClose($process)
    RunKey()
Else
    RunKey()
EndIf


Func RunKey()   
    Sleep(250)
    Send("^!a")
    Exit 0
EndFunc

 

Link to comment
Share on other sites

  • Developers
4 hours ago, lakadigital said:
$process = ProcessList(@ScriptName)
If ProcessExists($process) Then
    ProcessClose($process)
    RunKey()
Else
    RunKey()
EndIf

What is this supposed to do?   the first line returns an Array when successful. So what about you start with explaining what it is you like to do exactly?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@lakadigital A more detailed description of what you want to achieve would be beneficial, e.g. by which application your "sendkey script" is called.

To avoid starting a script multiple times, you can also use  _Singleton. This allows only one running instance of the script at a time.

#include <Misc.au3> ; Info : to use _Singleton()

; Exit the script with the exit code -1 if another instance of the script already exists
_Singleton(@ScriptName, 0)

RunKey()

Func RunKey()
    Sleep(250)
    Send("^!a")
    Exit 0
EndFunc

(last but not least : please read the forum rules  )

Edit : @Jos Apologies, I had already sent my reply when I saw your request.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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