Jump to content
Sign in to follow this  
neotrio

important point?

Recommended Posts

neotrio

hi all,

We all know that, for calling a UDF by clicking a control we should use GUICtrlSetOnEvent()

Also,

OnEvent functions are called when the option GUIOnEventMode is 1.and when in this mode GUIGetMsg is not used at all.

what i am trying is calling a UDF by click of a button and returning the value from the function in to the edit control so that i can see the out put in the same GUI.

#include<GuiConstants.au3>


Dim $a ="fgdgd"
Dim $b = "hello"
Dim $c 
Dim $d 
Opt("GUIOnEventMode",1)
; GUI
GuiCreate(" Automation Tool", 500, 611)

; ICON
GuiCtrlCreateIcon("shell32.dll", 1, 5, 130)
;GuiCtrlCreateLabel("Icon", 230, 10, 50, 20)

; DATE
GuiCtrlCreateDate("", 318, 10, 185, 20)
GuiCtrlCreateLabel("(Date control expands into a calendar)", 318, 35, 200, 20)

; BUTTON
 $button1 = GuiCtrlCreateButton("Get software version", 130, 430, 120, 30)

GuiCtrlCreateButton("Test ", 250, 430, 100, 30)
GuiCtrlCreateButton("Save", 420, 370, 50, 30)

;GUI Event
GUICtrlSetOnEvent($button1,"Gui")

Func Gui()
GuiCtrlCreateEdit(@CRLF & $b, 60, 130, 350, 270)
EndFunc

; GUI MESSAGE LOOP
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

how to achieve what i am trying to do?

any help will be appreciated.

Share this post


Link to post
Share on other sites
SmOke_N

We "all" don't know that is the way to call a function :) come to think of it, I use GUIGetMsg() 85% of the time (was 99% until recently). The way to get around your situation is making variables global, if your stuck to OnEvenMode.


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.

Share this post


Link to post
Share on other sites
MHz

We all know not to use GUIOnEventMode with GuiGetMsg(), or perhaps we do not. :)

Share this post


Link to post
Share on other sites
neotrio

We all know not to use GUIOnEventMode with GuiGetMsg(), or perhaps we do not. :)

yeah .........but how to accomplishe what i am trying?

Share this post


Link to post
Share on other sites
SmOke_N

yeah .........but how to accomplishe what i am trying?

Re-write it to utilize GUIGetMsg()?

Edit:

We all know not to use GUIOnEventMode with GuiGetMsg(), or perhaps we do not. :)

I will assume that was a jest at me... rather than the poster. We all know you shouldn't, but do we all know you can... Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites
MHz

I will assume that was a jest at me... rather than the poster.

Not directed at you SmOke.

I was following the theme of the topic starter and directed my reply to the topic starter.

:)

Share this post


Link to post
Share on other sites
SmOke_N

Not directed at you SmOke.

I was following the theme of the topic starter and directed my reply to the topic starter.

:P

Dammit, I just spent 3 minutes making this to prove the point!! :)

Opt('GUIONEVENTMODE', 1)
$Main = GUICreate('SOMEGUI', 200, 100)
$BUTT = GUICtrlCreateButton('SWITCH TO GUIGETMSG()', 25, 35, 150, 30)
GUISetOnEvent(-3, '_EXIT')
GUICtrlSetOnEvent($BUTT, '_EVENTS')
GUISetState()
While 1
    Sleep(10000)
WEnd
Func _EVENTS()
    Switch @GUI_CtrlId
        Case $BUTT
            _GUIGETMSG()
    EndSwitch
EndFunc
Func _GUIGETMSG()
    $OPTGOEM = Opt('GUIONEVENTMODE', 0)
    $CHILD = GUICreate('GETMSG GUI', 200, 100)
    $CBUTT = GUICtrlCreateButton('SWITCH TO ONEVENMODE', 25, 35, 150, 30)
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case -3, $CBUTT
                GUIDelete($CHILD)
                Opt('GUIONEVENTMODE', $OPTGOEM)
                Return 1
        EndSwitch
    WEnd
EndFunc
Func _EXIT()
    Exit
EndFunc

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.

Share this post


Link to post
Share on other sites
MHz

Dammit, I just spent 3 minutes making this to prove the point!! :)

Nice alternating message mode script. I do not see much point of normal use, but nice anyway.

Perhaps I should have been more clear to all with my 1st post to save misunderstanding in stating that not possible to have both message modes at the exact same time. :P

If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1.

Share this post


Link to post
Share on other sites
SmOke_N

Nice alternating message mode script. I do not see much point of normal use, but nice anyway.

Perhaps I should have been more clear to all with my 1st post to save misunderstanding in stating that not possible to have both message modes at the exact same time. :)

You never need to explain yourself, especially to me.. I'll admit that I was confused on you're post, but I agree, although I'd never (well to yet anyway) use an example like I posted, it would be useful for those that felt it necessary to have the control of OnEventMode and the flexibilty of GUIGetMsg().

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.

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  

×

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.