Jump to content

How to do it?


Recommended Posts

How to GUICtrlSetData($Label1,GUICtrlRead($Label1)+1) by scrolling MouseWheel? (UP: -1 | Down: +1)

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Example", 269, 118, 451, 501)
$Label1 = GUICtrlCreateLabel("100", 80, 40, 101, 28, $SS_CENTER)
GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

And how to:

If Single Click on TrayIcon then
        msgbox(0,"","Single click")
ElseIf Double Click on TrayIcon then
        msgbox(0,"","Double click")
EndIf

(it's for simplicity of understanding)

Edited by Vitas

_____________________________________________________________________________

Link to comment
Share on other sites

This ones straight from the help file:

#include <Constants.au3>
#NoTrayIcon

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitEvent")

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"SpecialEvent")
TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"SpecialEvent")

TraySetState()

While 1
    Sleep(10)   ; Idle loop
WEnd

Exit


; Functions
Func SpecialEvent()
    Select
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE
            Msgbox(64,"SpecialEvent-Info","Primary mouse button double clicked.")
        Case @TRAY_ID = $TRAY_EVENT_SECONDARYUP
            Msgbox(64,"SpecialEvent-Info","Secondary mouse button clicked.")
    EndSelect
EndFunc


Func ExitEvent()
    Exit
EndFunc

or search traysetonevent in the help file

Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

This ones straight from the help file:

- Yes, I seen it, and modify to this:

#include <Constants.au3>
#NoTrayIcon

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitEvent")

TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"SpecialEvent")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN,"SpecialEvent")
TraySetClick (16)
TraySetState()

While 1
    Sleep(10)   ; Idle loop
WEnd

Exit

Func ExitEvent()
    Exit
EndFunc


Func SpecialEvent()
    Select
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE
            MsgBox(0,"","double")
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOWN
            MsgBox(0,"","single")
    EndSelect
EndFunc

When you double click in tray, you will see MsgBox(0,"","single") and then MsgBox(0,"","double"). How to divide it??

Edited by Vitas

_____________________________________________________________________________

Link to comment
Share on other sites

  • 2 weeks later...

Func SpecialEvent()
    Select
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE
            AdlibDisable()
            MsgBox(0,"","double")
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOWN
            AdlibEnable('_Adlib', 150)
    EndSelect
EndFunc
    
Func _Adlib()
    AdlibDisable()
    MsgBox(0, "", "single")
EndFunc

You can call GetDoubleClickTime to determine the interval in ms that a click event should be considered a single click.

Link to comment
Share on other sites

Authenticity, it works, but if you click once, and then when you seen MsgBox("Single"), quickly clicks once again, you will see MsgBox("Double"), that's why code must be looks like this:

Glogal $adlib = False
Func SpecialEvent()
    Select
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOUBLE
            If $adlib = True Then
                AdlibDisable()
                ConsoleWrite("Double!" & @CR)
            EndIf
        Case @TRAY_ID = $TRAY_EVENT_PRIMARYDOWN
            $adlib = True
            AdlibEnable('_Adlib', 150)
    EndSelect
EndFunc

Func _Adlib()
    AdlibDisable()
    ConsoleWrite("Single" & @CR)
    $adlib = False
EndFunc

Thanks to all!

Edited by Vitas

_____________________________________________________________________________

Link to comment
Share on other sites

  • 4 weeks later...

Two qustions:

- How to get WinList?

(not of all - only such as you press ALT-TAB)

- How to shutdown PC if there are no-saved documents?

(without WinGetTitle, sending CTRL-S to each window, - just ignore all messages and terminate machine)

thanks.

_____________________________________________________________________________

Link to comment
Share on other sites

Two qustions:

- How to get WinList?

(not of all - only such as you press ALT-TAB)

Straight from help file, includes _IsVisible check. Enjoy.

$var = WinList()

For $i = 1 to $var[0][0]
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
  EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

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