Jump to content

Parameters not set when called by HotKey or GUICtrlSetOnEvent


Recommended Posts

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.

Link to post
Share on other sites
  • Developers

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 ?

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

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
Link to post
Share on other sites
  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...