Jump to content

Something to do with time...


Recommended Posts

If you've used Windows Live Messenger then you know it limits the nudges you can send, I'm making something similar and I want to limit it to run also once in 10 seconds...I can't seem to be able to do it though :/

Func Nudge()
    $Windowmove = 0
    $Windowcoord = WinGetPos (@GUI_WINHANDLE, "")
    If _Timer_Diff($Nudgetime) > 10000 Then
        For $Windowmove = 1 to 15
            WinMove(@GUI_WINHANDLE, "", $Windowcoord[0]-1, $Windowcoord[1]-1, Default, Default,100)
            WinMove(@GUI_WINHANDLE, "", $Windowcoord[0], $Windowcoord[1], Default, Default,100)
        Next
        $Nudgetime = _Timer_Init()
    Else
        MsgBox(0,"Don't nudge so often","You can only nudge once every 10 seconds")
    EndIf
EndFunc

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

I thought I couldn't do it but here it is:

#include <GUIConstantsEx.au3>
#include <Timers.au3>

$firstnudge = 1
$Nudgetime = 0

#region - GUI Create
$hWnd = GUICreate('test')
$button = GUICtrlCreateButton('Nudge', 1, 1)
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button
            Nudge()
    EndSelect
WEnd
#endregion


Func Nudge()
    $firstnudge = 0
    $Windowmove = 0
    $Windowcoord = WinGetPos ($hWnd, "")
    If $firstnudge = 1 OR _Timer_Diff($Nudgetime) > 10000 Then
        For $Windowmove = 1 to 15
            WinMove($hWnd, "", $Windowcoord[0]-1, $Windowcoord[1]-1, Default, Default,100)
            WinMove($hWnd, "", $Windowcoord[0], $Windowcoord[1], Default, Default,100)
        Next
        $Nudgetime = _Timer_Init()
    Else
        MsgBox(0,"Don't nudge so often","You can only nudge once every 10 seconds")
    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...