Sign in to follow this  
Followers 0
Sparrowlord

GUI Question

12 posts in this topic

Is it possible to just have a GUI centered at the bottom of my screen maybe 165 pixels high and 750 pixels wide that is always on top and acts like a console? I have never made a GUI in my life so I have no idea what a GUI can do. I thought maybe I was able to save the added lines to a file and call a function to update the GUI.

Example: When the GUI refreshes it shows in this format, where the last action is at the bottom and it works its way up the console with each new action and after so many just disappears from the GUI but is still in the file.

_____________________________________________________________________________________

Time: The action before that

Time: The action before that

Time: The action before that

Time: The action before that

Time: The action before that

Time: Last Action...

_____________________________________________________________________________________

And when I want to update the GUI I just call the function like "GUIUpdate()" where ever I want it to refresh...

Anyways, is this even possible if so what all would I have to do? I am almost finished with my script I have been working on now for over three weeks and I have never used a GUI so I don't really want to ruin my script with a horrible looking GUI.

Share this post


Link to post
Share on other sites



Is it possible to just have a GUI centered at the bottom of my screen maybe 165 pixels high and 750 pixels wide that is always on top and acts like a console? I have never made a GUI in my life so I have no idea what a GUI can do. I thought maybe I was able to save the added lines to a file and call a function to update the GUI.

Example: When the GUI refreshes it shows in this format, where the last action is at the bottom and it works its way up the console with each new action and after so many just disappears from the GUI but is still in the file.

_____________________________________________________________________________________

Time: The action before that

Time: The action before that

Time: The action before that

Time: The action before that

Time: The action before that

Time: Last Action...

_____________________________________________________________________________________

And when I want to update the GUI I just call the function like "GUIUpdate()" where ever I want it to refresh...

Anyways, is this even possible if so what all would I have to do? I am almost finished with my script I have been working on now for over three weeks and I have never used a GUI so I don't really want to ruin my script with a horrible looking GUI.

Use Koda that comes along with SCiTe installation.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I just tried to use Koda I can't make anything that looks good.. :)

Edited by Sparrowlord

Share this post


Link to post
Share on other sites

I just tried to use Koda I can't make anything that looks good.. :)

Can't be that bad... post what you created! And if you want some bling with it, do a search for X-Skin...

Share this post


Link to post
Share on other sites

Ah screw it, I just spent the last 9 hours working on this and I couldn't do it correctly. I screwed it up so bad that I just had to restart a few times.. I would post what I had, but I got so pissed off I went on a deleting rampage and ended up deleting half of the stuff on my computer.

It hasn't been a very good day :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Just save this code as Form1.kxf and load it by Koda and make desired changes:

<?xml version="1.0" encoding="windows-1251"?>
<object type="TAForm" name="Form1">
    <properties>
        <property name="Left" vt="Int16">259</property>
        <property name="Top" vt="Int16">158</property>
        <property name="Width" vt="Int16">538</property>
        <property name="Height" vt="Int16">394</property>
        <property name="Caption" vt="String">Form1</property>
        <property name="Color" vt="Ident">clBtnFace</property>
        <property name="Font.Charset" vt="Ident">DEFAULT_CHARSET</property>
        <property name="Font.Color" vt="Ident">clWindowText</property>
        <property name="Font.Height" vt="Int8">-11</property>
        <property name="Font.Name" vt="String">MS Sans Serif</property>
        <property name="Font.Style" vt="Set"/>
        <property name="OldCreateOrder" vt="False">False</property>
        <property name="Position" vt="Ident">poDesktopCenter</property>
        <property name="Visible" vt="True">True</property>
        <property name="Style" vt="Int32">-1798701056</property>
        <property name="ExStyle" vt="Int16">264</property>
        <property name="Version" vt="String">1.03</property>
        <property name="PixelsPerInch" vt="Int8">96</property>
        <property name="TextHeight" vt="Int8">13</property>
    </properties>
    <components>
        <object type="TAList" name="List1">
            <properties>
                <property name="Left" vt="Int8">4</property>
                <property name="Top" vt="Int8">4</property>
                <property name="Width" vt="Int16">522</property>
                <property name="Height" vt="Int16">357</property>
                <property name="ItemHeight" vt="Int8">13</property>
                <property name="TabOrder" vt="Int8">0</property>
                <property name="CtrlStyle" vt="Int32">1350631427</property>
                <property name="CtrlExStyle" vt="Int16">512</property>
                <property name="Resizing" vt="Set"/>
            </properties>
            <components/>
        </object>
    </components>
</object>
Edited by Zedna

Share this post


Link to post
Share on other sites

Oh wow, thanks Zedna.. I got it going and working

Just one question though, after the List gets full the messages keep displaying downwards but it don't scroll with it so they don't show unless you manually scroll.. how would I make it so it scrolls down with the messages as they appear ?

Example:

Posted Image

As you can see in that screen shot there are messages below "Line 10" but they don't show.

Any suggestions on what I should do to fix this?

Also I have no idea if I am putting the messages to the GUI right, I was just messing around with it and this seems to work so I went with it.

#include <GUIConstants.au3>
#include <file.au3>


#Region ### START Koda GUI section ### Form=c:\documents and settings\chris\desktop\form1.kxf
$Form1_1 = GUICreate("JMC - Console", 452, 144, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$list = GUICtrlCreateList("", 4, 4, 442, 136)
GUISetState(@SW_SHOW)
WinMove("JMC - Console", "", 0, 840)
GUICtrlSetData($list, "#Welcome Message Line 1")
GUICtrlSetData($list, "#Welcome Message Line 2")
GUICtrlSetData($list, "#Welcome Message Line 3")
GUICtrlSetData($list, "#Welcome Message Line 4")
GUICtrlSetData($list, "#Welcome Message Line 5")
#EndRegion ### END Koda GUI section ###
Sleep(5000)
GUICtrlSetData($list, Time() & "Line 6")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 7")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 8")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 9")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 10")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 11")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 12")
Sleep(2000)
GUICtrlSetData($list, Time() & "Line 13")
Sleep(1000)
GUICtrlSetData($list, Time() & "Line 14")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Time()
Func Time()
    If @HOUR > 12 Then
        $hour = @HOUR - 12
        $AMPM = " PM: "
    ElseIf @HOUR = 0 Then
        $hour = 12
        $AMPM = " AM: "
    Else
        $hour = @HOUR
        $AMPM = " AM: "
    EndIf
    Return $hour & ":" & @MIN & ":" & @SEC & $AMPM
EndFunc  ;==>Time

Help? :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

We fixed the time function, here is the new one

Func Time($Seconds = 1)
    Local $hour = @HOUR, $AMPM = "AM"
    If $hour > 11 Then $AMPM = "PM"
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    If $Seconds Then Return $hour & ":" & @MIN & ":" & @SEC & " " & $AMPM
    Return $hour & ":" & @MIN & " " & $AMPM
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

We fixed the time function, here is the new one

Func Time()
    Local $hour = @HOUR, $AMPM = "AM"
    If $hour > 11 Then $AMPM = "PM"
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    Return $hour & ":" & @MIN & " " & $AMPM
EndFunc

8)

The only problem with that function is it's lack of flexibility. You can't properly display seconds if you need them. And I just removed the code that did. :)^_^:)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

OK, how about this

#include <GUIConstants.au3>
#include <file.au3>


#Region ### START Koda GUI section ### Form=c:\documents and settings\chris\desktop\form1.kxf
$Form1_1 = GUICreate("JMC - Console", 452, 144, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$list = GUICtrlCreateList("", 4, 4, 442, 136)
GUISetState(@SW_SHOW)
;WinMove("JMC - Console", "", 0, 840)
AddText( "#Welcome Message Line 1")
AddText( "#Welcome Message Line 2")
AddText( "#Welcome Message Line 3")
AddText( "#Welcome Message Line 4")
AddText( "#Welcome Message Line 5")
#EndRegion ### END Koda GUI section ###
Sleep(5000)
AddText( Time() & " Line 6")
Sleep(2000)
AddText( Time() & " Line 7")
Sleep(2000)
AddText( Time() & " Line 8")
Sleep(2000)
AddText( Time() & " Line 9")
Sleep(2000)
AddText( Time() & " Line 10")
Sleep(2000)
AddText( Time() & " Line 11")
Sleep(2000)
AddText( Time() & " Line 12")
Sleep(2000)
AddText( Time() & " Line 13")
Sleep(1000)
AddText( Time() & " Line 14")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func AddText($text)
    $i = GUICtrlSendMsg($List, $LB_ADDSTRING, 0, $text) ; returns index of added line
    GUICtrlSendMsg($List, $LB_SETTOPINDEX, $i, 0)
EndFunc

Func Time($Seconds = 1)
    Local $hour = @HOUR, $AMPM = "AM"
    If $hour > 11 Then $AMPM = "PM"
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    If $Seconds Then Return $hour & ":" & @MIN & ":" & @SEC & " " & $AMPM
    Return $hour & ":" & @MIN & " " & $AMPM
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Func Time($Seconds = 1)
    Local $hour = @HOUR, $AMPM = "AM"
    If $hour > 11 Then $AMPM = "PM"
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    If $Seconds Then Return $hour & ":" & @MIN & ":" & @SEC & " " & $AMPM
    Return $hour & ":" & @MIN & " " & $AMPM
EndFunc
That does seconds but my earlier version did it easier by using the two functions. Luck I saved a copy . :)^_^

MsgBox(4096, "Time test", nHour() & @Min & ":" & @Sec & SetAP())

Func nHour()
    Local $hour = @Hour
    If $hour = 0 Then $hour = 12
    If $hour > 12 Then $hour -= 12
    Return $hour & ":"; & @MIN & " " & $AMPM
EndFunc

Func SetAP()
   Local $ap = " AM"
   If @Hour > 11 Then $ap = " PM"
   Return $ap
EndFunc

You can chang the function name if you need to.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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