Jump to content
DoofGore

GUI Stay on Top ON OFF Button

Recommended Posts

DoofGore

Hello All, My first post I know this is pretty noobish but I'm trying to find a way to make this gui working.. searched but as I'm new to autoit I don't understand much... 

I want to make this gui on top if we press ON TOP button and off on top function when we press on top off.. Created gui with koda ... any help would be appreciated 

Regards,

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 353, 209, 192, 114)
Global $ONTOPON = GUICtrlCreateButton("ON TOP ON", 32, 40, 137, 65)
Global $exit = GUICtrlCreateButton("EXIT", 105, 118, 137, 65)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $ONTOPOFF = GUICtrlCreateButton("ON TOP OFF", 184, 41, 137, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $ONTOPON

        Case $ONTOPOFF

        Case $exit
            Exit


    EndSwitch
WEnd

 

ontop.jpg

Share this post


Link to post
Share on other sites
Melba23

DoofGore,

WinSetOnTop should be the solution for which you are looking.

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

 

Share this post


Link to post
Share on other sites
DoofGore

Hello Melba23 I am playing around with WinSetOnTop but i didn't really understand it... it would be great if someone just explain how this is gona work.. Sorry for this noobish post..

Share this post


Link to post
Share on other sites
DoofGore
1 minute ago, JLogan3o13 said:

@DoofGore Did you read the help file entry for WinSetOnTop? It explains what it does pretty simply. Where exactly are you confused?

I am confused how to write this function to set the gui on top on button click : Can you please provide some examples? So I can learn it how to make this function work.. Thanks

Share this post


Link to post
Share on other sites
Bilgus

UH there is an example in the helpfile?

https://www.autoitscript.com/autoit3/docs/functions/WinSetOnTop.htm

;Example
#include <AutoItConstants.au3>

Example()

Func Example()
    ; Retrieve the handle of the active window.
    Local $hWnd = WinGetHandle("[ACTIVE]")

    ; Set the active window as being ontop using the handle returned by WinGetHandle.
    WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)

    ; Wait for 2 seconds to display the change.
    Sleep(2000)

    ; Remove the "topmost" state from the active window.
    WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
EndFunc   ;==>Example
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 353, 209, 192, 114)
Global $ONTOPON = GUICtrlCreateButton("ON TOP ON", 32, 40, 137, 65)
Global $exit = GUICtrlCreateButton("EXIT", 105, 118, 137, 65)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $ONTOPOFF = GUICtrlCreateButton("ON TOP OFF", 184, 41, 137, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $ONTOPON
            Example($Form1, True)
        Case $ONTOPOFF
            Example($Form1, False)
        Case $exit
            Exit


    EndSwitch
WEnd


Func Example($hWnd, $bTrue)
    
    If Not IsHwnd($hWnd) Then Msgbox(0,"Error" "Invalid hWnd")
    If $bTrue Then
        ; Set the active window as being ontop using the handle YOU supply.
        WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
    Else
        ; Remove the "topmost" state from the handle YOU supply.
        WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
    EndIF
EndFunc   ;==>Example
#include <AutoItConstants.au3>
    
    If Not IsHwnd($hWnd) Then Msgbox(0,"Error", "Invalid hWnd")

 

Edited by Bilgus
Couple Errors..
  • Thanks 1

Share this post


Link to post
Share on other sites
DoofGore

@Bilgus Thank you so much .... This is what i was asking for .. will give it a try now... 

Share this post


Link to post
Share on other sites
DoofGore

Made Some changes and its working..  Thank you so much ... :) 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 353, 209, 192, 114)
Global $ONTOPON = GUICtrlCreateButton("ON TOP ON", 32, 40, 137, 65)
Global $exit = GUICtrlCreateButton("EXIT", 105, 118, 137, 65)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $ONTOPOFF = GUICtrlCreateButton("ON TOP OFF", 184, 41, 137, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $ONTOPON
            Example($Form1, True)
        Case $ONTOPOFF
            Example($Form1, False)
        Case $exit
            Exit


    EndSwitch
WEnd


Func Example($Form1, $bTrue)
    ; Retrieve the handle of the active window.
    Local $hWnd = WinGetHandle("[ACTIVE]")
    If $bTrue Then
        ; Set the active window as being ontop using the handle returned by WinGetHandle.
        WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)
    Else
        ; Wait for 2 seconds to display the change.
        Sleep(2000)

        ; Remove the "topmost" state from the active window.
        WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
    EndIf
EndFunc   ;==>Example

 

Edited by DoofGore

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

  • Similar Content

    • Blueman
      By Blueman
      Hey Guys,
      Maybe you can help me with something small.
      It is not terrible but it slows down my script and after a while even crash the script.

      First i explain what i have;
      I have a GUI with a lot of GUICtrlCreateInput controls, lets say 600 pieces.
      All the controls are hidden when the GUI is displayed, i have 3 buttons attached to 200 pieces each.
      When i press button-1 the first 200 controls are showed,
      When i press button-2 the first 200 controls are hidden and the next 200 controls are showed,
      etc, etc.
      This is working perfectly but after a while the GUI is getting slower and slower.
      After a while the controls aren't responding anymore and the script crashes.
      When i compile the script to 64-Bits version the speed is a lot better but you can still see the script slowing down each time i use the buttons.
      I think there has to be a buffer somewhere that is filling each time i show and hide the controls, but how can i clear that buffer without restarting the script?
      Deleting and re-creating the controls didn't help, deleting the entire gui (and controls) and re-creating it didn't help also.
      The only thing that is working is restarting the script.

      Thanks guys!

      PS: If you need a working example i can add it to this topic, just let me know. It is not rocket science, i just create the controls and show/hide them with a while loop and 3 buttons.
       
    • TheDcoder
      By TheDcoder

      ProxAllium
      ProxAllium is a GUI frontend to Tor, it aims to make the usage of Tor easier by directly exposing its SOCK5 proxy which can be used to access the Tor network. The GUI is designed to be simple and user-friendly and it has a few other features... namely:
      Fully portable - doesn't write outside its own directory Integrated with Tor via the controller interface and properly communicates with it Minimize to tray Option to start with Windows Interface to configure bridges if Tor is censored in your region Many customization options are available via the config.ini file Screenshots:
      The code is made with pure AutoIt, is fully open source and you are free to adapt it to your needs
      The GitHub repository hosts all the releases and code. As a bonus it has a somewhat sparsely documented Tor UDF which can be used to control Tor, the code also demonstrates the proper usage of my Process UDF which might be interesting if you want to deal with processes.
       
      As some of my friends know, I no longer use Windows as my main operating system. I switched to Linux a few months back as my primary operating system and haven't looked back since. Unfortunately that meant I could no longer use my own program due to it being Windows only... after a few months of playing around with C and making a basic program, I have decided to rewrite all of ProxAllium into C and make it cross-platform. Sadly this means that the AutoIt version of ProxAllium will not receive any major updates now.
      Let me know if this is something you guys would use, I used it daily with my IRC client to connect via Tor (to protect my I.P). I hope you enjoy using my program!
    • morion84
      By morion84
      Hi, when I call a MsgBox function I can use a "$MB_SERVICE_NOTIFICATION" flag so it will be displayed "on the current active desktop, even if there is no user logged on to the computer.". That works just great. Is there a way to do the same to Autoit GUI Form so it will be visible on desktop even if running from system account and user is not logged?
    • remin
      By remin
      I do have one autoit script file with multiple functions.
      p.e.
       
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <String.au3> #include <GuiButton.au3> #include <Constants.au3> #include <EditConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <HotString.au3> Func ACase() $Form4=GUICreate("ACase", 100, 195, 290, 142) etc etc GUISetState(@SW_SHOW, $Form4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SUB_Write2ini(....) ;I write a few things in an ini file Case $a Case $b etc EndSwitch WEnd EndFunc Func BCase() $Form5=GUICreate("BCase", 100, 195, 290, 142) etc etc GUISetState(@SW_SHOW, $Form5) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SUB_Write2ini(....) ;I write a few things in an ini file Case $a Case $b etc EndSwitch WEnd EndFunc When I activate the 1st function (ACase), using a shortcut and the 2nd function (BCase) (with a different shortcut) and I click on a button in whatever of these 2 Gui's, I can't use the other Gui anymore. It doesn't do the right thing as if autoit only remembers the Gui I first used.
      What did I wrong? How can I let autoit know which GUI is active and to connect to the function of that Gui?
      Hope I made myself clear.
       
    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
×