Sign in to follow this  
Followers 0
Borje

[ SOLVED ] Need little help from anybody

6 posts in this topic

#1 ·  Posted (edited)

Hello

Is it poosible to change this script to Disconnect and Connect to Internet I have done som tests but can not find a solution to have this outside the loop.

I want when computer is idle that should disconnect from the Internet and when I move the mouse again it would Connect to the Internet again.

Is there any solution to have this _RunDOS("ipconfig /release") ; Disconnect Internet running one time when idle time is up?

and have this _RunDOS("ipconfig /renew") ; Connect to Internet running one time when I move the mouse?

I have done some tests but cannot have this to working ouside the loop.

Please can anybody help me to fix so this working outside the loop?

I can not find any solution.

I have try and try I have much to learn me!!

Code:

#include <Process.au3>

$Idle = 0

$Old = MouseGetPos()

While 1

$Get = MouseGetPos()

If $Get[0] = $Old[0] And $Get[1] = $Old[1] Then

$Idle += 1

Else

$Idle = 0

EndIf

If $Idle <> 0 Then

TrayTip("", "Idle time : " & $Idle & " second.", 1, 16)

Else

TrayTip("", "Hello", 0)

EndIf

$Old = MouseGetPos()

Sleep(1000)

WEnd

;_RunDOS("ipconfig /release") ; Disconnect Internet

;_RunDOS("ipconfig /renew") ; Connect Internet

Edited by Borje

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You try to detect moves of mouse but if I press a key?

This is a good function to get idle time:

Func _Timer_GetIdleTime()
; Get ticks at last activity
    Local $tStruct = DllStructCreate("uint;dword");
    DllStructSetData($tStruct, 1, DllStructGetSize($tStruct));
    DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($tStruct))

; Get current ticks since last restart
    Local $avTicks = DllCall("Kernel32.dll", "int", "GetTickCount")

; Return time since last activity, in ticks (approx milliseconds)
    Local $iDiff = $avTicks[0] - DllStructGetData($tStruct, 2)
    If $iDiff >= 0 Then
  ; Normal return
        Return $iDiff
    Else
  ; Rollover of ticks counter has occured
        Return SetError(0, 1, $avTicks[0])
    EndIf
EndFunc;==>_Timer_GetIdleTime
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks Andrejk, I would like a example to that code I post and I need some example code.

Edited by Borje

Share this post


Link to post
Share on other sites

Is there anybody out there can give me some code example that I ask in my first post what i must do to have that to work outside the loop?

Share this post


Link to post
Share on other sites

Is there anybody out there can give me some code example that I ask in my first post what i must do to have that to work outside the loop?

I think you mean this sort of thing, but I'm not sure.

#include <Process.au3>

$Idle = 0
$Old = MouseGetPos()
$internet = true;assume we start with internet connected
$maxCount = 500;how long to wait before turning off internet connection

While 1
    $Get = MouseGetPos()
    If $Get[0] = $Old[0] And $Get[1] = $Old[1] Then
        $Idle += 1
        $Old[0] = $Get[0]
        $Old[1] = $Get[1]
    Else
        $Idle = 0
    EndIf
    If $Idle <> 0 Then
        TrayTip("", "Idle time : " & $Idle & " second.", 1, 16)
        if $Idle > $MaxCount and $internet = true Then
            abcd();turn off
            $Internet = false
        EndIf
        
    Else
        TrayTip("", "Hello", 0)
    EndIf
    if $Idle < $MaxCount and $internet = false Then
        defg();turn on
        $interney = True
    EndIf
    
    Sleep(1000)
WEnd

Func abcd()
;;
EndFunc

Func defg()
;
;
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks Martin this worked great and thanks to others to.

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