Jump to content

GUISetOnEvent problem


Recommended Posts

Hi gurus,

I have a problem with the following script.

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode",1) ; 0 = (default) disable. - 1 = enable

$gui_handle = GuiCreate("Silly Window Effect", 280, 60,200,100, BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "move_gui")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "move_gui")
GUISetOnEvent($GUI_EVENT_CLOSE, "close_gui")

        
$header_handle = GUICtrlCreateLabel("Some silly text",10,0,250)
GUICtrlSetFont($header_handle,9,600,0,"Arial Bold")
GuiSetState()

while 1
  sleep(250)
wend

func move_gui ()
   if @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN then msgbox(0,"","MOUSE DOWN")
   if @GUI_CTRLID = $GUI_EVENT_PRIMARYUP then msgbox(0,"","MOUSE UP")
endfunc 

func close_gui ()
   exit
endfunc

When I click into the window (not the text !!) then I will see two msgboxes. One for MOUSE_DOWN and one for MOUSE_UP.

HOWEVER, when I click into the text area, I get only one msgbox for MOUSE_UP. What happend to MOUSE_DOWN here?

Any idea what's wrong with my script?

EDIT: I tried the official release and the latest Beta (.54)

EDIT#2: The idea is to move the whole gui whith drag-n-drop, so I need to know when the mouse was clicked to save the mouse coordinates (MOUSE_DOWN) and to move the windows (MOUSE_UP).

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Must be a bug, not sure...

PS,

Don't tell anyone I told you it might be a bug, because it seems as I'm never right on these forums!

Thanks

Edited by layer
FootbaG
Link to comment
Share on other sites

I found it!!!

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode",1); 0 = (default) disable. - 1 = enable

$gui_handle = GuiCreate("Silly Window Effect", 280, 60,200,100, BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "move_gui")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "move_gui")
GUISetOnEvent($GUI_EVENT_CLOSE, "close_gui")

        
$header_handle = GUICtrlCreateLabel("Some silly text",10,0,250)
$header_button = GUICtrlCreateButton("Some silly btn",10,20,250)
GUICtrlSetFont($header_handle,9,600,0,"Arial Bold")
GuiSetState()

while 1
  sleep(250)
wend

func move_gui ()
   if @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN then msgbox(0,"","MOUSE DOWN")
   if @GUI_CTRLID = $GUI_EVENT_PRIMARYUP then msgbox(0,"","MOUSE UP")
endfunc 

func close_gui ()
   exit
endfunc

8)

NEWHeader1.png

Link to comment
Share on other sites

I found it!!!

What did you find? It is still the same on my system. When I click into the text field, I see only MOUSE_UP.

The only difference is the button you added, for which MOUSE_DOWN works. So I guess it could be a bug in conjunction with labels !?!

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

SOLVED! GUISetOnEvent can't return $GUI_EVENT_PRIMARYDOWN when I click a control, as there would be no way to return the control id then (GUICtrlSetOnEvent).

So, no bug. As usual: The problem sits in front of the monitor :)

Here is the code...

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode",1)  ; 0 = (default) disable. - 1 = enable

global $mouse_pos_start, $mouse_pos_curr, $gui_pos, $mouse_klicked

dim $control_handles[10]

for $counter = 0 to Ubound($control_handles)-1
    $control_handles[$counter] = -999999999
next


$gui_handle = GuiCreate("Silly Window Effect", 280, 60,200,100, BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST)

$gui_pos = WinGetPos($gui_handle)

GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "move_gui")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "move_gui")
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "move_gui")
GUISetOnEvent($GUI_EVENT_CLOSE, "close_gui")

           
        
$control_handles[0] = GUICtrlCreateLabel("Some silly text",10,0,250)
$control_handles[1] = GUICtrlCreateLabel("'nother silly text",10,20,250)

for $counter = 0 to Ubound($control_handles)-1
    GUICtrlSetFont($control_handles[$counter],9,600,0,"Arial Bold")
    GUICtrlSetOnEvent($control_handles[$counter], "move_gui")
next

GuiSetState()


while 1
  sleep(250)
wend

func move_gui ()
   local $control_handle_found = 0, $control_id_found = 0, $counter
   
   for $counter = 0 to Ubound($control_handles)-1
       if $control_handles[$counter] = @GUI_CTRLHANDLE then $control_handle_found = 1
       if $control_handles[$counter] = @GUI_CTRLID then $control_id_found = 1
   next

   if (@GUI_WINHANDLE = $gui_handle) OR ($control_handle_found = 1) then
     select
       case (@GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN) OR ($control_id_found = 1)
           $mouse_pos_start= MouseGetPos()
           $mouse_klicked = 1 
           
           
       case @GUI_CTRLID = $GUI_EVENT_PRIMARYUP
           $mouse_klicked = 0
           $mouse_pos_curr= MouseGetPos()
           $delta_x = $mouse_pos_curr[0] - $mouse_pos_start[0]
           $delta_y = $mouse_pos_curr[1] - $mouse_pos_start[1]
           WinMove($gui_handle,"", $gui_pos[0]+$delta_x, $gui_pos[1]+$delta_y)
           $gui_pos = WinGetPos($gui_handle)        
           
       case @GUI_CTRLID = $GUI_EVENT_MOUSEMOVE
           if $mouse_klicked = 1 then
              $mouse_pos_curr= MouseGetPos()
           $delta_x = $mouse_pos_curr[0] - $mouse_pos_start[0]
           $delta_y = $mouse_pos_curr[1] - $mouse_pos_start[1]
           WinMove($gui_handle,"", $gui_pos[0]+$delta_x, $gui_pos[1]+$delta_y)
        
           endif
     endselect
   endif       
endfunc 


func close_gui ()
   exit
endfunc

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

What happend to MOUSE_DOWN here?

The funny part is the button "Only" shows mouse down... and the label "Only" shows mouse up???

i do know that they both are accepted in "GUIGetMessage"

EDIT

Just caught your message while i was typing this

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Just caught your message while i was typing this

See my UDF for which I needed that stuff :)UDF: Animated Progress Bar

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

See my UDF for which I needed that stuff :)UDF: Animated Progress Bar

Cheers

Kurt

<{POST_SNAPBACK}>

Down-loaded the full version.... nothing happened????

am i supposed to enter info???

EDIT.... Just Noticed they are all functions...sorry

noticed this ( fyi)

$s_CloseFunc - Which function *mto* call when the GUI gets closed.

; Requirement(s): None

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Down-loaded the full version.... nothing happened????

am i supposed to enter info???

Well, I did only test this with the latest beta, so it might not work on your

system. If it worked you would see a green bar moving from left to right and

vice versa. See screenshot.

$s_CloseFunc  - Which function *mto* call when the GUI gets closed.

; Requirement(s):  None

I'll have a look.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

i now have ver ... v3.1.1.55 (beta)

example script gives this

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3(6,10) : ERROR: can't open include file <anislider.au3>

#include <anislider.au3>

~~~~~~~~~^

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3(13,86) : ERROR: _AniSliderCreateGui(): undefined function.

_AniSliderCreateGui("Animated Slider Demo", "Status line...", "_AniSliderTestExit")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3(25,103) : ERROR: _AniSliderSetProgressState(): undefined function.

_AniSliderSetProgressState("I'm in _AniSliderTestFunc1()... " & $i_Counter & " s")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~^

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3(44,19) : ERROR: _AniSliderExit(): undefined function.

_AniSliderExit()

~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3 - 4 error(s), 0 warning(s)

>Exit code: 0 Time: 3.932

full script give this

>"C:\Program Files\AutoIt3\SciTe\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "C:\Program Files\AutoIt3\Examples\My Stuff\slider-progress.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams

>Running AU3Check...C:\Program Files\AutoIt3\SciTe\Defs\Unstable\Au3Check\au3check.dat

>AU3Check Ended.

>Running: (3.1.1.55):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Program Files\AutoIt3\Examples\My Stuff\slider-progress.au3"

>AutoIT3.exe ended.

>Exit code: 0 Time: 0.985

?????

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

C:\Program Files\AutoIt3\Examples\My Stuff\slider-prog-2.au3(6,10) : ERROR: can't open include file <anislider.au3>

#include <anislider.au3>

where did you put that file? Should be in the AutoIT include directory.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

where did you put that file? Should be in the AutoIT include directory.

Cheers

Kurt

<{POST_SNAPBACK}>

its not on my computer... anywhere?

i have

GUISlider 6/5/2005

and

Autoit3.exe 6/28/2005

dont know?

8)

EDIT... I normally use the 3.1.1+++ exe file.... i just tried the zip file and its still not here

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

its not on my computer... anywhere?

Hm.. are you saying that you did not download the attachment from my post? Well, then it's totally clear why it does not work :) Go back to my post and get the file anislider.au3, put it into the include directory of AutoIT and run the sample I provided.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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