Jump to content

Script inside a While Loop stop while dragging a GUI Window or Enter the Menu List


Recommended Posts

Hej Guys,

I'm new here but I work with Autoit long time.

I made a lot of different au3 scripts.

A few are more complex and others short & easy.

This time I want to build a bigger script...  but already at begin of my project I saw an inconspicuous but ugly problem.

The Problem Description:

I have a label which includes the time parameters "@HOUR @MIN @SEC".

After the whole "GuiCtrl Creation" + Attributes I made a "While Loop" and inside the 'while-loop' I paste the Code "GuiCtrlSetData($TimeLabel,@HOUR & ":" & @MIN & ":" & @SEC)"

with a Sleep Command (1000) 1 second.

Everything works well the Label refresh the Time every 1 second  but the Label doesnt refresh while I drag a GUI or enter with my Mouse the Menu Bar,

To understand it better here is the script:   

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <Debug.au3>
#include <String.au3>
#include <NetShare.au3>
#include <Array.au3>
#include <EditConstants.au3>
#Include <Misc.au3>
#include <array.au3>
#include <GuiStatusBar.au3>
#include <GuiButton.au3>
#include <File.au3>
#include <Array.au3>
#include <Inet.au3>
#include <GuiStatusBar.au3>
#include <Timers.au3>
#include <ProgressConstants.au3>


Local $i, $Uhr
Opt("GUIOnEventMode",1) ;OnEvent Modus für GUIs' , die dem User als Tool dienen.
Opt("TrayIconHide", 0)  ;0 Zeigt TrayIcon des Programms, 1 versteck TrayIcon
Opt("GUICloseOnESC",1)  ;Schließt das Programm beim Drücken der ESC Taste
;~ Opt("SendCapslockMode", 0)

Local $PublicIP = _GetIP()
Local $aParts[3] = [100,25,-1]

;******************SOLUTION MENÜ*************************************
$main_gui = GUICreate("EDV",281, 19, 500,200)
;***************S T E U E R E L E M E N T E********
GUISetOnEvent($GUI_EVENT_CLOSE, "close_main_gui")

;M E N U S
;Menü Datei
$Datei = GUICtrlCreateMenu("Netzwerk Ordner")
$Datei_item1 = GUICtrlCreateMenuItem("Ordner öffnen", $Datei)
GUICtrlSetOnEvent($Datei_item1,"Open_NetzwerkOrdnerGUI")
$Datei_item2 = GUICtrlCreateMenuItem("Beenden", $Datei)

;Menü Programme
$Programme = GUICtrlCreateMenu("Programme")
$Programme_item1 = GUICtrlCreateMenuItem("Info", $Programme)

;Menü Drucker
$Drucker = GUICtrlCreateMenu("Drucker")
$Drucker_item1 = GUICtrlCreateMenuItem("Info", $Drucker)

;Menü Hilfe
$Hilfe = GUICtrlCreateMenu("Hilfe")
$Uhrzeit = GUICtrlCreateMenuItem("Uhrzeit", $Hilfe)
GUICtrlSetOnEvent($Uhrzeit,"ShowUhr")
$Hilfe_item2 = GUICtrlCreateMenuItem("Info", $Hilfe)

;Menü Uhr
$Zeit = GUICtrlCreateMenu(@HOUR & ":" & @MIN & ":" & @SEC)
$Zeit_item1 = GUICtrlCreateMenuItem("Fenstermodus", $Zeit)
GUICtrlSetOnEvent($Zeit_item1,"UhrModus")
;GUICtrlSetState($Zeit,$GUI_DISABLE)



; L A B E L S 

;Gesamtes Netzwerk
;Attribute
GUICtrlCreateLabel("Gesamtes Netzwerk:",10,10)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlSetFont(-1,8,400,4)
GUICtrlSetResizing(-1,$GUI_DOCKALL)

;Netzwerk Ordner
;Attribute
GUICtrlCreateLabel("Netzwerk Ordner:",10,50)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlSetFont(-1,8,400,4)
GUICtrlSetResizing(-1,$GUI_DOCKALL)

$Time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC,40,320,60)
GUICtrlSetResizing($Time,$GUI_DOCKALL)


;B U T T O N S 

;ShowNetwork
;Attribute
$ShowNetwork = GUICtrlCreateButton("Show", 280,10,45,20)
GUICtrlSetFont($ShowNetwork,7)
GUICtrlSetResizing($ShowNetwork,$GUI_DOCKALL)
;Event
GUICtrlSetOnEvent($ShowNetwork, "ShowNetwork")

;OpenNetwork
;Attribute
$OpenNetwork = GUICtrlCreateButton("Open", 330, 10, 45, 20)
GUICtrlSetFont($OpenNetwork,7)
GUICtrlSetResizing($OpenNetwork,$GUI_DOCKALL)
;Event
GUICtrlSetOnEvent($OpenNetwork, "OpenNetwork")

;ShowFiles
;Attribute
$ShowFiles = GUICtrlCreateButton("Show", 280, 50, 45, 20)
GUICtrlSetFont($ShowFiles,7)
GUICtrlSetResizing($ShowFiles,$GUI_DOCKALL)
;Event
GUICtrlSetOnEvent($ShowFiles, "ShowFiles")

;Erweitert
;Attribute
$Erweitert = GUICtrlCreateButton("Erweitert",10,80,370,15)
GUICtrlSetFont($Erweitert,7)
GUICtrlSetResizing($Erweitert,$GUI_DOCKALL)
;Event
GUICtrlSetOnEvent($Erweitert,"Erweitert")

;Normal
;Attribute
$Normal = GUICtrlCreateButton("Normal",10,80,370,15)
GUICtrlSetFont($Normal,7)
GUICtrlSetResizing($Normal,$GUI_DOCKALL)
GUICtrlSetState($Normal,$GUI_HIDE)
;Event
GUICtrlSetOnEvent($Normal,"Normal")

;C O M B O  B O X E S

;Netzwerkliste
;Attribute
$NetzwerkListe = GUICtrlCreateCombo("",120,10,150,10)
GUICtrlSetFont($netzwerkListe,7)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlSetResizing(-1,$GUI_DOCKALL)

;Ordner Liste
;Attribute
$OrdnerListe = GUICtrlCreateCombo("",120,50,150,40)
GUICtrlSetFont($OrdnerListe,7)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlSetResizing(-1,$GUI_DOCKALL)

GUISetBkColor(0xFFFFFF)                                             ;HINTERGRUNDFARBE
WinSetTrans($main_gui,"",220)                           ;Transparenz des programmwindows
GUISetBkColor(0xFFFFFF)                                             ;HINTERGRUNDFARBE
GUISetBkColor(0xFFFFFF) 

;*************** U H R   G U I************************
$Uhr_GUI = GUICreate(" ",265,100)
;***************S T E U E R E L E M E N T E***********
GUISetOnEvent($GUI_EVENT_CLOSE, "close_Uhr_gui")

$UhrLabel = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC,10,0,240,70)
GUICtrlSetFont($UhrLabel,50,40,2,"Impact")


GUISwitch($main_gui)
GUISetState(@SW_SHOW)

While 1
Sleep(1000)
GUICtrlSetData($Zeit,@HOUR & ":" & @MIN & ":" & @SEC)
GUICtrlSetData($UhrLabel,@HOUR & ":" & @MIN & ":" & @SEC)
WEnd

;***********************************************;
;*******************FUNKTIONEN******************;
;***********************************************;
Func close_main_gui()
   Exit
EndFunc

Func close_Uhr_gui()
   GUISwitch($main_gui)
   GUISetState(@SW_SHOW, $main_gui)
   GUISetState(@SW_HIDE, $Uhr_gui)
   Local $size = WinGetPos("EDV")
   WinMove("EDV", "",$size[0],$size[1],343,47)
   GUICtrlSetData($Uhrzeit,"Uhrzeit")
   GUICtrlSetState($Uhrzeit,$GUI_ENABLE)
EndFunc

Func Open_NetzwerkOrdnerGUI()
   MsgBox(0,"f","test")
EndFunc

Func ShowUhr()
   Local $size = WinGetPos("EDV")
   WinMove("EDV", "",$size[0],$size[1],343,47)
   GUICtrlSetOnEvent($Uhrzeit,"HideUhr")
   GUICtrlSetState($Uhrzeit,$GUI_CHECKED)
   GUICtrlSetState($Zeit,$GUI_HIDE)
EndFunc

Func HideUhr()
   Local $size = WinGetPos("EDV")
   WinMove("EDV", "",$size[0],$size[1],290,47)
   GUICtrlSetOnEvent($Uhrzeit,"ShowUhr")
   GUICtrlSetState($Uhrzeit,$GUI_UNCHECKED)
EndFunc

Func UhrModus()
   Local $size = WinGetPos("EDV")
   WinMove("EDV", "",$size[0],$size[1],290,47)
   $x = $size[0]
   $y = $size[1]
   $x = $x + 300
   $y = $y
   GUISwitch($Uhr_GUI)
   GUISetState(@SW_SHOW)
   GUICtrlSetState($Uhrzeit,$GUI_DISABLE)
   GUICtrlSetData($Uhrzeit,"Uhrzeit (Fenstermodus)")
   Local $size = WinGetPos(" ")
   WinMove(" ", "",$x,$y,$size[2],$size[3])
EndFunc

Would be very nice if somebody could help me

Edited by AndroidZero
Link to comment
Share on other sites

  • Moderators

AndroidZero,

Threads merged - you are allowed to bump at least twice. :)

And did you think to search the forum (look at top-right for the facility)? This thread popped up when I took a quick look. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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