Sign in to follow this  
Followers 0
Fr33b0w

Toggle GUI On Top with one Button

5 posts in this topic

It has been probably answered somewhere. I did a search and find something similar ('?do=embed' frameborder='0' data-embedContent>>) but that doesnt solve my problem. Have been trough other posts but I couldnt find it. I did look at those but could find nothing...:

Gui On Top On Top Of Windows 7 Start Menu (06 Sep 2013)
Make A Button Visible When Notepad Is Opened (09 Sep 2013)
Turn Off Monitor When Shutdown Button Pressed From Start Menu (10 Sep 2013)
What I Am Doing Wrong (11 Sep 2013)
Winapi Drawshadowtext (16 Sep 2013)
Duplicate Mouse Clicks (17 Sep 2013)
How Can I Create A Custom Shaped Gui Interface (25 Sep 2013)
Set An Array Variable With Unknown Number (24 Sep 2013)
Knowing If A Gui Is Clicked Or Not Im Using Gdiplus To Make A Png Gui Want To Know If Someone Clicks It (27 Sep 2013)
Login Script Check Wordpress Credentials Via Php Function Using Inet (29 Sep 2013)
Console Or Dunno (30 Sep 2013)
Font Change (29 Sep 2013)
Another Exe In My Gui (29 Sep 2013)
How To Use Chat Engine To Get Adresses And Ad Them To My Script (30 Sep 2013)
Script Consumes Too Much Memory Please Help Me Find Where (18 Nov 2013)
Detect Leaving Of Inputbox And Change Listview Item (01 Nov 2013)
Is Posible Create Gui Effects With Autoitobject (18 Nov 2013)
Png Image Design (25 Nov 2013)
Getting Event When File Is Dragged To Input Field (09 Dec 2013)
Wmp Visualization Help (16 Dec 2013)
Remote Computer Command Help (17 Dec 2013)
Edit Autohvscroll (21 Dec 2013)
Trying To Read Url From Chrome Yes Still And Again (12 Jan 2014)
Console Transpert In My Gui (01 Jan 2014)
Problem Drawingdeleting Lines With Gdiplus Graphicsdrawline (07 Jan 2014)
Question Gui Dropaccepted (10 Jan 2014)
Chnaging The Taskbar Clock Format (12 Jan 2014)
Greater Than (16 Jan 2014)
Winsetontop Taking Focus (22 Jan 2014)
Need Help On Creating Dialog Box With Text (18 Jan 2014)
Problem Extracting Folders Icon (19 Jan 2014)
Attaching Element To Existing Gui (24 Jan 2014)
Alternative To Guictrlsetgraphic (23 Jan 2014)

I am trying to get GUI toggle ontop and not ontop. Part of the code I want to put it in is:

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

$hGUI = GUICreate("Toggle Not Working", 171, 699, -1, -1)
GUICtrlSetStyle(-1, $SS_RIGHT)
GUICtrlSetFont(-1, 8.5, 400, 0, "MS Shell Dlg", 5)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlSetStyle(-1, $SS_RIGHT)

$hOntop = GUICtrlCreateButton("", 142, 628, 21, 21)
GUICtrlSetStyle(-1, $BS_ICON)
GUICtrlSetImage(-1, "ontop.ico")
GUISetState()

Select
Case $hMsg = $hButton1
ClipPut(FileReadLine($file,206))
Case $hMsg = $hButton207
ClipPut(FileReadLine($file,207))
Case $hMsg = $hOntop
GUICtrlSetState(-1, $WS_EX_TOPMOST)
EndSelect

I did tried with two buttons but couldnt switch it not to be on top. Because I already posting it would like to see an example with toggle if someone knows (with just one button). Thanks.

Share this post


Link to post
Share on other sites



#include <GUIConstantsEx.au3>
 
$hGUI = GUICreate("Toggle Not Working", 200, 200)
$c_Button_Ontop = GUICtrlCreateButton("Not OnTop", 10, 10, 140, 21)
GUISetState()
 
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $c_Button_Ontop Then _ToogleOnTop()
WEnd
 
Func _ToogleOnTop()
Switch GUICtrlRead($c_Button_Ontop)
Case "Not OnTop"
WinSetOnTop($hGUI,"",1)
GUICtrlSetData($c_Button_Ontop,"OnTop")
Case Else
WinSetOnTop($hGUI,"",0)
GUICtrlSetData($c_Button_Ontop,"Not OnTop")
EndSwitch
EndFunc
1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Fr33b0w,

This works for me: :)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Toggle Working", 171, 699, -1, -1)

GUICtrlSetFont(-1, 8.5, 400, 0, "MS Shell Dlg", 5)
$oIE = ObjCreate("Shell.Explorer.2")

$hOntop = GUICtrlCreateButton("Set On Top", 102, 628, 61, 21)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hOntop
            If GUICtrlRead($hOntop) = "Set On Top" Then
                WinSetOnTop($hGUI, "", 1)
                GUICtrlSetData($hOntop, "Set NOT On Top")
            Else
                WinSetOnTop($hGUI, "", 0)
                GUICtrlSetData($hOntop, "Set On Top")
            EndIf
    EndSwitch
WEnd
M23

Edit: Guten tag, KaFu. Ich war zu langsam heute! :D

Edited by Melba23
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Guys, thank You very much! Both answers work for me. I already put KaFus in a script but Melbas goes without Subfunction...   Which one should I mark as better (solved)?  Dont want to hurt anyones feelings...  Again, many thanks!

Share this post


Link to post
Share on other sites

Function is easier to understand, though I would pass as params.

1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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