Jump to content
Sign in to follow this  
badcoder123

How does AdlibRegister exactly work?

Recommended Posts

badcoder123

Hey everyone,

I've been messing around with some new things and adlibs look extremely useful/interesting, however, I can't seem to get it to work.. Here's what I have

HotKeySet("{F1}", "_Exit")

$qCount = 1
Global $_Timer
AdlibRegister($_Timer, 1000)
AdlibUnRegister($_Timer)

While 1
  SoundPlay(@WindowsDir & "\media\tada.wav", 1)
  $qCount += 1
  ToolTip('"Tada" has been played ' & $qCount & " times",200,200)
WEnd

Func _Timer()
   Local Static $iCount += 1
   ConsoleWrite($iCount)
   If $iCount = 20 Then ConsoleWrite("iCount is at " & $iCount)
EndFunc

Func _Exit()
   Exit
EndFunc

Basically I want it to call the _Timer function but it doesn't seem to work :/ any ideas?

Share this post


Link to post
Share on other sites
badcoder123
49 minutes ago, Danp2 said:

Move this line to after the While loop or within your _Exit function --

AdlibUnRegister($_Timer)

Hey Danp2,

Thanks for the reply. I've modified the code to...

HotKeySet("{F1}", "_Exit")

$qCount = 1
Global $_Timer
AdlibRegister($_Timer, 1000)

While 1
   SoundPlay(@WindowsDir & "\media\tada.wav", 1)
   $qCount += 1
   ToolTip('"Tada" has been played ' & $qCount & " times",200,200)
WEnd



Func _Timer()
   Local Static $iCount += 1
   ConsoleWrite($iCount)
   If $iCount = 20 Then ConsoleWrite("iCount is at " & $iCount)
EndFunc

Func _Exit()
   ToolTip("")
   AdlibUnRegister($_Timer)
   Sleep(2000)
   Exit
EndFunc

I'm not sure if this is what you meant but this still does not work.

Share this post


Link to post
Share on other sites
kylomas

Badcoder123,

Register the function. Not the variable.

Kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
badcoder123
25 minutes ago, kylomas said:

Badcoder123,

Register the function. Not the variable.

Kylomas

omg... Thanks haha :)

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  

  • Similar Content

    • chacoya121
      By chacoya121
      can someone plz explain how WinAPI work and some example script plz
    • Bilgus
      By Bilgus
      Apparently you can't use a function with variables for AdlibRegister
      Like you declare it with a variable even an optional one and it throws an error if you try and call it
      Thats ok though I figured out a hack using eval to get a better result
      Registered_Funct(250);Register Sleep(10000) Registered_Funct(-1);UnRegister Func Registered_Funct($iTime = -1) Local $i_Time = Eval("iTime") If $i_Time > 0 Then AdlibRegister("Registered_Funct", $i_Time) ElseIf $i_Time < 0 Then AdlibUnRegister("Registered_Funct") Else ConsoleWrite("Do Stuff") EndIf EndFunc
      Surely it has an impact on efficiency though...
    • watchoverme
      By watchoverme
      hi all, how can i move mouse to the place where pixel changes
       
      While Sleep (3000)
      $pix = PixelChecksum(0,0,55,55)
      If IsArray($pix) = True Then
      MouseMove($pix [0],$pix[1])
      EndIf
      WEnd
    • Ignacio
      By Ignacio
      Hello, and good day
      Im trying to make a sentence autocompleter so that when you type certain words (or commands) the scripts, and im in need of help/pointers
      That is what i have at the time and the issues i have currently is that:
      - I cant find an easy way to reset the counter to 0 in case a different letter from those are pressed ( tried NOT _ispressed but i think i got it wrong)
      -Is there another way to detect the key press that _ispressed? (i couldnt find it so far), since i feel like it is too clunky ( although maybe that is just me and my way to code)
      - for some reason the hex code (6F) for the / (divide nume pad) isnt working for me
       
      Im thinking of making a text file with some words to use them as variables/comparations  (so that at least removes the need of a variable for the words in the script) and make the script make a temporal text file to save the input and then compare it with the other one. But i dont know if that is a good approach.
      Thanks for your time and patience.
    • Miliardsto
      By Miliardsto
      Is there any difference in timers and AdlibRegister ?
      in :
      performance usage reliability or any kind of difference I want use few timers at once so it will make difference.
      I have problem with timers and I saw AdlibRegister behaves similar like:
      wont stop crashing slowing program so much maybe is there any trick to make it better?
×

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.