oozma Posted April 11, 2009 Posted April 11, 2009 (edited) Hi, I'm trying to use an Adlib in a Timerdiff fuction. See below. Global $set = 10000 Global $timer = TimerInit() Switch TimerDiff($timer) Case 1 To $set AdlibEnable ("run",100) EndSwitch This is calling the function 'run' every 100ms, but the problem is it never ends. Even after 10,000ms it keeps going and going Any way to stop this after 10 seconds and continue on with the rest of the script? Edited April 11, 2009 by oozma
Authenticity Posted April 11, 2009 Posted April 11, 2009 I think it should be as followed: AdlibEnable('Function', 100) Sleep(10000) AdlibDisabl3()
Moderators Melba23 Posted April 11, 2009 Moderators Posted April 11, 2009 oozma, Try this:; Start timer $iBegin = TimerInit() ; Enable Adlib AblibEnable("run", 100) ; Start loop which runs for 10 secs - during this loop function "run" is called every 100ms While TimerDiff($iBegin) < 10000 Sleep(100) ; Very important or you use 100% CPU WEnd ; Disable Adlib AdlibDisable() ; Continue with the script M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
oozma Posted April 11, 2009 Author Posted April 11, 2009 Unfortunately this didn't work, it still seems to loop the run function non-stop.
Authenticity Posted April 11, 2009 Posted April 11, 2009 Are you looping infinitely in the run Adlib function?
oozma Posted April 11, 2009 Author Posted April 11, 2009 This is the run function: Func run() Send("J") sleep(100) EndFunc I assumed that would only execute once every 100ms until 10 seconds was reached.(Used Melba's from above) Func type() Send("o") $iBegin = TimerInit() AdlibEnable("run", 100) While TimerDiff($iBegin) < 10000 Sleep(100) WEnd AdlibDisable() Send("C") EndFunc Func run() Send("J") sleep(100) EndFunc
Authenticity Posted April 11, 2009 Posted April 11, 2009 Remove the Sleep call within the Adlib function. Seems to me like a strange behavior: Dim $iCounter = 1 AdlibEnable('SomeFunc', 50) Sleep(500) ConsoleWrite('Sleep over!!!' & @LF) AdlibDisable() Func SomeFunc() ConsoleWrite('Data' & $iCounter & @LF) $iCounter += 1 Sleep(50) ConsoleWrite('Exiting Adlib' & $iCounter-1 & @LF) EndFunc So if you sleep more than or exactly the Adlib interval you're creating an infinite loop. ;]
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