Jump to content

My Gui to refesh data When it's not in focus (RESOLVED)


Recommended Posts

Hi guys

what i am trying to do is have My Gui LIve update Out of focus, so i can have this on a 2nd monitor streaming live updates while i continue to work on other screen, 

i have been googling and looking at other threads about focus and stuff , but they do not seem to match what I'm after, 

to be clear - i am not wanting to put focus on the GUI for it to auto update values, 

 

if you have any positive feed back on the script while you read - i would be more then happy to accept - as im still building my Knowledge of this coding, 

and stream line is always better Garbage code writing, 

 

Kind regards 

Gngnut

 

#include <MemoryConstants.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $currentTime,$currentTimeValue,$v,$Label_Time,$Form1
Global $Label_C2_1,$Label_C2_2,$Label_C2_3,$Label_C2_4,$Label_C2_5,$Label_C2_6,$Label_C2_7
Global $Label_C3_1,$Label_C3_2,$Label_C3_3,$Label_C3_4,$Label_C3_5,$Label_C3_6,$Label_C3_7

;~ Default Hight for boxs
    $Hight = 40
    $lenght = 180

;; As per nines comments moved out side of the While loop, 
    AdlibRegister(UpdateTime,250)
    AdlibRegister(updateValues,500)
    AdlibRegister(Warning,250)
    hotkeyset ("{ESC}",Terminate) ;; <<<  Used to Quit the programe

    $aMemStats = MemGetStats()
    MyGui()  ;; running the GUI

#Region ### START Koda GUI section ### Form=
func MyGui()
        $ServerName=@ComputerName
        ;  ### Change to your location of image
        $Image = "C:\Users\gngnut\OneDrive\Pictures\Computer.jpg"

        ; Creating the form With the Labels
        $Form1 = GUICreate("My System Status", 800, 750, 225, 173,BitOR($WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX));$WS_POPUP))
        $Pic1 = GUICtrlCreatePic($Image, 0, 0, 800, 750)

        ;;; ####  Column 1
        $Label_C1_1 = GUICtrlCreateLabel("Total load currently on RAM:", 71, 192, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_2 = GUICtrlCreateLabel("Total physical RAM:", 71, 248, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_3 = GUICtrlCreateLabel("Available physical RAM:", 71, 304, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_4 = GUICtrlCreateLabel("Total Page Size:", 71, 360, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_5 = GUICtrlCreateLabel("Available Page Size:", 71, 416, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_6 = GUICtrlCreateLabel("Total virtual Size:", 71, 472, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C1_7 = GUICtrlCreateLabel("Available virtual RAM:", 71, 528, 180, $Hight, BitOR($SS_CENTER,""))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        ;;; ####  Column 2

        $Label_C2_1 = GUICtrlCreateLabel($aMemStats[$MEM_LOAD] & " %", 311, 192, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        $colour=0xFEF200
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_2 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' , 311, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_3 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPHYSRAM] & ' Kb', 311, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_4 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPAGEFILE] & ' Kb', 311, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_5 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPAGEFILE] & ' Kb', 311, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_6 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALVIRTUAL] & ' Kb' , 311, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C2_7 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILVIRTUAL] & ' Kb', 311, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        ;;; ####  Column 3

        $Label_C3_2 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPHYSRAM]/1024/1024, 2) & ' Gb', 551, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C3_3 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPHYSRAM]/1024/1024, 2) & ' Gb', 551, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C3_4 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPAGEFILE]/1024/1024, 2) & ' Gb', 551, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C3_5 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPAGEFILE]/1024/1024, 2) & ' Gb', 551, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C3_6 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALVIRTUAL]/1024/1024, 2) & ' Gb', 551, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_C3_7 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILVIRTUAL]/1024/1024, 2) & ' Gb', 551, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_Server = GUICtrlCreateLabel($ServerName, 551, 600, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        $Label_Time = GUICtrlCreateLabel($currentTime , 71, 600, 180, $Hight, bitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE))
        GUICtrlSetBkColor(-1, 0xFEF200)
        GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

        GUISetState(@SW_SHOWNORMAL)
        #EndRegion ### END Koda GUI section ###
EndFunc

While 1
    Sleep(1000)  ; sets a delay of 1 sec per 1000
WEnd

;; close down the Application
func Terminate()
    exit
EndFunc

;;  Updating Time
func UpdateTime()
    $currentTime = @HOUR&":"& @MIN &":"& @SEC
    ControlSetText($Form1,"",$Label_Time, $currentTime)
EndFunc

;; currently changing the CPU % lable
Func Warning()
        if $aMemStats[$MEM_LOAD] <=40 Then ; Green
            GUICtrlSetbkColor($Label_C2_1,0x2BFC0B)
        ElseIf $aMemStats[$MEM_LOAD] >40 and $aMemStats[$MEM_LOAD] <= 80 Then
            GUICtrlSetbkColor($Label_C2_1,0xFDBE01)
        Elseif $aMemStats[$MEM_LOAD] > 80 Then
             GUICtrlSetBkColor($Label_C2_1, 0xEE0C0C)
        EndIf
EndFunc

;;  Updating The Lable values of column 2 Only if the values change
func updateValues()
    $aMemStats = MemGetStats()
    if  GUICtrlRead($Label_C2_1) <> $aMemStats[$MEM_LOAD] Then
        ControlSetText($Form1,"",$Label_C2_1,$aMemStats[$MEM_LOAD])
    endif
    If GUICtrlRead($Label_C2_2) <> $aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_2,$aMemStats[$MEM_TOTALPHYSRAM] & ' Kb')
    endif
    If GUICtrlRead($Label_C2_3) <> $aMemStats[$MEM_AVAILPHYSRAM]  & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_3,$aMemStats[$MEM_AVAILPHYSRAM]  & ' Kb')
    endif
    If GUICtrlRead($Label_C2_4) <> $aMemStats[$MEM_TOTALPAGEFILE] & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_4,$aMemStats[$MEM_TOTALPAGEFILE] & ' Kb')
    endif
    If GUICtrlRead($Label_C2_5) <> $aMemStats[$MEM_AVAILPAGEFILE] & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_5,$aMemStats[$MEM_AVAILPAGEFILE] & ' Kb')
    endif
    If GUICtrlRead($Label_C2_6) <> $aMemStats[$MEM_TOTALVIRTUAL]  & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_6,$aMemStats[$MEM_TOTALVIRTUAL]  & ' Kb')
    endif
    If GUICtrlRead($Label_C2_7) <> $aMemStats[$MEM_AVAILVIRTUAL]  & ' Kb' then
        ControlSetText($Form1,"",$Label_C2_7,$aMemStats[$MEM_AVAILVIRTUAL]  & ' Kb')
    endif
EndFunc

 

Edited by GNGNUT
Updated the Script content based on comments from others for better coding practice,
Link to post
Share on other sites

Your while Loop is not good at all.  It registers adlib functions and hotkeyset repeatedly which is useless.  Just put those statements once at the beginning of the script.  It is also a bad practice to put code between functions, it makes it hard to read and hard to debug.  Put all your main code together at the beginning of the script before all functions.

At first glance, beside the above comments, your code looks right, even if I didn't test it.  You do not seem to say that you have a particular problem...

Link to post
Share on other sites

HI Nine Ty for the comments, 

The problem i have and looking for a solution to is   Getting it to update - when its not in focus  as I'm working on other things on my pc, 

so if i'm writing emails, coding ect I would still like to see the GUI to update Per sec with out me having to click on it to update, 

Currently if i take focus The time will stop - and only change once i refocus the Gui again,

 

Link to post
Share on other sites

I see.  Declare your $Form1 as Global, and replace all controlSetText first parameter with $Form1, instead of "".  Should work...

If that doesn't work put top most extended style to your GUI.

Edited by Nine
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By XGamerGuide
      I'm trying to assign a faint text in the background to an input field that disappears after the input has started. This should have a certain color such as gray.
    • By Bruceway
      Hi All, 
      I am trying to mark out the middle square of this Magnify Routine "window on right" (stolen from M23 - Thanks) - I assume the DllCall is overwriting the boxes. But wherever I try and redraw, they won't stay on the Magnify Window. Can anyone advise, bet way to keep boxes around the middle square.
      Please be kind with my code, it is ripped from a MUCH bigger exe.
      The "half" transparent window, is for dragging to where you want it, and the buttons are for more precise placement.
      #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $hMag_GUI, $hMagDC, $hDeskDC, $hPen, $oObj, $aWinPos[2], $iLast_Mouse_X = 0, $iLast_Mouse_Y = 0 Global $pWindowCaptureX, $pWindowCaptureY Global $pWindowMagWinX, $pWindowMagWinY #Region - GUI3 ; *** Grabber/Picker Window Global $hGUI3 = GUICreate("Capture", 150, 150, $pWindowCaptureX, $pWindowCaptureY, $WS_EX_TOOLWINDOW) Global $Pic1 = GUICtrlCreatePic("", 70, 40, 10, 10, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER)) Global $hButtonUp = GUICtrlCreateButton("U", 65, 60, 20, 20) Global $hButtonDown = GUICtrlCreateButton("D", 65, 100, 20, 20) Global $hButtonLeft = GUICtrlCreateButton("L", 40, 80, 20, 20) Global $hButtonRight = GUICtrlCreateButton("R", 90, 80, 20, 20) Global $hButtonOK = GUICtrlCreateButton("OK", 60, 80, 30, 20) #EndRegion - GUI3 #Region - GUI4 Global $hGUI4 = GUICreate("MagWin", 250, 250, 325, 195) Global $hButtonMOK = GUICtrlCreateButton("OK", 45, 140, 30, 20) Global $hButtonMUp = GUICtrlCreateButton("U", 50, 120, 20, 20) Global $hButtonMDown = GUICtrlCreateButton("D", 50, 160, 20, 20) Global $hButtonMLeft = GUICtrlCreateButton("L", 25, 140, 20, 20) Global $hButtonMRight = GUICtrlCreateButton("R", 75, 140, 20, 20) Global $hLabelWindow = GUICtrlCreateLabel("Window", 5, 185, 44, 15) Global $hLabelWindowText = GUICtrlCreateLabel("", 60, 185, 176, 15) Global $hLabelCheck = GUICtrlCreateLabel("Check", 5, 205, 44, 15) Global $hLabelCheckText = GUICtrlCreateLabel("", 60, 205, 176, 15) Global $hLabelScreen = GUICtrlCreateLabel("Screen", 5, 225, 44, 15) Global $hLabelScreenText = GUICtrlCreateLabel("", 60, 225, 176, 15) #EndRegion - GUI4 ;GUISetState(@SW_HIDE, $hGUI1) GUISetState(@SW_SHOW, $hGUI3) GUISetState(@SW_SHOW, $hGUI4) WinSetTrans($hGUI3, "", 100) $hMag_GUI = WinGetHandle("MagWin") ; Get device context for Mag GUI $hMagDC = _WinAPI_GetDC($hMag_GUI) If @error Then Exit ; Get device context for desktop $hDeskDC = _WinAPI_GetDC(0) If @error Then _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) Exit EndIf ; Create pen $hPen = _WinAPI_CreatePen($PS_SOLID, 5, 0x7E7E7E) $oObj = _WinAPI_SelectObject($hMagDC, $hPen) ; Loop until the user exits. ; *** Static Window While 1 ; Reset position Local $aWinPos = WinGetPos("Capture") If $aWinPos[0] <> $iLast_Mouse_X Or $aWinPos[1] <> $iLast_Mouse_Y Then ; Redraw Mag GUI _FOEA_Loupe($aWinPos) ;~ Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle ;~ Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;~ ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) GUISetState(@SW_HIDE, $hGUI3) Local $output1 = PixelCheckSum($aWinPos[0]+81, $aWinPos[1]+75, $aWinPos[0]+91, $aWinPos[1]+85) Local $output2 = PixelCheckSum($aWinPos[0]+73, $aWinPos[1]+66, $aWinPos[0]+83, $aWinPos[1]+76) If $aWinPos[0] < 1440 Then GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81 & "(" & $aWinPos[0]+81+1440 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 & ")," & $aWinPos[1]+66 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 &")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) Else GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81-1440 & "(" & $aWinPos[0]+81 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+89-1440 & "(" & $aWinPos[0]+89 &")," & $aWinPos[1]+84 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73-1440 & "(" & $aWinPos[0]+73 & ")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) ;GUICtrlSetData($hLabel2, $aWinPos[1]+75) EndIf GUISetState(@SW_SHOW, $hGUI3) $iLast_Mouse_X = $aWinPos[0] $iLast_Mouse_Y = $aWinPos[1] $pWindowCaptureX = $aWinPos[0] $pWindowCaptureY = $aWinPos[1] ; *** Box ; Tried it here - doesn't work ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(194, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 73, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(0, 0, 1, 1) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Local $aWinPos = WinGetPos("MagWin") $pWindowMagWinX = $aWinPos[0] $pWindowMagWinY = $aWinPos[1] ;GUISetState(@SW_HIDE, $hGUI3) GUIDelete($hGUI3) ; Clear up Mag GUI _WinAPI_SelectObject($hMagDC, $oObj) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDeskDC) _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) ;GUISetState(@SW_HIDE, $hMag_G GUIDelete($hGUI4) GUIDelete($hMag_GUI) ExitLoop Case $hButtonMOK GUISetState(@SW_HIDE, $hGUI3) Local $aWinPos = WinGetPos("Capture") Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) If $aWinPos[0] > 1440 Then $aWinPos[0] = $aWinPos[0]-1440 $TWPx = $TWPx-1440 EndIf Local $output0 = PixelCheckSum($TWPx-8, $TWPy-9, $TWPx-8+10, $TWPy+1) ;_FOEA_WinAPI_DrawRect(LRChecksum($TWPx-8), $TWPy-9, LRChecksum($TWPx-8)+10, $TWPy+1, 0xFFFFFF, 50) MsgBox($MB_SYSTEMMODAL, "Results ", _ "Window Coords" & @CRLF & _ $TWPx & "(" & $TWPx+1440 & "), " & $TWPy & @CRLF & _ "Checksum0: " & $output0 & @CRLF) GUISetState(@SW_SHOW, $hGUI3) WinActivate($hGUI3, "Capture") Case $hButtonMUp _FOEA_ButtonMUp() Case $hButtonMDown _FOEA_ButtonMDown() Case $hButtonMRight _FOEA_ButtonMRight() Case $hButtonMLeft _FOEA_ButtonMLeft() EndSwitch WEnd Func _FOEA_Loupe($aWinPos) Local $iX, $iY DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 10, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+68, "int", $aWinPos[1]+61, "int", 20, "int", 20, _ "long", $SRCCOPY) DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 130, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+70, "int", $aWinPos[1]+63, "int", 7, "int", 7, _ "long", $SRCCOPY) ; Appears initially - then disappears... Global $Graph1 = GUICtrlCreateGraphic(170, 57, 8, 16, $SS_WHITERECT) Global $Graph2 = GUICtrlCreateGraphic(170, 73, 31, 8, $SS_WHITERECT) Global $Graph3 = GUICtrlCreateGraphic(193, 57, 8, 16, $SS_WHITERECT) Global $Graph4 = GUICtrlCreateGraphic(170, 49, 31, 8, $SS_WHITERECT) ; This apears to be needed to stop the Magnify window moving Global $Graph5 = GUICtrlCreateGraphic(0, 0, 1, 1) ;Tried this too - no difference GUISetState(@SW_SHOW, $Graph1) GUISetState(@SW_SHOW, $Graph2) GUISetState(@SW_SHOW, $Graph3) GUISetState(@SW_SHOW, $Graph4) EndFunc ;==>Loupe Func _FOEA_ButtonMUp() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]-1) EndFunc Func _FOEA_ButtonMDown() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]+1) EndFunc Func _FOEA_ButtonMRight() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]+1, $aWinPos[1]) EndFunc Func _FOEA_ButtonMLeft() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]-1, $aWinPos[1]) EndFunc  
    • By XGamerGuide
      I'm trying to display a GIF. However, the GUI should not be visible. Here is an attempt that doesn't work:
      $sGIF = "MyGIF.gif" #Include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <SendMessage.au3> Global Const $SC_DRAGMOVE = 0xF012 HotKeySet("{ESC}", "_Exit") $hGui = GUICreate("Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 10, 10, 380, 280) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) _IENavigate($oIE, $sGIF) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd Func _Exit() Exit  
    • By kcvinu
      Hi all,
      I am creating a GUI library in Nim with win32 API functions. Even though the syntax is similar to Python, coding is almost similar to C in Nim. 
      I can change the back color of the button in NM_CUSTOMDRAW. But I can't change the button text color. here is my pseudo code.  
      proc setBtnBackColor*(me : Button, lp: LPNMCUSTOMDRAW ) = if lp.uItemState and CDIS_SELECTED : #------------------ btn clicked # Here i am changing the button color with SelectObject & FillRect. elif lp.uItemState and CDIS_HOT : # ----------------Mouse over # Here i am changing the button's mouse hover color with SelectObject & FillRect. else: # -------------------------Default color set # Here i am changing the button's default color with SelectObject & FillRect. # Here i tried---> SetTextColor(lp.hdc, RGB(102, 255, 51) ) #------- But no luck. #------------------------------------------------------------------------- Please guide me. What i am doing wrong here ?  I am returning "CDRF_SKIPDEFAULT" after calling this function.
      Note : I am using subclassed button. So when the parent window receives WM_NOTIFY message, it sends that to my button's WndProc. There i am handling the message.
    • By paw
      I use SetSoundDevice to control my audio devices but the UI was either
       
      blurry like this:
      or unusable like this:

      so I made this horrible thing to add scaling to the GUI:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
      And now it looks good: 
      but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
      because the comment contains a parenthesis and it would break completely if there were variables as parameters..
      Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
×
×
  • Create New...