Sign in to follow this  
Followers 0
qwert

Need advice on outdated example

2 posts in this topic

I've found an example on this forum of exactly the window type I'm trying to construct. Unfortunately, the script is from 2004 and it gets several errors when the SyntaxCheck is run. Has AutoIt changed that much since then that the script is now obsolete -- or am I just missing an include file with the proper functions?

Here is the script:

; CREATE GUI WITH BORDERLESS STYLE

Global $title = "ExampleGUI"
Global $MOVE_MODE = 0, $OFFSET
Opt("WinWaitDelay", 10)
Opt("GUINotifyMode", 1)
GuiCreate($title, 200, 100, 10, 10, 0x80000000)


; CREATE ALL CONTROLS BEFORE THE BACKGROUND

$hello = GuiSetControl("button","Hello", 10, 10, 30, 20)
$close = GuiSetControl("button","Close", 140, 60, 30, 20)

$background = GuiSetControl("label","", 0, 0, 200, 100)
GuiShow()
WinSetOnTop($title, "", 1)

; SET CONTROL STATES TO SHOW... IN ORDER FOR THE WINDOW TO REPAINT

GUISetControlEx($hello, 16);show
GUISetControlEx($close, 16);show

While 1
   sleep(10);just some extra sleep...
  
; IF IN MOVE MODE, THEN MOVE THE WINDOW RELATIVE TO THE MOUSE
  
   If $MOVE_MODE Then
      $mouse = MouseGetPos()
      WinMove($title,"", $mouse[0] + $x_offset, $mouse[1] + $y_offset)
   EndIf
  
   $msg = GuiMsg(0)
   If $msg = $hello Then MsgBox(4096,"Hi","Test message")
   If $msg = $close Then Exit
   If $msg = $background Then
      $MOVE_MODE = Not $MOVE_MODE;toggle mode
      
   ;CALCULATE RELATIVE OFFSET BETWEEN WINDOW AND MOUSE
      If $MOVE_MODE Then
         $mouse = MouseGetPos()
         $window = WinGetPos($title)
         $x_offset = $window[0] - $mouse[0]
         $y_offset = $window[1] - $mouse[1]
      EndIf
   EndIf
WEnd
Thanks in advance for any help.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you want a moveable popup window, there are far better solutions to be found in this forum. No need to be digging for fossils so deep.

Do a search for "+drag +ws_popup" and you'll have dozens of threads, some as old as two weeks ago.

Edited by Siao

"be smart, drink your wine"

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