Jump to content

Recommended Posts

  • Moderators
Posted

This is an example of using the desktop as the GUI, but you could just create a transparent GUI and use these target ideas (originally from anygui.au3, I've posted it before somewhere).

#include <GUIConstants.au3>
;Functions used from AnyGUI v2.6 by Quaizywabbit


$DeskTop = ControlGetHandle('Program Manager', 'FolderView', 'SysListView321')
$C1 = _TargetaddCombo('', @DesktopWidth - 155, 65, 135, 20, Default, Default, $DeskTop)
GUICtrlSetData($C1[0], "It|is|possible|to|create|that|type|of|GUI")
GUISetState()
$B1 = _TargetaddButton("Example 1", @DesktopWidth - 80, 100, 60, 30, -1, -1, $DeskTop)
GUISetState()
$B2 = _TargetaddButton("Example 2", @DesktopWidth - 150, 100, 60, 30, -1, -1, $DeskTop)
GUISetState()

While WinExists($DeskTop)
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $B1[0]
            MsgBox(0, 'Example', 'This is just an example')
        Case $msg[0] = $B2[0]
            If MsgBox(4, 'Exit?', 'Would you like to exit?') = 6 Then Exit
    EndSelect
    Sleep(5)
WEnd

Func _TargetaddChild($text, $PosX, $PosY, $SizeX, $SizeY, $LocTargethWnd = 0);
    If not ($LocTargethWnd = 0) Then $TargethWnd = $LocTargethWnd
    Local $a = GUICreate($text, $SizeX, $SizeY, $PosX, $PosY, $WS_CHILD, -1, $TargethWnd)
    If $a = 0 Then SetError(1)
    Return $a
EndFunc   ;==>_TargetaddChild

Func _TargetaddCombo($text, $PosX, $PosY, $SizeX, $SizeY, $style = -1, $exstyle = -1, $LocTargethWnd = 0)
    If not ($LocTargethWnd = 0) Then $TargethWnd = $LocTargethWnd
    Local $a[3]
    $a[2] = _TargetaddChild($text, $PosX, $PosY, $SizeX, $SizeY, $TargethWnd)
    $a[0] = GUICtrlCreateCombo($text, 0, 0, $SizeX, $SizeY, $style, $exstyle)
    $a[1] = ControlGetHandle($a[2], "", $a[0])
    If $a[2] = 0 Or $a[0] = 0 Or $a[1] = "" Then
        SetError(1)
        Return 0
    Else
        Return $a
    EndIf
EndFunc   ;==>_TargetaddCombo

Func _TargetaddButton($text, $PosX, $PosY, $SizeX, $SizeY, $style = -1, $exstyle = -1, $LocTargethWnd = 0)
    If not ($LocTargethWnd = 0) Then $TargethWnd = $LocTargethWnd
    Local $a[3]
    $a[2] = _TargetaddChild($text, $PosX, $PosY, $SizeX, $SizeY, $TargethWnd)
    $a[0] = GUICtrlCreateButton($text, 0, 0, $SizeX, $SizeY, $style, $exstyle)
    $a[1] = ControlGetHandle($a[2], "", $a[0])
    If $a[2] = 0 Or $a[0] = 0 Or $a[1] = "" Then
        SetError(1)
        Return 0
    Else
        Return $a
    EndIf
EndFunc   ;==>_TargetaddButton

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Try this:

#include <GuiConstants.au3>

$Main_Gui = GUICreate("", 400, 400, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)

$But1 = GUICtrlCreateButton("Exit", 100, 100, 80, 21)
$But2 = GUICtrlCreateButton("Floating button", 100, 140, 120, 21)

GUISetControlsVisible($Main_Gui)

GUISetState()

While 1
    If GUIGetMsg() = $But1 Then Exit
WEnd

Func GUISetControlsVisible($hWnd)
    Local $aClassList, $aM_Mask, $aCtrlPos, $aMask
    
    ;Set $WS_POPUP style part:
    Local Const $GWL_STYLE = -16
    Local Const $GWL_EXSTYLE = -20
    Local Const $SWP_NOMOVE = 0x2
    Local Const $SWP_NOSIZE = 0x1
    Local Const $SWP_SHOWWINDOW = 0x40
    Local Const $SWP_NOZORDER = 0x4
    
    Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $WS_POPUP)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", $iFlags)
    ;End Set $WS_POPUP style part
    
    $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF)
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    
    For $i = 1 To UBound($aClassList) - 1
        $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$i])
        If Not IsArray($aCtrlPos) Then ContinueLoop
        
        $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _
            "long", $aCtrlPos[0], _
            "long", $aCtrlPos[1], _
            "long", $aCtrlPos[0] + $aCtrlPos[2], _
            "long", $aCtrlPos[1] + $aCtrlPos[3])
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1)
EndFunc

Func _WinGetClassListEx($sTitle)
    Local $sClassList = WinGetClassList($sTitle)
    Local $aClassList = StringSplit($sClassList, @LF)
    Local $sRetClassList = "", $sHold_List = "|"
    Local $aiInHold, $iInHold
    
    For $i = 1 To UBound($aClassList) - 1
        If $aClassList[$i] = "" Then ContinueLoop
        
        If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then
            $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1)
            $iInHold = Number($aiInHold[UBound($aiInHold)-1])
            
            If $iInHold = 0 Then $iInHold += 1
            
            $aClassList[$i] &= "~" & $iInHold + 1
            $sHold_List &= $aClassList[$i] & "|"
            
            $sRetClassList &= $aClassList[$i] & @LF
        Else
            $aClassList[$i] &= "~1"
            $sHold_List &= $aClassList[$i] & "|"
            $sRetClassList &= $aClassList[$i] & @LF
        EndIf
    Next
    
    Return StringReplace(StringStripWS($sRetClassList, 3), "~", "")
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

This is my favorite thing ever. Create controls and call that function.

#include <GuiConstants.au3>
#NoTrayIcon
HotKeySet("{ESC}", "QuitApp")

$Form1 = GUICreate("Form1", 407, 63, 305, 302, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$Input1 = GUICtrlCreateInput("", 8, 8, 200, 21)
$Button1 = GUICtrlCreateButton("Lock", 100, 40, 89, 17, 0)
GUISetControlsVisible($Form1)
GUISetState()

While 1
    If GUIGetMsg() = $Button1 Then Exit
WEnd

Func GUISetControlsVisible($hWnd)
    Local $aClassList, $aM_Mask, $aCtrlPos, $aMask
    
    $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF)
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    
    For $i = 1 To UBound($aClassList) - 1
        $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$i])
        If Not IsArray($aCtrlPos) Then ContinueLoop
        
        $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _
            "long", $aCtrlPos[0], _
            "long", $aCtrlPos[1], _
            "long", $aCtrlPos[0] + $aCtrlPos[2], _
            "long", $aCtrlPos[1] + $aCtrlPos[3])
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1)
EndFunc

Func _WinGetClassListEx($sTitle)
    Local $sClassList = WinGetClassList($sTitle)
    Local $aClassList = StringSplit($sClassList, @LF)
    Local $sRetClassList = "", $sHold_List = "|"
    Local $aiInHold, $iInHold
    
    For $i = 1 To UBound($aClassList) - 1
        If $aClassList[$i] = "" Then ContinueLoop
        
        If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then
            $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1)
            $iInHold = Number($aiInHold[UBound($aiInHold)-1])
            
            If $iInHold = 0 Then $iInHold += 1
            
            $aClassList[$i] &= "~" & $iInHold + 1
            $sHold_List &= $aClassList[$i] & "|"
            
            $sRetClassList &= $aClassList[$i] & @LF
        Else
            $aClassList[$i] &= "~1"
            $sHold_List &= $aClassList[$i] & "|"
            $sRetClassList &= $aClassList[$i] & @LF
        EndIf
    Next
    
    Return StringReplace(StringStripWS($sRetClassList, 3), "~", "")
EndFunc

Func QuitApp()
    Exit
EndFunc
  • Moderators
Posted

_WinGetClassListEx

The code looks strangely familiar... did you mod this off of one of my udf's?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

_WinGetClassListEx

The code looks strangely familiar... did you mod this off of one of my udf's?

Haha! I don't know! I got it from MsCreatoR I think, and now use it alot! :)

Posted

Thanks all, here's my transparent GUI using MrCreatoR's functions.

Use F10 to move around and ESC to exit.

#include <GuiConstants.au3>
#include <GUITransparent.au3>

HotKeySet("{F10}", "ToggleVisibility")
HotKeySet("{ESC}", "ExitGUI")

$w1_title  = "xxx";title does not matter
$w1_width  = 399;width of main GUI
$w1_height = 187;height of main GUI
$w2_title  = "yyy";title does not matter
$w2_width  = 50 ;width of "show main GUI" GUI
$w2_height = 30 ;height of "show main GUI" GUI
$w2_left   = @DesktopWidth  - 60;left of "show main GUI" GUI
$w2_top = @DesktopHeight - 70;top of "show main GUI" GUI

Opt("GUIOnEventMode", 1);set on event mode
$mouse = MouseGetPos()  ;get mouse coordinate

;draw main GUI
$Main_Gui = GUICreate("xxx", $w1_width, $w1_height, $mouse[0]-($w1_width/2), $mouse[1]-($w1_height/2), $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$Button1 = GUICtrlCreateButton("Button1", 4, 60, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 84, 32, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Button3", 164, 4, 75, 25, 0)
$Button4 = GUICtrlCreateButton("Button4", 244, 32, 75, 25, 0)
$Button5 = GUICtrlCreateButton("Button5", 320, 60, 75, 25, 0)
$Button6 = GUICtrlCreateButton("Button6", 320, 100, 75, 25, 0)
$Button7 = GUICtrlCreateButton("Button7", 244, 128, 75, 25, 0)
$Button8 = GUICtrlCreateButton("Button8", 164, 156, 75, 25, 0)
$Button9 = GUICtrlCreateButton("Button9", 84, 128, 75, 25, 0)
$Button10 = GUICtrlCreateButton("Button10", 4, 100, 75, 25, 0)
$Button11 = GUICtrlCreateButton("Hide", 164, 80, 75, 25, 0)
    GUICtrlSetOnEvent(-1, "HideGUI")
GUISetControlsVisible($Main_Gui)
GUISetState(@SW_SHOW, $Main_Gui)

;draw secondary GUI
$GUI2 = GUICreate("yyy", $w2_width, $w2_height, $w2_left, $w2_top, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$Button12 = GUICtrlCreateButton("Show", 0, 0, 40, 25, 0)
    GUICtrlSetOnEvent(-1, "ShowGUI")
    GUICtrlSetBkColor(-1, 0x0000FF)
    GUICtrlSetColor(-1, 0xFF0000)
GUISetControlsVisible($GUI2)
GUISetState(@SW_HIDE, $GUI2)

;infinite loop
While 1
    Sleep(100)
WEnd

;exit
Exit

;Hides main GUI and shows secondary GUI
Func HideGUI()
    GUISetState(@SW_HIDE, $Main_Gui)
    GUISetState(@SW_SHOW, $GUI2)
EndFunc

;Shows main GUI and hides secondary GUI
Func ShowGUI()
    GUISetState(@SW_SHOW, $Main_Gui)
    GUISetState(@SW_HIDE, $GUI2)
EndFunc

;Exits everything
Func ExitGUI()
    Exit
EndFunc

;Move main window according to mouse coordinate
Func ToggleVisibility()
    $mouse = MouseGetPos()
    WinMove($w1_title, "", $mouse[0]-($w1_width/2), $mouse[1]-($w1_height/2))
EndFunc
Posted

sensalim

Can I use these functions anywhere?

Sure, otherwise that code wasn't been here in the first place :party:

_WinGetClassListEx

The code looks strangely familiar... did you mod this off of one of my udf's?

Afair nope, i wrote it from scratch (maybe just the concept was from my memory, and the memory of course could be "remembered" from some of the similar udfs :) ), i even spent a whole hour on it :)

I know i searched for such function, but i didn't find anything that might help (to get class list wich is fully numerated).

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • Moderators
Posted

sensalim

Sure, otherwise that code wasn't been here in the first place :party:

Afair nope, i wrote it from scratch (maybe just the concept was from my memory, and the memory of course could be "remembered" from some of the similar udfs :) ), i even spent a whole hour on it :)

I know i searched for such function, but i didn't find anything that might help (to get class list wich is fully numerated).

http://www.autoitscript.com/forum/index.ph...c=32781&hl=

Just thought it weird the local var(s) were the same as well as the concept :lmao: ... but good job.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

  • 3 weeks later...
Posted

This may sound silly, but make a 1x1 bitmap in Paint, with just a dot with the color #FF00FF. Save it to the script folder then try this:

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

$gui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xFF00FF)
$a = GUICtrlCreatePic(@ScriptDir & "\dot.bmp", 0, 0, 1, 1)

$but1 = GUICtrlCreateButton("Exit", 100, 100, 100, 21)
$but2 = GUICtrlCreateButton("Some button", 100, 200, 100, 21)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    select
        case $msg = $but1
            Exit
        case $msg = $but2
            msgbox(0, "", "Some random box")
    endselect
WEnd

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.
×
×
  • Create New...