Sign in to follow this  
Followers 0
Klaatu

Find name of current Adlib function

4 posts in this topic

Is there any way to find out the name of the current Adlib function? I'd like to save the name of the currently set Adlib function in a variable, change it to another temporarily, then set it back at the end. You know, similar to the way AutoItSetOption returns the current value of an option so you can set it back when you're done?

I did a lot of looking through the help file, but couldn't find anything that might answer the question.


My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!

Share this post


Link to post
Share on other sites



This is ugly, but might do the trick for you... I didn't comment it as I think it's fairly straight forward:

Global $aTrackAdlib[5] = ['', 0, 0, 0, 0]
Global $aAdlibFuncs[5] = ['', '_Turtle', '_Monkey', '_SeaBass', '_GoonyGooGoo']
AdlibEnable($aAdlibFuncs[Random(1, 4, 1)], 1000)
While 1
    Sleep(1000)
    $nCC = _TrackAdlib()
    ToolTip('The current function you are on: ' & $aAdlibFuncs[$nCC], 0, 0)
    AdlibDisable()
    AdlibEnable($aAdlibFuncs[Random(1, 4, 1)], 1000)
WEnd

Func _Turtle()
    _SetFuncCall(1)
    ConsoleWrite(@LF & 'In Turtle' & @LF)
    Return ''
EndFunc
Func _Monkey()
    _SetFuncCall(2)
    ConsoleWrite(@LF & 'In Monkey' & @LF)
    Return ''
EndFunc
Func _SeaBass()
    _SetFuncCall(3)
    ConsoleWrite(@LF & 'In SeaBass' & @LF)
    Return ''
EndFunc
Func _GoonyGooGoo()
    _SetFuncCall(4)
    ConsoleWrite(@LF & 'In GoonyGooGoo' & @LF)
    Return ''
EndFunc
Func _SetFuncCall($nNum)
    For $iCC = 1 To UBound($aTrackAdlib) - 1
        If $iCC = $nNum Then
            $aTrackAdlib[$iCC] = 1
        Else
            $aTrackAdlib[$iCC] = 0
        EndIf
    Next
    Return SetError(0, 0, 1)
EndFunc
Func _TrackAdlib()
    For $iCC = 1 To UBound($aTrackAdlib) - 1
        If $aTrackAdlib[$iCC] Then Return $iCC
    Next
    Return SetError(1, 0, 0)
EndFunc
The main focuses should be _TrackAdlib/_SetFuncCall/Global $aTrackAdlib[5]/$aAdlibFuncs[5]


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This is ugly, but might do the trick for you... I didn't comment it as I think it's fairly straight forward

Boy, sorry you went through all that for nothing. I'm writing a debugger and have no control (well, at least not that kind of control) over the script I'm debugging. I'm attempting to implement a better pause function (as the one I've got now pauses the main script but not any adlib going), so would like to save the name of whatever function they've set as the current Adlib function, disable adlibbing while paused, then start their AdLib function again. Ideally, I'd also be able to save the interval they've set as well so that can be restored also.

Sorry I didn't say all that the first time, but thought my question fairly straightforward as well; guess I was wrong.


My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Boy, sorry you went through all that for nothing. I'm writing a debugger and have no control (well, at least not that kind of control) over the script I'm debugging. I'm attempting to implement a better pause function (as the one I've got now pauses the main script but not any adlib going), so would like to save the name of whatever function they've set as the current Adlib function, disable adlibbing while paused, then start their AdLib function again. Ideally, I'd also be able to save the interval they've set as well so that can be restored also.

Sorry I didn't say all that the first time, but thought my question fairly straightforward as well; guess I was wrong.

And why wouldn't this work? I didn't intend for you to use the function exactly as I had put it, but yes, you'd have to know what function you are in, or you'd be SOL.

Edit:

I looked at you debugger... Nice work. I thought about making one once. I think for what I had in mind on how I would do a debugger myself, the idea that I presented would have worked well. However, I can see your reservations on it for yours.

Edit2:

I don't know how AdlibDisable works (too lazy to look it up in the source code I guess), but I'm curious if it could actually return the last function it had just disabled. That would in fact give the effect as $Opt = Opt(whatever, 1) / Opt(whatever, $Opt).

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0