Sign in to follow this  
Followers 0
dantay9

Send Message

5 posts in this topic

#1 ·  Posted (edited)

Here is an excerpt from a script I am making. I got the _SendMessage() function on line 37 from the forum. Why does the line with _SendMessage() only work every other time?

#include <StaticConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "OnAutoItExit")
Global $Hour
CreateClock(0, 0)
Func CreateClock($Left, $Top)
    _GDIPlus_Startup()

    $ClockImage = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Owner\Desktop\Franks Gadget\Graphics\DigitalClock3.png")
    $ImageWidth = _GDIPlus_ImageGetWidth($ClockImage)
    $ImageHeight = _GDIPlus_ImageGetHeight($ClockImage)

    $ClockGUI = GUICreate("DigitalClock2", $ImageWidth, $ImageHeight, $Left, $Top, _
            $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    GUISetState()
    WinSetOnTop($ClockGUI, "", 1)
    SetBitMap($ClockGUI, $ClockImage, 255)

    $ClockControlGUI = GUICreate("ControlGuiDigitalClock2", $ImageWidth - 18, $ImageHeight - 8, $Left + 9, $Top + 4, _
            $WS_POPUP, BitOR($WS_CLIPCHILDREN, $WS_EX_MDICHILD, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $ClockGUI)
    GUISetState()
    GUISetBkColor(0x000000)

    $Time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC, 0, 2, $ImageWidth - 20, $ImageHeight - 8, $SS_CENTER)
    GUICtrlSetFont(-1, 16)
    GUICtrlSetColor(-1, 0x00ff00)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    AdlibEnable("Check_Hour", 1000)
    GUISetState()
    Check_Hour()
    While 1
        If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then
            _SendMessage($ClockGUI, $WM_SYSCOMMAND, 0xF012, 0); SC_DRAGMOVE
        EndIf
        GUICtrlSetData($Time, $Hour & ":" & @MIN & ":" & @SEC)
    WEnd
EndFunc  ;==>CreateClock

Func Check_Hour()
    If @HOUR > 12 Then
        $Hour = @HOUR - 12
    Else
        $Hour = @HOUR
    EndIf
EndFunc  ;==>Check_Hour

Func SetBitmap($hGUI, $hImage, $iOpacity);From Frank's Gadgets
    Local $AC_SRC_ALPHA = 1
    Local $ULW_ALPHA = 2
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc  ;==>SetBitmap

Func OnAutoItExit()
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>OnAutoItExit
Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites



I noted with this simple modification, that the GUI is set to active, then every-other click it is set to inactive, then active, then inactive.

NOTE I do not have your clock pic

#include <StaticConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "OnAutoItExit")
Global $Hour
CreateClock(0, 0)
Func CreateClock($Left, $Top)
    _GDIPlus_Startup()

    $hImageDigitalClock2 = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Owner\Desktop\Franks Gadget\Graphics\DigitalClock3.png")
    $WidthDigitalClock2 = _GDIPlus_ImageGetWidth($hImageDigitalClock2)
    $HeightDigitalClock2 = _GDIPlus_ImageGetHeight($hImageDigitalClock2)

    $GuiDigitalClock2 = GUICreate("DigitalClock2", $WidthDigitalClock2, $HeightDigitalClock2, $Left, $Top, _
            $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    GUISetState()
    WinSetOnTop($GuiDigitalClock2, "", 1)
    SetBitMap($GuiDigitalClock2, $hImageDigitalClock2, 255)

    $ControlGuiDigitalClock2 = GUICreate("ControlGuiDigitalClock2");, $WidthDigitalClock2 - 18, $HeightDigitalClock2 - 8, $Left + 9, $Top + 4, $WS_POPUP, BitOR($WS_CLIPCHILDREN, $WS_EX_MDICHILD, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $GuiDigitalClock2)
    GUISetState()
    GUISetBkColor(0x000000)

    $Time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC, 0, 2, $WidthDigitalClock2 - 20, $HeightDigitalClock2 - 8, $SS_CENTER)
    GUICtrlSetFont(-1, 16)
    GUICtrlSetColor(-1, 0x00ff00)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    AdlibEnable("Check_Hour", 1000)
    GUISetState()
    Check_Hour()
    While 1
        If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then
            ConsoleWrite(" > $GUI_EVENT_PRIMARYDOWN " & @CRLF)
            _SendMessage($GuiDigitalClock2, $WM_SYSCOMMAND, 0xF012, 0)
        EndIf
        GUICtrlSetData($Time, $Hour & ":" & @MIN & ":" & @SEC)
        Sleep(5)
    WEnd
EndFunc  ;==>CreateClock

Func Check_Hour()
    If @HOUR > 12 Then
        $Hour = @HOUR - 12
    Else
        $Hour = @HOUR
    EndIf
EndFunc  ;==>Check_Hour

Func SetBitmap($hGUI, $hImage, $iOpacity);From Frank's Gadgets
    Local $AC_SRC_ALPHA = 1
    Local $ULW_ALPHA = 2
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc  ;==>SetBitmap

Func OnAutoItExit()
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>OnAutoItExit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Nevermind. The problem was I was using the wrong window with the _SendMessage Function. The way I was doing it, I could only drag using the outer rim.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Nevermind. ....

The results I posted wasn't helpful?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No, I think I found the problem and was posting while you were posting yours. Sorry. Here's the fixed code:

#include <StaticConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "OnAutoItExit")
Global $Hour
CreateClock(0, 0)
Func CreateClock($Left, $Top)
    _GDIPlus_Startup()

    $ClockImage = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Owner\Desktop\Franks Gadget\Graphics\DigitalClock3.png")
    $ImageWidth = _GDIPlus_ImageGetWidth($ClockImage)
    $ImageHeight = _GDIPlus_ImageGetHeight($ClockImage)

    $ClockGUI = GUICreate("DigitalClock2", $ImageWidth, $ImageHeight, $Left, $Top, _
            $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
    GUISetState()
    WinSetOnTop($ClockGUI, "", 1)
    SetBitMap($ClockGUI, $ClockImage, 255)

    $ClockControlGUI = GUICreate("ControlGuiDigitalClock2", $ImageWidth - 18, $ImageHeight - 8, $Left + 9, $Top + 4, _
            $WS_POPUP, BitOR($WS_CLIPCHILDREN, $WS_EX_MDICHILD, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $ClockGUI)
    GUISetState()
    GUISetBkColor(0x000000)

    $Time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC, 0, 2, $ImageWidth - 20, $ImageHeight - 8, $SS_CENTER)
    GUICtrlSetFont(-1, 16)
    GUICtrlSetColor(-1, 0x00ff00)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUISetState()
    AdlibEnable("Check_Hour", 1000)
    Check_Hour()
    WinActivate($ClockGUI)
    While 1
        If GUIGetMsg() = $GUI_EVENT_PRIMARYDOWN Then
            _SendMessage($ClockGUI, $WM_SYSCOMMAND, 0xF012, 0); SC_DRAGMOVE
            WinActivate($ClockControlGUI)
        EndIf
        GUICtrlSetData($Time, $Hour & ":" & @MIN & ":" & @SEC)
    WEnd
EndFunc  ;==>CreateClock

Func Check_Hour()
    If @HOUR > 12 Then
        $Hour = @HOUR - 12
    Else
        $Hour = @HOUR
    EndIf
EndFunc  ;==>Check_Hour

Func SetBitmap($hGUI, $hImage, $iOpacity);From Frank's Gadgets
    Local $AC_SRC_ALPHA = 1
    Local $ULW_ALPHA = 2
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc  ;==>SetBitmap

Func OnAutoItExit()
    _GDIPlus_Shutdown()
    Exit
EndFunc  ;==>OnAutoItExit
Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

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