Jump to content

functions with parameters in OnEvent and HotKeys


martin
 Share

Recommended Posts

Hi all

Thanks for this function, I use It, nad i like it.

I made a little change, i remark that the GUI_Event... are negative value

And now it's possible to use you're fonction with GUI_Event !!!

If IsString($iCtrl) Then ; it's a hotkey
        HotKeySet($iCtrl, "HK_EventFunc")
        $CtrlLib[$item][0][0] = $OE_HOTKEY
    ElseIf $iCtrl <= -3 And $iCtrl >= -13 Then    ;; <<<< Here my change
        If Opt("GUIOnEventMode") = 0 Then
            Return -3 ; not using event mode
        EndIf
        $CtrlLib[$item][0][0] = $OE_CONTROL
        GUISetOnEvent($iCtrl, "EventFunc")
    Else
        If Opt("GUIOnEventMode") = 0 Then
            Return -3 ; not using event mode
        EndIf
        $CtrlLib[$item][0][0] = $OE_CONTROL
        GUICtrlSetOnEvent($iCtrl, "EventFunc") ; all controls call this function
    EndIf

Thx

Link to comment
Share on other sites

Hi all

Thanks for this function, I use It, nad i like it.

I made a little change, i remark that the GUI_Event... are negative value

And now it's possible to use you're fonction with GUI_Event !!!

If IsString($iCtrl) Then ; it's a hotkey
        HotKeySet($iCtrl, "HK_EventFunc")
        $CtrlLib[$item][0][0] = $OE_HOTKEY
    ElseIf $iCtrl <= -3 And $iCtrl >= -13 Then    ;; <<<< Here my change
        If Opt("GUIOnEventMode") = 0 Then
            Return -3 ; not using event mode
        EndIf
        $CtrlLib[$item][0][0] = $OE_CONTROL
        GUISetOnEvent($iCtrl, "EventFunc")
    Else
        If Opt("GUIOnEventMode") = 0 Then
            Return -3 ; not using event mode
        EndIf
        $CtrlLib[$item][0][0] = $OE_CONTROL
        GUICtrlSetOnEvent($iCtrl, "EventFunc") ; all controls call this function
    EndIf

Thx

Thanks for the input GaRydelaMer, and I'm glad you like the script.

It was a bit of an omission that I didn't include gui events. Someone else made an event udf to be able to use parameters which looked quite clever using a dictionary but I've forgotten who now, but I did notice that their udf did include Gui events. I'll give some thought to what you've done and add something to the udf. It doesn't need much of a change does it?

I think I would prefer this construction though.

If IsString($iCtrl) Then; it's a hotkey
     HotKeySet($iCtrl, "HK_EventFunc")
     $CtrlLib[$item][0][0] = $OE_HOTKEY
 Else
     If Opt("GUIOnEventMode") = 0 Then Return -3; not using event mode
 
     If $iCtrl < -2 And $iCtrl > -14 Then;;;; <<<< Gui events added by GaRydelaMer
         GUISetOnEvent($iCtrl, "EventFunc");;;all Gui events call this function..
         $CtrlLib[$item][0][0] = $OE_GUI; new constant which might or might not be useful
     Else
         GUICtrlSetOnEvent($iCtrl, "EventFunc");.. and all control events call this function
         $CtrlLib[$item][0][0] = $OE_CONTROL
     EndIf
 
 EndIf

I might need to think about how to use @GUI_WinHandle as well.

EDIT: It's not quite so simple. The change suggested by itself won't work, and there's the optional winhandle in the GuiOnEvent function, and the macros @GUI_DRAGID, @GUI_DRAGFILE and @GUI_DROPID which might be required.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

New version with Gui events now avaliable in the download. (V10)

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin

Good Job ! I was waiting for that event :)

Cheers, FireFox.

Whoops, GaRydelaMer pointed out there was a bug in Version 10 so that the udf wasn't working for HotKeys. Updated to Version 11 which corrects it, and updated the example which called the wrong function for a hotkey.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 4 months later...

i can't seem to get it to work right, only the first event set will run, non of the other events set

You need to post some code which shows the problem. I am not aware of any problems with the udf but if there is a bug I would like to know.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

very cool! nice job martin :D , btw i thought it would be cool if you could use a function as a param :D so i modified the udf a bit ;)

you can use $paramfunc , "funcname" and it will call the func as a param ;) .

P.S: maybee use a func with params ?( i haven't done that :P )

onEventFunc.au3

OnEventFuncExample.au3

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

very cool! nice job martin :D , btw i thought it would be cool if you could use a function as a param ;) so i modified the udf a bit :P

you can use $paramfunc , "funcname" and it will call the func as a param :D .

P.S: maybee use a func with params ?( i haven't done that ;) )

Thanks Xand3r.

Your change to add a function as a param looks fine.

For my own UDF I would prefer that if you want a function to be called with a parameter which is itself the result of function call that you handle that in the primary function depending on a parameter. That way my UDF is kept simpler and the extra feature you want, and which I think is unusual, can be handled by the user's own script.

You could have parameters with your function by passing a string made up of sections with a separator as one of the parameters to the SetOnEvent function. The first part could be the function name, the others could be the parameters. But this is beyond the scope of my current interests :D .

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 8 months later...

New version with TraySetOnEventA fiunction added for Tray menu items after push from FireFox.

see first post.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 months later...

This appears to be a nice script. But oddly I'm not being able to download the file on the first post. When I download it I only get a file with 21 bytes. The file is around 6kb so attaching it with the post should not be problemous. Can anyone do that?

[Not using this account any more. Using "iShafayet" instead]

Link to comment
Share on other sites

This appears to be a nice script. But oddly I'm not being able to download the file on the first post. When I download it I only get a file with 21 bytes. The file is around 6kb so attaching it with the post should not be problemous. Can anyone do that?

There might be something I need to tweek on the website but no time now so I'll attach to this post for a while.

onEventFunc.zip

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 6 months later...

the ability to send params with hotkeys and buttons is usefull for me to reduce the need of variables and code. for me this udf does not help to simplify and reduce my code.

I am sorry that it doesn't simplify or reduce your code; but of course it depends what your code is to start with and what you need to do. The UDF was developed for someone who needed to dynamically create a lot of menus, buttons and icons and for that application this udf helped to simplify the code a lot and I think that scenario is where the udf has the most benefit.

Maybe there is some feature of the udf which is a shortcoming from your experience, and if you tell me what it is or give me an example then I might be able to make some suggestions or improvements.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...

Thank you for this, saved me a lot of time.

Small observation: you didn't declare $iParCount in SetOnEventA which leads to an error when the main script has Opt("MustDeclareVars", 1). Don't know if there are any implications but i thought i'd mention it.

Edit: it might have consequences, my compiled script was giving out "variable used before being declared" on some machines, and fixing that in the UDF seemed to fix that problem (it was either that or my sloppy "declare everything as global until you can pinpoint the problem" technique).

Edited by ovideo
Link to comment
Share on other sites

ovideo,

thanks for telling about that, it is certainly a mistake. I try to test my udf's with "mustdecalrevars" so I must have not done that.

Now fixed.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 1 month later...

marting i used your UDF on one of my projects, it's great and made my whole script more simple but i have 1 little problem.

For more security against leechers i'm always use #Obfuscator_Parameters=/SF /SV /CV=1 /CF=1 /CS=1 /CN=1 /OM /Beta, you used Call() on your UDF so i have some problem when i want compile my script.

I know it's possible to ignore some function with #Obfuscator_Ignore_Funcs but i can't figure out which function i should add to this parameter.

Log:

-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.
>### current Func: _pp_Timer
C:UsersD4RK.ON3DesktopGoDLiKe.eXp UltimateIncludes_Pop-ups.au3(451,1) Warning for line:Call($ppData[$i][7])
-### StripOnly/StripFunc Error: Found Call() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.
>### current Func: BuildFnCall
C:UsersD4RK.ON3DesktopGoDLiKe.eXp UltimateIncludes_OnEvent.au3(307,1) Warning for line:Call($CtrlLib[$index][1][1], $Arrayset)
-#############################################################################################
-#### Obfuscator Found   2 Error(s)!!!!    This means your script could have problems running properly.  ####
-#############################################################################################
- Iteration 1 Strip Functions result: Output  4782 lines and stripped 5408 lines
- Iteration 2 Strip Variables result: Output  2939 lines and stripped 1789 lines
- Iteration 3 Strip Variables result: Output  2919 lines and stripped 20 lines
- Iteration 4 Start the actual Obfuscation.
-### StripOnly/StripFunc Error: Found Eval() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.
>### current Func: SetOnEventAT
C:UsersD4RK.ON3AppDataLocalTempOBs5844.tmp(561,1) Warning for line:$CtrlLib[$item][0][$n + 2] = Eval("ParType" & $n)
-### StripOnly/StripFunc Error: Found Eval() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.
>### current Func: SetOnEventAT
C:UsersD4RK.ON3AppDataLocalTempOBs5844.tmp(563,1) Warning for line:$CtrlLib[$item][1][$n + 2] = Eval("Par" & $n)
-### StripOnly/StripFunc Error: Found Eval() statement using unsolvable Func, which will/could lead to removal of Funcs that are used by the Call() statement.
>### current Func: SetOnEventAT
C:UsersD4RK.ON3AppDataLocalTempOBs5844.tmp(565,1) Warning for line:$aval = Eval("Par" & $n)
-#############################################################################################
-#### Obfuscator Found   3 Error(s)!!!!    This means your script could have problems running properly.  ####
-#############################################################################################
+> Source    27003 lines 1455205 Characters.
+> Stripped  7217 Func/Var lines and  16802 comment lines, Total 1332974 Characters.
+> Saved     88% lines 91% Characters.
+> Obfuscator v1.0.29.0 finished obfuscating 3437 lines, created:C:UsersD4RK.ON3DesktopGoDLiKe.eXp UltimateGoDLiKe.eXp Ultimate_Obfuscated.au3

Thanks for your help.

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