Jump to content

help with gui for a newbee


Recommended Posts

I need help with this gui

the first button should togle sound off / on

pretent the code is #soundon & #soundoff.

the second increase button must execute code #increase

the third button decrease shoud execute code #decrease.

forth button (not shown yet) toggles stay on top. I think thats $WS_EX_TOPMOST but now sure how to apply it.

can someone help me tidy this up?

Edited by trademaid
Link to comment
Share on other sites

code tags please

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

ive made progress.

this basically works, but im not sure how to do the stay on top.

Also would like to know how to resize the entire window box, not just the inside one.

thanks for your help

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

Opt("MustDeclareVars", 1)

Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1
Global $iTimer1, $iTimer2

_Example_Events()

Func _Example_Events()
    Local $hGUI, $btn_change, $iWait = 10, $btn_state,$btn_stateincrease;,$btn_change
    Local $aParts[3] = [75, 330, -1]

    $hGUI = GUICreate("Timers Using WM_TIMER Events", 400+200, 320) ; ttile x and y of the entire box
    $iMemo = GUICtrlCreateEdit("", 2, 32, 396+200, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $btn_state =         GUICtrlCreateButton("Sound off", 30, 270, 100, 25)
    $btn_stateincrease = GUICtrlCreateButton("Increase", 330, 270, 100, 25)
    $btn_change = GUICtrlCreateButton("Decrease", 230, 270, 90, 25)
    ;GUICtrlSetState($btn_change, $GUI_DISABLE)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
    _GUICtrlStatusBar_SetText($hStatusBar, "Timers*")
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
    $progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
    GUICtrlSetColor($progress, 0xff0000)
    _GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress))
    GUISetState()

    GUIRegisterMsg($WM_TIMER, "WM_TIMER")

    $iTimer1 = _Timer_SetTimer($hGUI, 1000)
;//#comments-start
    While 1
    ;if @sec=1 or @sec =30 then     MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "#milliseconds *******************")
                $iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
;GUICtrlSetData($iMemo, @sec & @crlf, 3)
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
                
            Case $btn_state
                ;If  GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
                    If  GUICtrlRead($btn_state) = "Sound On" Then ; if this is true you cant stop it
                        SoundPlay("c:\windows\media\ding.wav")
                    ;$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer . this line and below starts timer
                    ;If @error Or $iTimer2 = 0 Then ContinueLoop
                    GUICtrlSetData($btn_state, "Sound off")
                    ;GUICtrlSetState($btn_change, $GUI_ENABLE)
                Else
                    ;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
                    _Timer_KillTimer($hGUI, $iTimer2)
                    ;GUICtrlSetData($btn_state, "Start Progress Bar")
                    GUICtrlSetData($btn_state, "Sound on")
                    SoundPlay("c:\windows\media\tada.wav")
                EndIf
                
                Case $btn_stateincrease
                ;If  GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
                    If  GUICtrlRead($btn_state) = "increase" Then ; if this is true you cant stop it
                        ;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "increase")
                    $iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
                    If @error Or $iTimer2 = 0 Then ContinueLoop
                    ;GUICtrlSetData($btn_state, "Sound off")
                    ;GUICtrlSetState($btn_change, $GUI_ENABLE)
                Else
                    MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "**increase")
                    ;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
                    _Timer_KillTimer($hGUI, $iTimer2)
                    ;GUICtrlSetData($btn_state, "Start Progress Bar")
                    ;GUICtrlSetData($btn_state, "Sound on")
                    ;SoundPlay("c:\windows\media\tada.wav")
                EndIf
                
                
                Case $btn_change
                ;If  GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
                    If  GUICtrlRead($btn_state) = "decrease" Then ; if this is true you cant stop it
                    ;   MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "decrease")
                    $iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
                    If @error Or $iTimer2 = 0 Then ContinueLoop
                    ;GUICtrlSetData($btn_state, "Sound off")
                    ;GUICtrlSetState($btn_change, $GUI_ENABLE)
                Else
                    ;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
                    _Timer_KillTimer($hGUI, $iTimer2)
                    ;GUICtrlSetData($btn_state, "Start Progress Bar")
                    ;GUICtrlSetData($btn_state, "Sound on")
                    MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "decrease")
                EndIf
                
                
                
                
                
                
                
            ;Case $btn_change
            ;   If $iWait = 10 Then
            ;       $iWait = 250
            ;   Else
            ;       $iWait = 10
            ;   EndIf
                MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds *")
                ;***$iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
        EndSwitch
    WEnd
    #comments-end
    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @LF)
    GUIDelete()
EndFunc   ;==>_Example_Events

; Timer Events
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $ilParam
    
    Switch _Timer_GetTimerID($iwParam)
        Case $iTimer1
            _UpdateStatusBarClock()
        Case $iTimer2
            _UpdateProgressBar()
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_TIMER

Func _UpdateStatusBarClock()
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock2

Func _UpdateProgressBar()
    $percent += 5 * $direction
    GUICtrlSetData($progress, $percent)
    If $percent = 100 Or $percent = 0 Then $direction *= -1
    If $percent = 100 Then
        GUICtrlSetColor($progress, 0xff0000)
    ElseIf $percent = 0 Then
        GUICtrlSetColor($progress, 0x0000ff)
    EndIf
EndFunc   ;==>_UpdateProgressBar2

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite
Edited by trademaid
Link to comment
Share on other sites

Here ya go. Please next time use autoit tags i.e

[autoit][/autoit]
=P

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

Opt("MustDeclareVars", 1)

Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1
Global $iTimer1, $iTimer2

_Example_Events()

Func _Example_Events()
Local $hGUI, $btn_change, $iWait = 10, $btn_state,$btn_stateincrease;,$btn_change
Local $aParts[3] = [75, 330, -1]

$hGUI = GUICreate("Timers Using WM_TIMER Events", 400+200, 320, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME), $WS_EX_TOPMOST) ; ttile x and y of the entire box
$iMemo = GUICtrlCreateEdit("", 2, 32, 396+200, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
$btn_state = GUICtrlCreateButton("Sound off", 30, 270, 100, 25)
$btn_stateincrease = GUICtrlCreateButton("Increase", 330, 270, 100, 25)
$btn_change = GUICtrlCreateButton("Decrease", 230, 270, 90, 25)
;GUICtrlSetState($btn_change, $GUI_DISABLE)
$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
_GUICtrlStatusBar_SetText($hStatusBar, "Timers*")
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
$progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
GUICtrlSetColor($progress, 0xff0000)
_GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress))
GUISetState()

GUIRegisterMsg($WM_TIMER, "WM_TIMER")

$iTimer1 = _Timer_SetTimer($hGUI, 1000)
;//#comments-start
While 1
;if @sec=1 or @sec =30 then MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "#milliseconds *******************")
$iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
;GUICtrlSetData($iMemo, @sec & @crlf, 3)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop

Case $btn_state
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "Sound On" Then ; if this is true you cant stop it
SoundPlay("c:\windows\media\ding.wav")
;$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer . this line and below starts timer
;If @error Or $iTimer2 = 0 Then ContinueLoop
GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
_Timer_KillTimer($hGUI, $iTimer2)
;GUICtrlSetData($btn_state, "Start Progress Bar")
GUICtrlSetData($btn_state, "Sound on")
SoundPlay("c:\windows\media\tada.wav")
EndIf

Case $btn_stateincrease
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "increase" Then ; if this is true you cant stop it
;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "increase")
$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
If @error Or $iTimer2 = 0 Then ContinueLoop
;GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "**increase")
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
_Timer_KillTimer($hGUI, $iTimer2)
;GUICtrlSetData($btn_state, "Start Progress Bar")
;GUICtrlSetData($btn_state, "Sound on")
;SoundPlay("c:\windows\media\tada.wav")
EndIf


Case $btn_change
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "decrease" Then ; if this is true you cant stop it
; MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "decrease")
$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
If @error Or $iTimer2 = 0 Then ContinueLoop
;GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2
_Timer_KillTimer($hGUI, $iTimer2)
;GUICtrlSetData($btn_state, "Start Progress Bar")
;GUICtrlSetData($btn_state, "Sound on")
MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "decrease")
EndIf







;Case $btn_change
; If $iWait = 10 Then
; $iWait = 250
; Else
; $iWait = 10
; EndIf
MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds *")
;***$iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
EndSwitch
WEnd
;#comments-end
ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @LF)
GUIDelete()
EndFunc ;==>_Example_Events

; Timer Events
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $ilParam

Switch _Timer_GetTimerID($iwParam)
Case $iTimer1
_UpdateStatusBarClock()
Case $iTimer2
_UpdateProgressBar()
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_TIMER

Func _UpdateStatusBarClock()
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc ;==>_UpdateStatusBarClock2

Func _UpdateProgressBar()
$percent += 5 * $direction
GUICtrlSetData($progress, $percent)
If $percent = 100 Or $percent = 0 Then $direction *= -1
If $percent = 100 Then
GUICtrlSetColor($progress, 0xff0000)
ElseIf $percent = 0 Then
GUICtrlSetColor($progress, 0x0000ff)
EndIf
EndFunc ;==>_UpdateProgressBar2

; Write a line to the memo control
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite

only changed styles in the GUICreate function.

Edited by Authenticity
Link to comment
Share on other sites

im impressed again.

I want to use a button to set stay on top.

How its setup its defined when the guicreate is done.

can this be done after the creation, or can we kill the gui and recreate it with or without the stay on top?

the window lower section also doesnt resize well when the y axis is stretched.

if there is a totally different way to do this with a gui, then thats fine.

can anyone recommend some good tutorials on gui?

some of seen show the outward capabilites, but dont use the inward.

some docs also dont show how its applied.

Edited by trademaid
Link to comment
Share on other sites

I've tried several ways to make it TopMost or not on the fly but still no luck, I've tried _WinAPI_GetWindowLong and GuiSetStyle and more but no luck so I'll need to keep test it...

About the $WS_THICKFRAME (resizeable window), you need to register a message handler to the WM_SIZE message to get notified about window getting resized and move the controls appropriately, because of this it's better to position the controls according to the GUI's width and height. This method is not so ideal for dialog boxes because you have buttons and many more controls, unlike Microsoft Notepad, for example, which has only an edit control with menu bar so resizing this window don't make it look ugly when it's resized heh.

Link to comment
Share on other sites

Link to comment
Share on other sites

I've tried several ways to make it TopMost or not on the fly but still no luck, I've tried _WinAPI_GetWindowLong and GuiSetStyle and more but no luck so I'll need to keep test it...

About the $WS_THICKFRAME (resizeable window), you need to register a message handler to the WM_SIZE message to get notified about window getting resized and move the controls appropriately, because of this it's better to position the controls according to the GUI's width and height. This method is not so ideal for dialog boxes because you have buttons and many more controls, unlike Microsoft Notepad, for example, which has only an edit control with menu bar so resizing this window don't make it look ugly when it's resized heh.

im a total novice on the gui.

can you recommend and alternative method. Im pretty flexible as to what, else show an example "you need to register a message handler to the WM_SIZE message to get notified about window getting resized and move the controls appropriately"

Link to comment
Share on other sites

Yeah, all this questions are answered there. Anyway this is example of msg handling but as you will see if you have controls in you gui like buttons or listboxes or so it's not a good idea to make the gui window resizeable:

Opt('MustDeclareVars', 1)

Dim $hGUI, $buttons[2]
Dim $i, $ret

$hGUI = GUICreate('Title', 500, 475, -1, -1, 0x80CF0000)

For $i = 0 To 1
    $buttons[$i] = GUICtrlCreateButton('Button&' & $i, 500/4+($i*500/4), 475/2-(475/8), 500/4, 475/4)
Next

$ret = GUIRegisterMsg(0x5, 'SizeHandler')

GUISetState()

While 1
    Local $msg = GUIGetMsg()
    
    If $msg = -3 Then ExitLoop

    Sleep(40)
WEnd

Exit

Func SizeHandler($hWnd, $uMsg, $wParam, $lParam)
    Local $nWidth, $nHeight, $i
    
    $nWidth = BitAND($lParam, 0x0000FFFF)
    ConsoleWrite(Hex($nWidth, 8) & @CRLF)
    $nHeight = BitAND($lParam, 0xFFFF0000)
    $nHeight /= 0x10000
    ConsoleWrite(Hex($nHeight, 8) & @CRLF)
    
For $i = 0 To 1
    $buttons[$i] = GUICtrlSetPos($buttons[$i], $nWidth/4+($i*$nWidth/4), $nHeight/2-($nHeight/8), $nWidth/4, $nHeight/4)
Next
EndFunc
Link to comment
Share on other sites

can anyone recommend some good tutorials on gui?

There is some tutorials on the forum, use search. Also u should just play around with the gui create + buttons etc...

thats how i learned to make gui's. :)

[font="Arial Black"][u]zero57[/u][/font]

Link to comment
Share on other sites

in the following code, how to i make the clock on the top , to the right of the buttons?

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

Opt("MustDeclareVars", 1)

Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1
Global $iTimer1, $iTimer2

;$ret = GUIRegisterMsg(0x5, 'SizeHandler')
;GUISetState()



_Example_Events()

Func _Example_Events()
Local $hGUI, $btn_change, $iWait = 10, $btn_state,$btn_stateincrease;,$btn_change
Local $aParts[3] = [75 ,330, -1]
;
;$hGUI = GUICreate("Timers Using WM_TIMER Events",         400+200, 320, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME), $WS_EX_TOPMOST) ; ttile x and y of the entire box
$hGUI = GUICreate("Timers Using WM_TIMER Events " & @sec, 400+200, 320, -1+1, -1+1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME ), $WS_EX_TOPMOST) ; ttile x and y of the entire box
;$hGUI = GUICreate("Timers Using WM_TIMER Events " & @sec, 400+200, 320, -1+1, -1+1, BitOR($WS_BORDER,$WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU )) ; ttile x and y of the entire box 0x80CF0000
;$iMemo = GUICtrlCreateEdit("", 2, 32, 396+200, 226, BitOR($WS_SCROLL, $WS_SCROLL))

$iMemo = GUICtrlCreateEdit("", 2, 22, 396+200, 305, BitOR($WS_HSCROLL, $WS_VSCROLL))
;$WS_AUTOVSCROLL, $WS_AUTOhSCROLL
;GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUICtrlSetFont($iMemo, 10, 00, 0, "")
;$btn_state = GUICtrlCreateButton("Sound off", 30, 270, 100, 25)
$btn_state = GUICtrlCreateButton("Sound off", 0, 0, 100, 25)
$btn_stateincrease = GUICtrlCreateButton("Increase", 100, 0, 100, 25)
$btn_change = GUICtrlCreateButton("Decrease", 200, 0, 90, 25)
;GUICtrlSetState($btn_change, $GUI_DISABLE)
$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
_GUICtrlStatusBar_SetText($hStatusBar, "Timers*")
_GUICtrlStatusBar_SetText($hStatusBar,  @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
$progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
GUICtrlSetColor($progress, 0xff0000)
_GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress))
GUISetState(); critical needed

;GUIRegisterMsg($WM_TIMER, "WM_TIMER")

;$iTimer1 = _Timer_SetTimer($hGUI, 1000)
;//#comments-start
While 1
    _UpdateStatusBarClock()
;if @sec=1 or @sec =30 then MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "#milliseconds *******************")
$iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
;GUICtrlSetData($iMemo, @sec & @crlf, 3)
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop

Case $btn_state
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "Sound On" Then ; if this is true you cant stop it
SoundPlay("c:\windows\media\ding.wav")
;$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer . this line and below starts timer
;If @error Or $iTimer2 = 0 Then ContinueLoop
GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2

;GUICtrlSetData($btn_state, "Start Progress Bar")
GUICtrlSetData($btn_state, "Sound on")
SoundPlay("c:\windows\media\tada.wav")
EndIf

Case $btn_stateincrease
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "increase" Then ; if this is true you cant stop it
;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "increase")
$iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
If @error Or $iTimer2 = 0 Then ContinueLoop
;GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "**increase")
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2

;GUICtrlSetData($btn_state, "Start Progress Bar")
;GUICtrlSetData($btn_state, "Sound on")
;SoundPlay("c:\windows\media\tada.wav")
EndIf


Case $btn_change
;If GUICtrlRead($btn_state) = "Start Progress Bar" Then ; if this is true you cant stop it
If GUICtrlRead($btn_state) = "decrease" Then ; if this is true you cant stop it
; MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "decrease")

If @error Or $iTimer2 = 0 Then ContinueLoop
;GUICtrlSetData($btn_state, "Sound off")
;GUICtrlSetState($btn_change, $GUI_ENABLE)
Else
;GUICtrlSetState($btn_change, $GUI_DISABLE) //tp2

GUICtrlSetData($iMemo, ''); this line clears the gui script
;GUICtrlSetData($btn_state, "Start Progress Bar")
;GUICtrlSetData($btn_state, "Sound on")

MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds !" & @SEC)

EndIf







;Case $btn_change
; If $iWait = 10 Then
; $iWait = 250
; Else
; $iWait = 10
; EndIf
MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds *")
;***$iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $iTimer2) ; reuse timer with different interval
EndSwitch
WEnd
;#comments-end

GUIDelete()
EndFunc ;==>_Example_Events

; Timer Events

Func _UpdateStatusBarClock()
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc ;==>_UpdateStatusBarClock2


; Write a line to the memo control
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Link to comment
Share on other sites

Use a label with SS_SUNKEN Style if I remember rightly... :)

Like the following:

#include <StaticConstants.au3>


$gui = GUICreate("Sample", 300, 200)
$lbl = GUICtrlCreateLabel("Somehting", 20, 20, 150, Default, $SS_SUNKEN)
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case - 3
            Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

I have now made the end product.

a tail command. It bleeps when the input file changes, unless you turn sound off.

There is a gui stay on top option now too. This is rough in the the gui x y corordinates reset to the initial ones.

I would like the clock on the top next to the buttons, auto width of the gui box if the lines are narrow, and better scaling of buttons. .

regardless this is a bit rough, but please feel free to use and improve

make a file in c:\1.txt

line1

line2

line3

line4

line5

line6

line7

line8

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <File.au3>
;Opt("MustDeclareVars", 1)



Global $hGUI, $btn_change, $iWait = 10, $btn_state, $btn_ontop, $btn_stateincrease, $iMemo, $inputfile, $attrib, $counter, $lines, $opstring, $tailline, $displaylines, $old_counter, $old_displaylines, $sound;,$btn_change
$inputfile = "c:\1.txt"
$displaylines = 5

$old_counter = -1; force it to display currentinfo on startup
$sound = 1; on by default

GUICreate("Tail 1.0 ", 400 + 200, 320, -1 + 1, -1 + 1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME), $WS_EX_TOPMOST) ; ttile x and y of the entire box
$btn_state = GUICtrlCreateButton("Sound off", 0, 0, 100, 25)
$btn_stateincrease = GUICtrlCreateButton("Increase", 100, 0, 100, 25)
$btn_change = GUICtrlCreateButton("Decrease", 200, 0, 90, 25)
$btn_ontop = GUICtrlCreateButton("Ontop", 300, 0, 90, 25)

GUISetState() ; will display an  dialog box with 2 button
$iMemo = GUICtrlCreateEdit("", 0, 25, 580, 300, BitOR($WS_HSCROLL, $WS_VSCROLL))


While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $btn_ontop

            If GUICtrlRead($btn_ontop) = "Ontop" Then ; if this is true you cant stop it
                SoundPlay("c:\windows\media\tada.wav")
                ;else
                GUIDelete()
                ; MsgBox(1,"tp1","")
                GUICreate("Tail 1 ", 400 + 200, 320, -1 + 1, -1 + 1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME)) ; ttile x and y of the entire box
                $btn_state = GUICtrlCreateButton("Sound off", 0, 0, 100, 25)
                $btn_stateincrease = GUICtrlCreateButton("Increase", 100, 0, 100, 25)
                $btn_change = GUICtrlCreateButton("Decrease", 200, 0, 90, 25)
                $btn_ontop = GUICtrlCreateButton("notOntop", 300, 0, 90, 25)
                $iMemo = GUICtrlCreateEdit("", 0, 25, 580, 300, BitOR($WS_HSCROLL, $WS_VSCROLL))
                GUISetState()
                $old_counter = -1
            Else
                
                
                
                
                SoundPlay("c:\windows\media\ringin.wav")
                ;else
                GUIDelete()
                ; MsgBox(1,"tp1","")
                GUICreate("Tail 1.0 ", 400 + 200, 320, -1 + 1, -1 + 1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_THICKFRAME), $WS_EX_TOPMOST) ; ttile x and y of the entire box
                $btn_state = GUICtrlCreateButton("Sound off", 0, 0, 100, 25)
                $btn_stateincrease = GUICtrlCreateButton("Increase", 100, 0, 100, 25)
                $btn_change = GUICtrlCreateButton("Decrease", 200, 0, 90, 25)
                $btn_ontop = GUICtrlCreateButton("Ontop", 300, 0, 90, 25)
                $iMemo = GUICtrlCreateEdit("", 0, 25, 580, 300, BitOR($WS_HSCROLL, $WS_VSCROLL))
                GUISetState()
                $old_counter = -1
            EndIf
            
            
            
            
        Case $btn_state

            If GUICtrlRead($btn_state) = "Sound On" Then ; if this is true you cant stop it
                SoundPlay("c:\windows\media\ding.wav")
                $sound = 0;
                GUISetStyle(-1, -1, $hGUI)
                GUICtrlSetData($btn_state, "Sound off")
                

            Else
                GUICtrlSetData($btn_state, "Sound on")
                SoundPlay("c:\windows\media\tada.wav")
                $sound = 1
                GUISetStyle(-1, $WS_EX_TOPMOST, $hGUI)
            EndIf
            
        Case $btn_stateincrease
            SoundPlay("c:\windows\media\chimes.wav")
            

            If GUICtrlRead($btn_state) = "increase" Then ; if this is true you cant stop it
                ;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "increase")
                ;SoundPlay("c:\windows\media\ringin.wav")
                
            Else
                ;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "**increase" & $displaylines)
                $displaylines = $displaylines + 1
                ;SoundPlay("c:\windows\media\chord.wav")
                
            EndIf
            
            
        Case $btn_change

            If GUICtrlRead($btn_state) = "decrease" Then ; if this is true you cant stop it
                
                If @error = 0 Then ContinueLoop
            Else
                $displaylines = $displaylines - 1
                ;MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & "**decrease" & $displaylines)
            EndIf
            
            
    EndSwitch
    
    $attrib = FileGetAttrib($inputfile)
    $counter = _FileCountLines($inputfile)
    While (StringInStr($attrib, "A") Or $counter <> $old_counter Or $old_displaylines <> $displaylines); _FileCountLines($inputfile) + 1)
        FileSetAttrib($inputfile, "-a")
        $attrib = FileGetAttrib($inputfile)
        $lines = _FileCountLines($inputfile)
        $opstring = ""
        
        For $loop = 0 To $displaylines;$lines
            $tailline = FileReadLine($inputfile, $counter - $displaylines + $loop + 1); read the line into tsdataline
            
            If @error = -1 Then
                FileSetAttrib($inputfile, "-a")
                
                ExitLoop
            EndIf
            $opstring = $opstring & $tailline & @CRLF

        Next
        FileClose($inputfile)
        $counter = $lines
        $old_counter = $counter
        $old_displaylines = $displaylines
        If $sound = 1 Then SoundPlay("c:\windows\media\ding.wav")
        
        GUICtrlSetData($iMemo, ''); this line clears the gui script. eraze wipe
        MemoWrite($opstring)
    WEnd
    
WEnd

Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite
Edited by trademaid
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...