Jump to content
Sign in to follow this  
Bookman

Script Becomes Unstable, Won't Close

Recommended Posts

Bookman

I'm running the following script to create hotkeys that control functions of a database. I have 2 problems. The first is that I can't get the script to exit when the DB closes. It remains running, and if I restart the DB, another copy of same script starts, leaving two copies running, more if I restart again. The second is that the script apparently becomes unstable after about 20 minutes of sitting idle. After the idle period, the computer acts as if the shift key is being held down. The CapsLock has no effect and the warm restart of windows doesn't work. The only solution is to shut down windows entirely, and re-start the computer after a minute or so. This solves the problem until another idle period.

P4 1Gb, memory plenty of available resources, Win XP pro SP2.

Runing the AutoIT 3 Beta version, script compiled under this version also.

Global Const $DB='Elsevier PSG*'

;Wait for the DB software to close

WinWaitClose($DB)

;Define the hot key set

HotkeySet("{F5}", 'Search')

HotkeySet("{F9}", 'Card')

WinWait ($DB)

Func Search()

Local $Input = InputBox('Scanning the EAN', 'Book:')

If @Error Then Return

WinActivate($DB)

Send("^s")

Sleep(300)

Send($Input, 1)

Send("{ENTER}", 0)

EndFunc

Func Card()

WinActivate($DB)

Send("^h")

EndFunc

Share this post


Link to post
Share on other sites
Valuater

maybe this

$DB='Elsevier PSG*'

;Define the hot key set
HotkeySet("{F5}", 'Search')
HotkeySet("{F9}", 'Card')


While WinActive($DB)
; if this title ($DB) is not active.. the program will exit
    sleep(20)
WEnd

Func Search()
Local $Input = InputBox('Scanning the EAN', 'Book:')
If @Error Then Return
WinActivate($DB)
Send("^s")
Sleep(300)
Send($Input, 1)
Send("{ENTER}", 0)
EndFunc

Func Card()
WinActivate($DB)
Send("^h")
EndFunc

you could change it to

While WinExists($DB)

; that way it does not have to be the "active" window but must exist or the program will close

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Bookman

you could change it to

While WinExists($DB)

; that way it does not have to be the "active" window but must exist or the program will close

8)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.