Jump to content
Sign in to follow this  
Didonet

Problem with script

Recommended Posts

Didonet

Hi all, I'm having a problem with this script. When I run it the "dragging" works, but the context menu didn't...

#NoTrayIcon
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

MouseUp("primary") ; To release Mouse when start /Func Capture()/

$HTCAPTION = 2
$WM_NCLBUTTONDOWN = 0xA1
$title = "Program Title"
$gui = GUICreate($title, 200, 20, -1, -1, $WS_POPUP + $WS_SYSMENU, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Capture")

$contextmenu = GUICtrlCreateContextMenu()
$trans_set = GUICtrlCreateMenu("Transparency", $contextmenu)
$trans_10 = GUICtrlCreateMenuItem("10%", $trans_set)
$trans_20 = GUICtrlCreateMenuItem("20%", $trans_set)
$trans_30 = GUICtrlCreateMenuItem("30%", $trans_set)
$trans_40 = GUICtrlCreateMenuItem("40%", $trans_set)
$trans_50 = GUICtrlCreateMenuItem("50%", $trans_set)
$trans_60 = GUICtrlCreateMenuItem("60%", $trans_set)
$trans_70 = GUICtrlCreateMenuItem("70%", $trans_set)
$trans_80 = GUICtrlCreateMenuItem("80%", $trans_set)
$trans_90 = GUICtrlCreateMenuItem("90%", $trans_set)
$trans_100 = GUICtrlCreateMenuItem("100%", $trans_set)

$exit_item = GUICtrlCreateMenuItem("Exit", $contextmenu)


GUISetState()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $exit_item Or $msg = $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf

    If $msg = $trans_10 Then
        WinSetTrans($title, "", 22)
    EndIf
    
    If $msg = $trans_20 Then
        WinSetTrans($title, "", 44)
    EndIf
    
    If $msg = $trans_30 Then
        WinSetTrans($title, "", 66)
    EndIf
    
    If $msg = $trans_40 Then
        WinSetTrans($title, "", 88)
    EndIf
    
    If $msg = $trans_50 Then
        WinSetTrans($title, "", 110)
    EndIf
    
    If $msg = $trans_60 Then
        WinSetTrans($title, "", 132)
    EndIf
    
    If $msg = $trans_70 Then
        WinSetTrans($title, "", 154)
    EndIf
    
    If $msg = $trans_80 Then
        WinSetTrans($title, "", 176)
    EndIf
    
    If $msg = $trans_90 Then
        WinSetTrans($title, "", 198)
    EndIf
    
    If $msg = $trans_100 Then
        WinSetTrans($title, "", 220)
    EndIf
WEnd

Func Capture()
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
EndFunc   ;==>Capture

Share this post


Link to post
Share on other sites
Valuater

Opt("GUIOnEventMode", 1) does not work with GUIGetMsg()

Use one or the other

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Didonet

And how to make this to work? :)

Edited by Didonet

Share this post


Link to post
Share on other sites
Generator

Here..

#NoTrayIcon
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

MouseUp("primary") ; To release Mouse when start /Func Capture()/

$HTCAPTION = 2
$WM_NCLBUTTONDOWN = 0xA1
$title = "Program Title"
$gui = GUICreate($title, 200, 20, -1, -1, $WS_POPUP + $WS_SYSMENU, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Capture")

$contextmenu = GUICtrlCreateContextMenu()
$trans_set = GUICtrlCreateMenu("Transparency", $contextmenu)
$trans_10 = GUICtrlCreateMenuItem("10%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_20 = GUICtrlCreateMenuItem("20%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_30 = GUICtrlCreateMenuItem("30%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_40 = GUICtrlCreateMenuItem("40%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_50 = GUICtrlCreateMenuItem("50%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_60 = GUICtrlCreateMenuItem("60%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_70 = GUICtrlCreateMenuItem("70%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_80 = GUICtrlCreateMenuItem("80%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_90 = GUICtrlCreateMenuItem("90%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$trans_100 = GUICtrlCreateMenuItem("100%", $trans_set)
GUICtrlSetOnEvent(-1, "_Event")
$exit_item = GUICtrlCreateMenuItem("Exit", $contextmenu)
GUICtrlSetOnEvent(-1, "_Event")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Bye")

GUISetState()

While 1
    Sleep(1)
WEnd

Func Capture()
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
EndFunc   ;==>Capture
Func _Event()
    $msg = @GUI_CtrlId
    If $msg = $exit_item Then
        Exit
    EndIf

    If $msg = $trans_10 Then
        WinSetTrans($title, "", 22)
    EndIf

    If $msg = $trans_20 Then
        WinSetTrans($title, "", 44)
    EndIf

    If $msg = $trans_30 Then
        WinSetTrans($title, "", 66)
    EndIf

    If $msg = $trans_40 Then
        WinSetTrans($title, "", 88)
    EndIf

    If $msg = $trans_50 Then
        WinSetTrans($title, "", 110)
    EndIf

    If $msg = $trans_60 Then
        WinSetTrans($title, "", 132)
    EndIf

    If $msg = $trans_70 Then
        WinSetTrans($title, "", 154)
    EndIf

    If $msg = $trans_80 Then
        WinSetTrans($title, "", 176)
    EndIf

    If $msg = $trans_90 Then
        WinSetTrans($title, "", 198)
    EndIf

    If $msg = $trans_100 Then
        WinSetTrans($title, "", 220)
    EndIf
EndFunc   ;==>_Event
Func _Bye()
    Exit
EndFunc   ;==>_Bye

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.