Sign in to follow this  
Followers 0
CyberSlug

IDE for GUI: Any coders?

152 posts in this topic

#1 ·  Posted (edited)

Is anyone planning to write some sort of IDE GUI Builder for AutoItGui scripts?

I could begin a new version of AutoBuilder if nobody wants to write a better program....

Current beta Prototype: http://www.autoitscript.com/fileman/users/public/CyberSlug/jan11autobuilder.zip

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites



me like this idea very much :ph34r:

Share this post


Link to post
Share on other sites

Is anyone planning to write some sort of IDE GUI Builder for AutoItGui scripts?

I could begin a new version of AutoBuilder if nobody wants to write a better program....

Go for it - it should be much easier with the multi gui stuff. If you struggle with getting certain features working then let me know and I can add functions (within reason :ph34r: ) - for example I will be adding some mouse detection stuff for the GUI windows and I think we may need some control specific context menus as well as a general context menu.

Share this post


Link to post
Share on other sites

Does mouse detection stuff include custom mouse cursors? I remember having trouble with the cursor reverting to the original when it hovered over controls.....

Another nice feature would be the ability to draw lines and set pixels. (This might allow me to draw a grid background without having to use an image file of a grid....)

Rich Text controls would be another nice feature....

I'd also like the ability for ControlCommand stuff to read a control's styles at runtime (in order to differentiate among buttons, checkboxes, and radio buttons)....

Mouse detection is the most important, however. :ph34r:


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Does mouse detection stuff include custom mouse cursors?  I remember having trouble with the cursor reverting to the original when it hovered over controls.....

Another nice feature would be the ability to draw lines and set pixels.  (This might allow me to draw a grid background without having to use an image file of a grid....)

Rich Text controls would be another nice feature....

I'd also like the ability for ControlCommand stuff to read a control's styles at runtime (in order to differentiate among buttons, checkboxes, and radio buttons)....

Mouse detection is the most important, however.  :ph34r:

I seem to remember that i just change a single line to keep the cursor as requested no matter what it hovered over - I sorta considered this a bug, but if you don't think it should change then that's easy to modify.

Drawing lines and the like has to be done IIRC during the WM_PAINT message which means that we need the callback stuff working first so that whenever windows needs to repaint the screen it can run a section of autoitscript. It's entirely possible as long as the script can run fast enough - will have to check after callbacks are in.

Share this post


Link to post
Share on other sites

...

I could begin a new version of AutoBuilder if nobody wants to write a better program....

<{POST_SNAPBACK}>

Would be nice and very useful. (since it has always been, AB.) :ph34r:

(...and these features what you said...) :(

Share this post


Link to post
Share on other sites

Is anyone planning to write some sort of IDE GUI Builder for AutoItGui scripts?

I could begin a new version of AutoBuilder if nobody wants to write a better program....

<{POST_SNAPBACK}>

I'd just like to add a vote for "yes, please do" since I haven't been using the GUI, I really need something like the AutoBuilder to get started...

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

I'd just like to add a vote for "yes, please do" since I haven't been using the GUI, I really need something like the AutoBuilder to get started...

Me too, I've never had the patience to do controls by hand :ph34r:

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I seem to remember that i just change a single line to keep the cursor as requested no matter what it hovered over - I sorta considered this a bug, but if you don't think it should change then that's easy to modify.

Could you change this? It seems the only time I want to change the mouse cursor is when it *is* hovering over a control!

Better yet would be a function similar to GUICtrlSetTip!

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Could you change this?  It seems the only time I want to change the mouse cursor is when it *is* hovering over a control!

Better yet would be a function similar to GUICtrlSetTip!

I changed it soon after that post so that it stays as whatever cursor you set it as. There's been about 10 unstable releases since then with various tweaks and fixes. :)

It may be too resource intensive to be able to set a cursor only for a particular control... If i have to search through the position of every control and compare it to the mouse position then it's a no-go. I think there might be an API that does it for you though so I'll check.

Edited by Jon

Share this post


Link to post
Share on other sites

I've got a GuiCtrlSetCursor() working. It works well but it wil be resource intensive for a massive amount of controls - if you don't use CtrlSetCursor in a script then there is no penalty, but if you do then every time the mouse is moved a search is run to find what control you are over which is obviously not free.

Will upload later.

Share this post


Link to post
Share on other sites

I've got a GuiCtrlSetCursor() working.  It works well but it wil be resource intensive for a massive amount of controls - if you don't use CtrlSetCursor in a script then there is no penalty, but if you do then every time the mouse is moved a search is run to find what control you are over which is obviously not free.

Will upload later.

<{POST_SNAPBACK}>

Thanks, don't forget to upload sources :)

Share this post


Link to post
Share on other sites

Could you change this?  It seems the only time I want to change the mouse cursor is when it *is* hovering over a control!

Better yet would be a function similar to GUICtrlSetTip!

Just uploaded a new unstable that has options with GuiSetCursor and GuiCtrlSetCursor so you should be able to do everything needed.

- Set a cursor for a window

- Decide if the window cursor changes shape when over controls (like the bar cursor over edit controls)

- Override the cursor shown when over individual controls.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Got some new messages working that let you know when and where the mouse is moved and when "primary" and "secondary" are clicked in a window.  Will upload in a while with an example. 

<{POST_SNAPBACK}>

Have you uploaded this yet? I'm eager to test mouse click detection :)

EDIT: Nevermind, I see the values in GuiConstants.au3! Excellent :)

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Feasibility test regarding mouse stuff.... and some thinking out loud....

- MoveMode: Click, Move, Click

- DrawMode: MouseDown, Move, MouseUp

It appears that buttons no longer respond to mouse clicks when they appear on top of an enabled picture.... This should be okay, since Visual Basic 6 requires you to select (click) an item on the toolbar each time you want to draw a new control...

However, I'd like to implement MoveMode with MouseUp/Down instead of clicks....

I'd probably have to loop thru all controls to determine which one is under the mouse (which Jon said he had to do for custom control cursors....)

A picture registers an event as soon as you mouseDown on it, and I use this fact in the Case $background = $msg[0] part...

A button only registers a click after you both mouseDown and mouseUp on it.

I'll probably just make DrawMode use Click, Move, Click like previous AutoBuilder versions :)

;;; Assume that background.bmp is the grid picture that AutoBuilder uses

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 4);advanced

$win = GUICreate("Move Mode", 415, 315, 100, 100)
$enableDraw = GUICtrlCreateMenuitem("Click for Draw Mode  ", -1)
$enableMove = GUICtrlCreateMenuitem("Click for Move Mode  ", -1)
$background = GUICtrlCreatePic(@ScriptDir & "\background.bmp", 0, 0, 1024,768)
$buttonRef = GuiCtrlCreateButton("Button", 10, 10, 100, 100)

Dim $Mode = 3; 1=initDraw, 2=drawing,  3=initMove, 4=moving
Dim $buttonRef, $p, $xOffset, $yOffset, $oldP

GUISetCursor(9, 1);sizeall cursor
GUICtrlSetState($background, 128);disable background so that user can click buttons

GuiSetState()
While 1
    $msg = GUIGetMsg(1)
    Select
    Case $GUI_EVENT_CLOSE = $msg[0]
        ExitLoop
   Case $enableDraw = $msg[0]
      $mode = 1
      If WinGetTitle("handle=" & $win) <> "Draw Mode" Then WinSetTitle("handle=" & $win, "", "Draw Mode")
      GUISetCursor(3, 1);crosshair cursor
      GUICtrlSetState($background, 64);enable background
      _repaintWindow()
   Case $enableMove = $msg[0]
      $mode = 3
      If WinGetTitle("handle=" & $win) <> "Move Mode" Then WinSetTitle("handle=" & $win, "", "Move Mode")
      GUISetCursor(9, 1);sizeall cursor
      GUICtrlSetState($background, 128);disable background so that user can click buttons
      _repaintWindow()
   Case $background = $msg[0]
    ; Note that clicking the background is triggered on mouse down
    ;  clicking on a button requires both mouse down and mouse up
      If $mode = 1 Then
         $p = _mouseClientPos()
         $buttonRef = GuiCtrlCreateButton("Button", $p[0], $p[1], 1, 1)
         ToolTip("")
         $mode = 2
      EndIf
   Case $GUI_EVENT_PRIMARYUP = $msg[0]
      If $mode = 2 Then
         $mode = 1
         ToolTip("")
      EndIf
   Case $msg[0] > 0;some button control
      If $mode = 3 Then
         $buttonRef = $msg[0]
         $c = ControlGetPos("handle=" & $win,"",$msg[0])
         $p = _mouseClientPos()
         $xOffset = $p[0] - $c[0]
         $yOffset = $p[1] - $c[1]
         ToolTip($xOffset & "," & $yOffset, 0, 0)
         $mode = 4
      ElseIf $mode = 4 Then
         $mode = 3
         ToolTip("")
      EndIf
   EndSelect
   
   Select
   Case $mode = 2;drawing
      $n = _mouseClientPos()
      If IsArray($p) Then
         GuiCtrlSetPos($buttonRef, $p[0], $p[1], $n[0]-$p[0], $n[1]-$p[1])
         ToolTip($n[0]-$p[0] & " x " & $n[1]-$p[1])
      EndIf
   Case $mode = 4;moving
      $p = _mouseClientPos()
    ;If (Not IsArray($oldP)) OR $oldP[0] <> $p[0] OR $oldP[1] <> $p[1] Then
         ToolTip("(" & $p[0] & ", " & $p[1] & ")")
    ;  $oldP = $p
    ;EndIf
      GuiCtrlSetPos($buttonRef, $p[0]-$xOffset, $p[1]-$yOffset, $c[2], $c[3])
   EndSelect
   
Wend
Exit


; Convert window mouse coordinates to GUI client area coords
Func _mouseClientPos()
    Local $mouseCoordModeBAK = Opt("MouseCoordMode", 0);relative to window

    Local $tmp[2]
    Local $windowSize = WinGetPos("");assuming GUI is active window...
    Local $clientSize = WinGetClientSize("")
   If @error Then Return $tmp;in case the taskbar is active
    Local $mouseCoord = MouseGetPos()
    Local $border = ($windowSize[2] - $ClientSize[0]) / 2;border along sides of window

    $tmp[0] = $mouseCoord[0] - $windowSize[2] + $clientSize[0] + $border
    $tmp[1] = $mouseCoord[1] - $windowSize[3] + $clientSize[1] + $border

    Opt("MouseCoordMode", $mouseCoordModeBAK);original
    Return $tmp
EndFunc


Func _repaintWindow()
; The SplashText forces the Helper window to repaint its controls
    Local $p = WinGetPos("handle=" & $win)
    SplashTextOn("", "", $p[2], $p[3], $p[0], $p[1], 1)
    SplashOff()
EndFunc

; For debug purposes...
Func Beep()
   Run(@ComSpec & " /c echo " & Chr(7), "", @SW_HIDE)
EndFunc
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

That's certainly nice and responsive. :)

I noticed that you're still having to resort to some generic Control... commands and then manually do screen->client area stuff. I'm not sure how to handle this - whether to rely on the generic control commands or to add a few more GUI... specific ones that talk in client coords. We've already got so many GUI specific functions that duplicate general Control commands. Thoughts?

I also noticed that you had to use MouseGetPos, you should probably have a case statement for the GUI_EVENT_MOUSEMOVE message and then just have it keep track of the current position in a global at all times, and then when you want to check the mouse position you can just read the variable and it will already be in client coords. Or I could re-add the GuiGetCursorPos function that can just ask the GUI for the last known position (again in client coords).

I could probably get the control notify messages to contain the mouse x and y at the time of the click too. So then when a button is clicked you can read the X and Y bit of the message and see where the mouse was when the notify happened. I'll test that out.

Share this post


Link to post
Share on other sites

I've updated the unstable with a few thing to make things easier. And the resulting script is:

;;; Assume that background.bmp is the grid picture that AutoBuilder uses

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 4);advanced

$win = GUICreate("Move Mode", 415, 315, 100, 100)
$enableDraw = GUICtrlCreateMenuitem("Click for Draw Mode  ", -1)
$enableMove = GUICtrlCreateMenuitem("Click for Move Mode  ", -1)
$background = GUICtrlCreatePic(@ScriptDir & "\background.bmp", 0, 0, 1024,768)
$buttonRef = GuiCtrlCreateButton("Button", 10, 10, 100, 100)

Dim $Mode = 3; 1=initDraw, 2=drawing,  3=initMove, 4=moving
Dim $buttonRef, $p, $xOffset, $yOffset, $oldP

GUISetCursor(9, 1);sizeall cursor
GUICtrlSetState($background, 128);disable background so that user can click buttons

GuiSetState()
While 1
    $msg = GUIGetMsg(1)


    Select
        Case $GUI_EVENT_CLOSE = $msg[0]
            ExitLoop

        Case $enableDraw = $msg[0]
            $mode = 1
            If WinGetTitle("handle=" & $win) <> "Draw Mode" Then WinSetTitle("handle=" & $win, "", "Draw Mode")
            GUISetCursor(3, 1);crosshair cursor
            GUICtrlSetState($background, 64);enable background

        Case $enableMove = $msg[0]
            $mode = 3
            If WinGetTitle("handle=" & $win) <> "Move Mode" Then WinSetTitle("handle=" & $win, "", "Move Mode")
            GUISetCursor(9, 1);sizeall cursor
            GUICtrlSetState($background, 128);disable background so that user can click buttons

        Case $background = $msg[0]
        ; Note that clicking the background is triggered on mouse down
        ;  clicking on a button requires both mouse down and mouse up
            If $mode = 1 Then
                $p = GuiGetCursorInfo()
                $buttonRef = GuiCtrlCreateButton("Button", $p[0], $p[1], 1, 1)
                ToolTip("")
                $mode = 2
            EndIf

        Case $GUI_EVENT_PRIMARYUP = $msg[0]
            If $mode = 2 Then
                $mode = 1
                ToolTip("")
            EndIf


        Case $msg[0] > 0;some button control
            If $mode = 3 Then
                $buttonRef = $msg[0]
                $c = ControlGetPos("handle=" & $win,"",$msg[0])
                $p = GuiGetCursorInfo()
                $xOffset = $p[0] - $c[0]
                $yOffset = $p[1] - $c[1]
                ToolTip($xOffset & "," & $yOffset)
                $mode = 4
            ElseIf $mode = 4 Then
                $mode = 3
                ToolTip("")
            EndIf

        Case $msg[0] = $GUI_EVENT_MOUSEMOVE
            Select
                Case $mode = 2;drawing
                    $n = GuiGetCursorInfo()
                    If NOT @error Then
                        GuiCtrlSetPos($buttonRef, $p[0], $p[1], $n[0]-$p[0], $n[1]-$p[1])
                        ToolTip($n[0]-$p[0] & " x " & $n[1]-$p[1])
                    EndIf
                Case $mode = 4;moving
                    $p = GuiGetCursorInfo()
                    ToolTip("(" & $p[0] & ", " & $p[1] & ")")
                    GuiCtrlSetPos($buttonRef, $p[0]-$xOffset, $p[1]-$yOffset, $c[2], $c[3])
            EndSelect
    EndSelect
  
  
Wend
Exit


; For debug purposes...
Func Beep()
  Run(@ComSpec & " /c echo " & Chr(7), "", @SW_HIDE)
EndFunc

I've basically removed the mouseclient pos and repaintwindow stuff by adding a few functions and fixing the bug that made repaintwindow required. The only thing I'm still not happy with is the ControlGetPos thing. Maybe I should add a GuiCtrlGetPos function. Or maybe a basic GuiCtrlGetInfo function that gives you the position, size and internal type?

Share this post


Link to post
Share on other sites

I've basically removed the mouseclient pos and repaintwindow stuff by adding a few functions and fixing the bug that made repaintwindow required.  The only thing I'm still not happy with is the ControlGetPos thing.  Maybe I should add a GuiCtrlGetPos function.  Or maybe a basic GuiCtrlGetInfo function that gives you the position, size and internal type?

<{POST_SNAPBACK}>

Thanks :) I'm sure josbe will also appreciate the repaintwindow fixes :)

ControlGetPos bothers me too, but I'm fine as long as it works. After all, I do use the generic WinSetTitle to change the GUI's title.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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