Sign in to follow this  
Followers 0
Wooltown

Parameters not set when called by HotKey or GUICtrlSetOnEvent

6 posts in this topic

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode 
HotKeySet("^s","Save")
HotKeySet("^t","TestSave1")
HotKeySet("^u","TestSave2")
While 1
    Sleep (1000)
Wend
Func Save($parameter = 0)
    msgbox(0,"Parameter",$parameter)
EndFunc
Func TestSave1()
    Save()
EndFunc
Func TestSave2()
    Save(2)
EndFunc

When I run this script and Pres Ctrl+S, I directly calls the Save function, and then AutoIT says "Error: Variable used without being declared.", but if it's called via TestSave1 or TestSave2 functions it work, is this a correct behaviour ??

The same behaviour is found when using GUiCtrlSetOnEvent.

Share this post


Link to post
Share on other sites



no errors here..

I would be helpful when more info is given... maybe a cut&paste of the SciTE outputpane so we can check the exact errors and running version ?

:)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I get the same error:

Error: Variable used without being declared

msgbox(0,"Parameter",$parameter)

msgbox(0,"Parameter",^ ERROR

edit - btw, running 3.2.2.0

Edited by xcal

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Opt("GUIOnEventMode", 1); Change to OnEvent mode 
HotKeySet("^s","Save")
HotKeySet("^t","TestSave1")
HotKeySet("^u","TestSave2")
While 1
    Sleep (1000)
Wend
Func Save($parameter = 0)
    msgbox(0,"Parameter",$parameter)
EndFunc
Func TestSave1()
    Save()
EndFunc
Func TestSave2()
    Save(2)
EndFunc

When I run this script and Pres Ctrl+S, I directly calls the Save function, and then AutoIT says "Error: Variable used without being declared.", but if it's called via TestSave1 or TestSave2 functions it work, is this a correct behaviour ??

The same behaviour is found when using GUiCtrlSetOnEvent.

Sorry forgot Win 2000 Sp4; AutoIT: 3.2.2.0

Output from SciTe

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "G:\Test system\Scripts\Development\Parm.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

>Running AU3Check (1.54.6.0) params: from:C:\Program Files\AutoIt3

+>AU3Check ended.rc:0

>Running:(3.2.2.0):C:\Program Files\AutoIt3\autoit3.exe "G:\Test system\Scripts\Development\Parm.au3"

G:\Test system\Scripts\Development\Parm.au3 (9) : ==> Variable used without being declared.:

msgbox(0,"Parameter",$parameter)

msgbox(0,"Parameter",^ ERROR

+>AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 6.816

Edited by Wooltown

Share this post


Link to post
Share on other sites

Ok, now I understand ...

This is a feature of AutoIt3.

The parameter fields are not initialised when called that way.

This was posted several times before ... eg http://www.autoitscript.com/forum/index.ph...otkey+parameter


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks for the answer, but I think it is a strange "feature", but it is easy to bypass the feature via another function call.

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