Jump to content

Gui_less Button?


fmen
 Share

Recommended Posts

Yes, I am new. I looked at the help file. I searched the forum.

Can I use Autoit to make a button with an assigned function without a surrounding Gui (or invisible gui?) that I can place anywhere on my desktop and remain on top?

Thanks for any suggestions.

Link to comment
Share on other sites

#include <GUIConstants.au3>
HotKeySet("{ESC}", "_Exit")
GUICreate("My GUI", 100, 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
$btn = GuiCtrlCreateButton("Click Me!", -1, -1, 100, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $btn
        MsgBox(0, "", "Clicked!")
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func _Exit()
    Exit
EndFunc

You'll need to set the position of the GUI to be where you want it to be ... It's currently in the upper left hand corner of the screen.

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

Wow...Fabulous...and fast. I am very impressed and very grateful, Sykes! Just what I was looking for. I hope it helped others. Being able to add functional buttons to other programs like browsers, editors etc is awesome. Thanks.

Link to comment
Share on other sites

Being able to add functional buttons to other programs like browsers, editors etc  is awesome. Thanks.

<{POST_SNAPBACK}>

That's exactly what ANYGUI.au3 is for (click link in my signature to download)
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

That's exactly what ANYGUI.au3 is for (click link in my signature to download)

<{POST_SNAPBACK}>

Hey thanks..this is like Christmas. Not to be greedy, but have you written a doc file for it to explain how it is used? I tried running it and an error popped up at line 332

$a(0)=^

Link to comment
Share on other sites

Sorry to be such a pest, but I have two more questions:

1. I downloaded the latest beta of AutoIt but Anygui.au3 still returns an error. I did a search for anygui.au3 but found nothing. Any information would be appreciated.

2.I've worked on the gui-less button that was generously contributed by sykes and have it optimized to exactly how I want it. It sits on my browser window and I have attached several functions to it. I even got it to close when the browser closes and to make it invisble when the browser is minimzed or not active.

What would be a nice touch is to make it invisible on the task bar when it is running to reduce clutter. I know how to hide it in the system tray but is there a way of eliminating it from the task bar.

Thanks in advance.

In case anyone would like to see a generic version that sits on Notepad....

Opt("SendKeyDelay", 0)

Opt("WinTitleMatchMode", 2)

Opt("TrayIconHide", 1)

#include <GUIConstants.au3>

GUICreate("My GUI", 100, 20, 516, 137, $WS_POPUP, $WS_EX_TOPMOST)

$btn = GuiCtrlCreateButton("Click Me!", -1, -1, 100, 20)

$btncontext = GUICtrlCreateContextMenu($btn)

$btnexit = GUICtrlCreateMenuitem("Exit",$btncontext)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $btn

run ( 'notepad.exe' )

EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $btnexit Then Exit

$state = WinGetState("Notepad", "")

If BitAnd($state, 16) Then

GUISetState(@SW_HIDE)

ElseIf BitAnd($state, 2) Then

GUISetState(@SW_SHOW)

ElseIf Not WinExists ('Notepad') Then

Exit

EndIf

Wend

Func _Exit()

Exit

EndFunc

Link to comment
Share on other sites

sorry i haven't finished with actual doc's for ANYGUI.au3

Hopefully this will help:

#include <ANYGUI.au3>
#include <guiconstants.au3>
Run("notepad.exe")
Sleep(1000)
WinSetState("Untitled - Notepad", "", @SW_MAXIMIZE)
$Targetwindow = _GuiTarget ("Untitled - Notepad", 1); mode 1 set so all '_Targetadd(s) go to this window
$TargetControl = _GuiTarget ("Untitled - Notepad", "", 15); gets hWnd of EDIT1 control(note Mode is not 1, so this returns a Local Variable
ControlMove($Targetwindow, "", 15, 0, 0, 800, 500);resize Edit1 control so everything fits
$btn1 = _TargetaddButton ( "Button1", 30, 550, 100, 50);
GUISetState(@SW_SHOW);
$btn2 = _TargetaddButton ( "Button2", 150, 550, 100, 50);
GUISetState(@SW_SHOW);
$Child = _TargetaddChild ("Test", 810, 0, 205, 500);
GUISetBkColor(0xff000);
$label1 = GUICtrlCreateLabel("Child Window", 60, 0, 100, 30)
$btn3 = GUICtrlCreateButton("Button3", 52, 35, 100, 50);
$grp1 = GUICtrlCreateGroup("Testing", 20, 90, 165, 200);
$radio1 = GUICtrlCreateRadio("A", 95, 120);
$radio2 = GUICtrlCreateRadio("B", 95, 180);
$radio3 = GUICtrlCreateRadio("C", 95, 240);
$Date = GUICtrlCreateDate("My Calender", 20, 300, 165, 180);
GUISetState(@SW_SHOW);
$tab = _TargetaddTab (300, 500, 715, 210);
$tab1 = GUICtrlCreateTabItem("First");
$btn4 = GUICtrlCreateButton("Tab-First", 20, 30)
$tab2 = GUICtrlCreateTabItem("Second");
$tab3 = GUICtrlCreateTabItem("Third");
GUISetState(@SW_SHOW)
While WinExists($Targetwindow)
   $msg = GUIGetMsg(1)
   If $msg[0] = $GUI_EVENT_CLOSE Then Exit
   If Not WinExists($Targetwindow) Then Exit
   Sleep(50)
WEnd
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

If you wish to hide an app from the task bar, use $WS_EX_TOOLWINDOW style:

opt("SendKeyDelay", 0)
opt("WinTitleMatchMode", 2)
opt("TrayIconHide", 1)

#include <GUIConstants.au3>

GUICreate("My GUI", 100, 20, 516, 137, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))


$btn = GUICtrlCreateButton("Click Me!", -1, -1, 100, 20)
$btncontext = GUICtrlCreateContextMenu($btn)
$btnexit = GUICtrlCreateMenuItem("Exit", $btncontext)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            Run('notepad.exe')
            WinWaitActive("Notepad")
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $btnexit
            Exit
    EndSelect
    
    
    $state = WinGetState("Notepad", "")
    
;~     If BitAND($state, 16) Then
;~         GUISetState(@SW_HIDE)
;~     ElseIf BitAND($state, 2) Then
;~         GUISetState(@SW_SHOW)
;~     ElseIf Not WinExists('Notepad') Then
;~         Exit
;~     EndIf
    
WEnd

Func _Exit()
    Exit
EndFunc  ;==>_Exit

Edit: sorry i changed it around a little to get it to work for me

Edited by steveR
AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
Link to comment
Share on other sites

Thanks so much for the "$WS_EX_TOOLWINDOW" tip SteveR, it works as advertised. As a newb, I appreciate the hand holding, perhaps some day I will be able to contribute to the forum in a more substantial way.

quaizywabbit. I am looking forward to your anygui doc. I am checking it out with the snippet that you posted. Thanks.

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