Jump to content

My First Script - Expert help requested


AV8R
 Share

Recommended Posts

Im totally a newb to AutoIt, so this is my first attempt at making a script.

What I dont want to do is re-invent the wheel or suffer unnecessarily if what Im attempting to do has already been done. Why not stand on the shoulders of those that have already cleared the path before me?

With that said, what Id like to do is to have a script that on a Windows XP system to show activity on my keyboard on an user set time interval on a continuous basis.

What I think Id do is the following, but Im open to better ideas:

- Every 5 or 10 minutes (or programmable reoccuring time and limits to run between a set of hours)

a. open up a command prompt or notepad session (background process would be best)

b. type in some text

c. close the session

or move the mouse around if thats registered the same as keyboard activity.

Simple to do with AutoIt?

thank you in advance

Lisa

Link to comment
Share on other sites

Im totally a newb to AutoIt, so this is my first attempt at making a script.

What I dont want to do is re-invent the wheel or suffer unnecessarily if what Im attempting to do has already been done. Why not stand on the shoulders of those that have already cleared the path before me?

With that said, what Id like to do is to have a script that on a Windows XP system to show activity on my keyboard on an user set time interval on a continuous basis.

What I think Id do is the following, but Im open to better ideas:

- Every 5 or 10 minutes (or programmable reoccuring time and limits to run between a set of hours)

a. open up a command prompt or notepad session (background process would be best)

b. type in some text

c. close the session

or move the mouse around if thats registered the same as keyboard activity.

Simple to do with AutoIt?

thank you in advance

Lisa

Care to further explain what it is you're trying to do?

If you're trying to monitor the 'activity on my keyboard', then you won't get any help. That's what we call a 'Keylogger'. And they aren't accepted here.

I can easily show you how to run notepad, type text in it, save a txt file or any other process mentioned above. But I don't know what it is exactly you want :D

Szh

Link to comment
Share on other sites

Although I understand exactly what you want to do, I'm curious of what you're trying to accomplish by doing this?

A good place to start with this is the AutoIt help file. It has a simple tutorial that: Opens notepad, writes some text in, closes notepad, clicks no on the 'Do you want to save?' dialog.

Edit: I must congratulate you on choosing AutoIt for this task. You're already "standing on the shoulders of others" by doing so. I couldn't think of a more perfect tool/language for this task than AutoIt.

Edited by Manadar
Link to comment
Share on other sites

Im totally a newb to AutoIt, so this is my first attempt at making a script.

What I dont want to do is re-invent the wheel or suffer unnecessarily if what Im attempting to do has already been done. Why not stand on the shoulders of those that have already cleared the path before me?

With that said, what Id like to do is to have a script that on a Windows XP system to show activity on my keyboard on an user set time interval on a continuous basis.

What I think Id do is the following, but Im open to better ideas:

- Every 5 or 10 minutes (or programmable reoccuring time and limits to run between a set of hours)

a. open up a command prompt or notepad session (background process would be best)

b. type in some text

c. close the session

or move the mouse around if thats registered the same as keyboard activity.

Simple to do with AutoIt?

thank you in advance

Lisa

Monitor how long the user has been idle with _Timer_GetIdleTime(). If it has been too long (i.e. to prevent screen saver from kicking in) you can just Send() a non-character key, like Send("{LSHIFT}").

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hello again and thank you for the kind and swift responses....

Let me try to address the questions and clearify what my application for AutoIt is, and what it is not.

What it is not:

Im not trying to be a nanny and monitor or keylog my or others information. Quite contrar,Im trying to do the opposite. Also, Im not trying to prevent a screen saver or wake up a keyboard sleep program.

What it is:

This keyboard tickler (hey, I think I like that appelation) would just keep activity on my keyboard at a refresh rate I want to set, and start and stop at the times I want to limit it to running. Does that make sense?

I like the ideas offered thus far:

1. Open/closing a text file.

2. Issuing faux keycommands.

What would be best is a solution that accomplishes what I want to do, and keep it from interfering when Im typing or collaborating online, etc.

I hope I did pick the right tool for the job as I was commended for. Ive run a couple of the examples and ran the editor too, but for a newbie the scripting looks like greek to me at first glance. I was hoping for a point and click teach and encode kind of GUI. Ive heard how some automate Windows applications to make non-graphical server manager programs with AutoIt. This is why I thought of AutoIt for my simple application.

Thanks so much,

Lisa

Link to comment
Share on other sites

Hello again and thank you for the kind and swift responses....

Let me try to address the questions and clearify what my application for AutoIt is, and what it is not.

What it is not:

Im not trying to be a nanny and monitor or keylog my or others information. Quite contrar,Im trying to do the opposite. Also, Im not trying to prevent a screen saver or wake up a keyboard sleep program.

What it is:

This keyboard tickler (hey, I think I like that appelation) would just keep activity on my keyboard at a refresh rate I want to set, and start and stop at the times I want to limit it to running. Does that make sense?

I like the ideas offered thus far:

1. Open/closing a text file.

2. Issuing faux keycommands.

What would be best is a solution that accomplishes what I want to do, and keep it from interfering when Im typing or collaborating online, etc.

I hope I did pick the right tool for the job as I was commended for. Ive run a couple of the examples and ran the editor too, but for a newbie the scripting looks like greek to me at first glance. I was hoping for a point and click teach and encode kind of GUI. Ive heard how some automate Windows applications to make non-graphical server manager programs with AutoIt. This is why I thought of AutoIt for my simple application.

Thanks so much,

Lisa

I presume you don't want to "tickle" the keyboard while the user is active, only when the user is idle for a while. That's what _Timer_GetIdleTime() was for. Check it out in the help file. You would put that in a While/WEnd loop, and only "tickle" when the idle time was longer than your designated interval.

Take a shot at it and post what you got if it doesn't work. You'll get plenty of help.

And welcome to AutoIt.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thank you for the warm welcome, and I like how you were warding against those that would seek to do harm or be invasive to others. Thats good sheparding, the inverse of being a nanny. Well done.

So, not being a programmer in the literal sense, but being one that thinks logically (ok most of the time), plz dont laugh at my rudimentary mad programming skills, but feel free to correct and make suggestions.

Begin userFunction KBTickler()

DoLoopForever()

start "_Timer_GetIdleTime()" //start idle timer

If "_Timer_GetIdleTime()> 5 minutes,

Begin loopSend

count(0,100)

loopSend("{LSHIFT}"). //send faux characters to create keyboard activity

End loopSend;

reset "_Timer_GetIdleTime()"

Else continue; // continue the counter if idle time is < 5 minutes

End KBTickler();

Be gentle...

Lisa

Link to comment
Share on other sites

Thank you for the warm welcome, and I like how you were warding against those that would seek to do harm or be invasive to others. Thats good sheparding, the inverse of being a nanny. Well done.

So, not being a programmer in the literal sense, but being one that thinks logically (ok most of the time), plz dont laugh at my rudimentary mad programming skills, but feel free to correct and make suggestions.

Begin userFunction KBTickler()

DoLoopForever()

start "_Timer_GetIdleTime()" //start idle timer

If "_Timer_GetIdleTime()> 5 minutes,

Begin loopSend

count(0,100)

loopSend("{LSHIFT}"). //send faux characters to create keyboard activity

End loopSend;

reset "_Timer_GetIdleTime()"

Else continue; // continue the counter if idle time is < 5 minutes

End KBTickler();

Be gentle...

Lisa

Where did you get that syntax? It's not AutoIt, anyway. For example, _Timer_GetIdleTime() returns the current idle time immediately:
#include <Timers.au3>

While 1
    Sleep(500)
    $iIdle = _Timer_GetIdleTime()
    If $iIdle >= 10 * 60 * 1000 Then
        ; Idle for 10min
        Send("{LSHIFT}")
    EndIf
WEnd

Or, if you're more minimalist:

#include <Timers.au3>

While 1
    Sleep(500)
    If _Timer_GetIdleTime() >= 10 * 60 * 1000 Then Send("{LSHIFT}")
WEnd

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

PsaltyDS

Thank you!!!

How can I test that this works if I cannot see the LSHIFT?

Can we insert a tone command or something so I can tell its working?

Lisa

#include <Timers.au3>

While 1

Sleep(500)

If _Timer_GetIdleTime() >= 10 * 60 * 1000 Then Send("{LSHIFT}")

MsgBox(0,"","It works",3)

WEnd

REB

MEASURE TWICE - CUT ONCE

Link to comment
Share on other sites

#include <Timers.au3>

While 1

Sleep(500)

If _Timer_GetIdleTime() >= 10 * 60 * 1000 Then Send("{LSHIFT}")

MsgBox(0,"","It works",3)

WEnd

REB

It should be:

#include <Timers.au3>

While 1
    Sleep(500)
    If _Timer_GetIdleTime() >= 10 * 60 * 1000 Then
        Send("{LSHIFT}")
        MsgBox(0x2000,"","It works")
    EndIf
WEnd

As it was, it will keep displaying a new message box every half second, forever. The edit will make the message box appear on 10 min idle time.

Edited by omikron48
Link to comment
Share on other sites

IT'S ABOUT TIME SOMEONE NEEDED MY SCRIPT.

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <GUIToolTip.au3>
#include <TabConstants.au3>
Local $Paused
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)

If Not FileExists(@TempDir & "Settings.kaf") Then
    $File = FileOpen(@TempDir & "Settings.kaf", 1)
    FileWriteLine($File, "Regular")
    FileWriteLine($File, "1")
    FileWriteLine($File, "")
    FileWriteLine($File, "left")
    FileWriteLine($File, "1")
    FileWriteLine($File, "|")
    FileClose($File)
EndIf

$TimeSet = 0
$File = FileOpen(@TempDir & "Settings.kaf", 0)
$TimeUse = FileReadLine($File, 1)
$TimeSave = FileReadLine($File, 2)
$CustomTimeSave = FileReadLine($File, 3)
$RadSelected = FileReadLine($File, 4)
$PixelSave = FileReadLine($File, 5)
$KeySave = FileReadLine($File, 6)
FileClose($File)

$Main = GUICreate("Keep Awake", 200, 250)
GUICtrlCreateTab(0, 0, 202, 252)
$MainTab = GUICtrlCreateTabItem("Main")
$Time1Rad = GUICtrlCreateRadio("Regular Time", 30, 30)
$Start = GUICtrlCreateButton("Start", 26, 170, 60, 30, $BS_DEFPUSHBUTTON)
$Cancel = GUICtrlCreateButton("Cancel", 113, 170, 60, 30)
$Time = GUICtrlCreateSlider(26, 75, 150, 40)
GUICtrlSetData($Time, $TimeSave)
$TimeLab = GUICtrlCreateLabel(" minutes", 72, 55, 100)
$Time2Rad = GUICtrlCreateRadio("Custom Time", 30, 115)
$CustomTimeInp = GUICtrlCreateInput($CustomTimeSave, 30, 140, 50)
$SecondsLab = GUICtrlCreateLabel("seconds", 90, 142)
GUICtrlSetLimit($Time, 10, 1)
$AboutLab1 = GUICtrlCreateLabel("Keep Awake by Minikori", 40, 210, 165)
$AboutLab2 = GUICtrlCreateLabel("Special thanks to Szhlopp and zorphnog", 4, 230, 200)
$CustomizeTab = GUICtrlCreateTabItem("Customize")
$ActionLab = GUICtrlCreateLabel("Action:", 20, 30)
$LeftRad = GUICtrlCreateRadio("Mouse Moves Left", 20, 50)
$TopRad = GUICtrlCreateRadio("Mouse Moves Up", 20, 70)
$UpDown = GUICtrlCreateInput("1", 150, 80, 35, 20)
$PixelUpDown = GUICtrlCreateUpdown($UpDown)
$RightRad = GUICtrlCreateRadio("Mouse Moves Right", 20, 90)
$BottomRad = GUICtrlCreateRadio("Mouse Moves Down", 20, 110)
$KeyRad = GUICtrlCreateRadio("Key Is Pressed", 20, 130)
$KeyCom = GUICtrlCreateCombo("", 20, 155, 110)
$SaveChk = GUICtrlCreateCheckbox("Save Changes", 20, 185)
Select
    Case $RadSelected = "left"
        GUICtrlSetState($LeftRad, $GUI_CHECKED)
    Case $RadSelected = "right"
        GUICtrlSetState($RightRad, $GUI_CHECKED)
    Case $RadSelected = "top"
        GUICtrlSetState($TopRad, $GUI_CHECKED)
    Case $RadSelected = "bottom"
        GUICtrlSetState($BottomRad, $GUI_CHECKED)
    Case $RadSelected = "key"
        GUICtrlSetState($KeyRad, $GUI_CHECKED)
EndSelect
GUISetIcon("shell32.dll", -28, $Main)
GUICtrlSetLimit($PixelUpDown, 9, 1)
GUICtrlSetLimit($UpDown, 1)
GUICtrlSetData($KeyCom, "1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|SPACE|ENTER|BACKSPACE|DELETE|UP|DOWN|LEFT|RIGHT|HOME|END|ESCAPE|INSERT|PGUP|PGDN|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|TAB|PRINTSCREEN|LWIN|RWIN|NUMPAD0|NUMPAD1|NUMPAD2|NUMPAD3|NUMPAD4|NUMPAD5|NUMPAD6|NUMPAD7|NUMPAD8|NUMPAD9", $KeySave)
GUICtrlSetData($CustomTimeInp, $CustomTimeSave)
GUICtrlSetData($UpDown, $PixelSave)
GUICtrlSetState($KeyCom, $GUI_DISABLE)
If $TimeUse = "Regular" Then
    GUICtrlSetState($Time1Rad, $GUI_CHECKED)
    GUICtrlSetState($SecondsLab, $GUI_DISABLE)
    GUICtrlSetState($CustomTimeInp, $GUI_DISABLE)
ElseIf $TimeUse = "Custom" Then
    GUICtrlSetState($Time2Rad, $GUI_CHECKED)
    GUICtrlSetState($TimeLab, $GUI_DISABLE)
    GUICtrlSetState($Time, $GUI_DISABLE)
EndIf
GUICtrlSetState($SaveChk, $GUI_CHECKED)

GUICtrlSetBkColor($Time, 0xFCFCFE)
GUISetState()
$TimeSetMem = ""
$CustomTimeMem = ""
While 1
    $msg = GUIGetMsg()
    $TimeSet = GUICtrlRead($Time)
    $CustomTimeSet = GUICtrlRead($CustomTimeInp)
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Cancel
            ExitLoop
        Case $msg = $Start
            Go()
        Case $TimeSet <> $TimeSetMem
            If $TimeSet = 1 Then
                GUICtrlSetData($TimeLab, $TimeSet & " minute")
                $TimeSetMem = $TimeSet
            Else
                GUICtrlSetData($TimeLab, $TimeSet & " minutes")
                $TimeSetMem = $TimeSet
            EndIf
        Case $CustomTimeSet <> $CustomTimeMem
            If $CustomTimeSet = 1 Then
                GUICtrlSetData($SecondsLab, "second")
                $CustomTimeMem = $CustomTimeSet
            Else
                GUICtrlSetData($SecondsLab, "seconds")
                $CustomTimeMem = $CustomTimeSet
            EndIf
        Case $msg = $LeftRad
            $RadSelected = "left"
            GUICtrlSetState($KeyCom, $GUI_DISABLE)
            GUICtrlSetState($UpDown, $GUI_ENABLE)
        Case $msg = $TopRad 
            $RadSelected = "top"
            GUICtrlSetState($KeyCom, $GUI_DISABLE)
            GUICtrlSetState($UpDown, $GUI_ENABLE)
        Case $msg = $RightRad
            $RadSelected = "right"
            GUICtrlSetState($KeyCom, $GUI_DISABLE)
            GUICtrlSetState($UpDown, $GUI_ENABLE)

        Case $msg = $BottomRad
            $RadSelected = "bottom"
            GUICtrlSetState($KeyCom, $GUI_DISABLE)
            GUICtrlSetState($UpDown, $GUI_ENABLE)
        Case $msg = $KeyRad
            $RadSelected = "key"
            GUICtrlSetState($KeyCom, $GUI_ENABLE)
            GUICtrlSetState($UpDown, $GUI_DISABLE)
        Case $msg = $Time1Rad
            $TimeUse = "Regular"
            GUICtrlSetState($CustomTimeInp, $GUI_DISABLE)
            GUICtrlSetState($SecondsLab, $GUI_DISABLE)
            GUICtrlSetState($TimeLab, $GUI_ENABLE)
            GUICtrlSetState($Time, $GUI_ENABLE)
        Case $msg = $Time2Rad
            $TimeUse = "custom"
            GUICtrlSetState($TimeLab, $GUI_DISABLE)
            GUICtrlSetState($Time, $GUI_DISABLE)
            GUICtrlSetState($CustomTimeInp, $GUI_ENABLE)
            GUICtrlSetState($SecondsLab, $GUI_ENABLE)
    EndSelect
WEnd
Exit

;------------------Functions------------------;

Func Go()
    $SaveVer = GUICtrlRead($SaveChk)
    If $SaveVer = $GUI_CHECKED Then
        $TimeSet = GUICtrlRead($Time)
        $CustomTimeSet = GUICtrlRead($CustomTimeInp)
        $Pixels = GUICtrlRead($UpDown)
        $KeySave = GUICtrlRead($KeyCom)
        _FileCreate(@TempDir & "Settings.kaf")
        $File = FileOpen(@TempDir & "Settings.kaf", 1)
        FileWriteLine($File, $TimeUse)
        FileWriteLine($File, $TimeSet)
        FileWriteLine($File, $CustomTimeSet)
        FileWriteLine($File, $RadSelected)
        FileWriteLine($File, $Pixels)
        FileWriteLine($File, $KeySave)
        FileClose($File)
    EndIf
    If $TimeUse = "Regular" Then
        If $RadSelected = "left" Or $RadSelected = "top" Or $RadSelected = "right" Or $RadSelected = "bottom" Then
            $TimeSet = GUICtrlRead($Time)
            $Pixels = GUICtrlRead($UpDown)
            If $TimeSet = 1 Then
                If $Pixels = 1 Then
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixel to the " & $RadSelected & " every minute. Press Ctrl+Shift+E to exit.")
                Else
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixels to the " & $RadSelected & " every minute. Press Ctrl+Shift+E to exit.")
                EndIf
            Else 
                If $Pixels = 1 Then
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixel to the " & $RadSelected & " every " & $TimeSet & " minutes. Press Ctrl+Shift+E to exit.")
                Else
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixels to the " & $RadSelected & " every " & $TimeSet & " minutes. Press Ctrl+Shift+E to exit.")
                EndIf
            EndIf
            GUIDelete($Main)
            HotKeySet("^+e", "Quit")
            $TrayPause = TrayCreateItem("Pause")
            $TrayExit = TrayCreateItem("Exit")
            $SleepTime = $TimeSet * 60000
            TraySetState()
            While 1
                $tray = TrayGetMsg()
                Sleep($SleepTime)
                $MousePos = MouseGetPos()
                If $RadSelected = "left" Then MouseMove($MousePos[0] - $Pixels, $MousePos[1])
                If $RadSelected = "top" Then MouseMove($MousePos[0], $MousePos[1] + $Pixels)
                If $RadSelected = "right" Then MouseMove($MousePos[0] + $Pixels, $MousePos[1])
                If $RadSelected = "bottom" Then MouseMove($MousePos[0], $MousePos[1] - $Pixels)
                If $tray = $TrayExit Then
                    Quit()
                EndIf
                If $tray = $TrayPause Then
                    Pause()
                EndIf
            WEnd
        EndIf
        If $RadSelected = "key" Then
            $Split = StringSplit("1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|SPACE|ENTER|BACKSPACE|DELETE|UP|DOWN|LEFT|RIGHT|HOME|END|ESCAPE|INSERT|PGUP|PGDN|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|TAB|PRINTSCREEN|LWIN|RWIN|NUMPAD0|NUMPAD1|NUMPAD2|NUMPAD3|NUMPAD4|NUMPAD5|NUMPAD6|NUMPAD7|NUMPAD8|NUMPAD9", "|")
            For $x = 1 To $Split[0]
                If GUICtrlRead($KeyCom) = $Split[$x] Then
                    $KeyPress1 = StringLower($Split[$x])
                    ExitLoop
                EndIf
            Next
            $TimeSet = GUICtrlRead($Time)
            If $TimeSet = 1 Then
                MsgBox(0, "Started", "The " & $KeyPress1 & " key will now be pressed every minute. Press Ctrl+Shift+E to exit.")
            Else
                MsgBox(0, "Started", "The " & $KeyPress1 & " key will now be pressed every " & $TimeSet & " minutes. Press Ctrl+Shift+E to exit.")
            EndIf
            GUIDelete($Main)
            HotKeySet("^+e", "Quit")
            $SleepTime = $TimeSet * 60000
            $KeyPress2 = "{" & $KeyPress1 & "}"
            While 1
                Sleep($SleepTime)
                Send($KeyPress2)
            WEnd
        EndIf
    EndIf
    If $TimeUse = "custom" Then
        If $RadSelected = "left" Or $RadSelected = "top" Or $RadSelected = "right" Or $RadSelected = "bottom" Then
            $TimeSet = GUICtrlRead($CustomTimeInp)
            $Pixels = GUICtrlRead($UpDown)
            If $TimeSet = 1 Then
                If $Pixels = 1 Then
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixel to the " & $RadSelected & " every second. Press Ctrl+Shift+E to exit.")
                Else
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixels to the " & $RadSelected & " every second. Press Ctrl+Shift+E to exit.")
                EndIf
            Else
                If $Pixels = 1 Then
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixel to the " & $RadSelected & " every " & $TimeSet & " seconds. Press Ctrl+Shift+E to exit.")
                Else
                    MsgBox(0, "Started", "The mouse will now move " & $Pixels & " pixels to the " & $RadSelected & " every " & $TimeSet & " seconds. Press Ctrl+Shift+E to exit.")
                EndIf
            EndIf
            GUIDelete($Main)
            HotKeySet("^+e", "Quit")
            $SleepTime = $TimeSet * 1000
            While 1
                Sleep($SleepTime)
                $MousePos = MouseGetPos()
                If $RadSelected = "left" Then MouseMove($MousePos[0] - $Pixels, $MousePos[1])
                If $RadSelected = "top" Then MouseMove($MousePos[0], $MousePos[1] + $Pixels)
                If $RadSelected = "right" Then MouseMove($MousePos[0] + $Pixels, $MousePos[1])
                If $RadSelected = "bottom" Then MouseMove($MousePos[0], $MousePos[1] - $Pixels)
            WEnd
        EndIf
        If $RadSelected = "key" Then
            $Split = StringSplit("1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|SPACE|ENTER|BACKSPACE|DELETE|UP|DOWN|LEFT|RIGHT|HOME|END|ESCAPE|INSERT|PGUP|PGDN|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|TAB|PRINTSCREEN|LWIN|RWIN|NUMPAD0|NUMPAD1|NUMPAD2|NUMPAD3|NUMPAD4|NUMPAD5|NUMPAD6|NUMPAD7|NUMPAD8|NUMPAD9", "|")
            For $x = 1 To $Split[0]
                If GUICtrlRead($KeyCom) = $Split[$x] Then
                    $KeyPress1 = StringLower($Split[$x])
                    ExitLoop
                EndIf
            Next
            $TimeSet = GUICtrlRead($CustomTimeInp)
            If $TimeSet = 1 Then
                MsgBox(0, "Started", "The " & $KeyPress1 & " key will now be pressed every second. Press Ctrl+Shift+E to exit.")
            Else
                MsgBox(0, "Started", "The " & $KeyPress1 & " key will now be pressed every " & $TimeSet & " seconds. Press Ctrl+Shift+E to exit.")
            EndIf
            GUIDelete($Main)
            HotKeySet("^+e", "Quit")
            $SleepTime = $TimeSet * 1000
            $KeyPress2 = "{" & $KeyPress1 & "}"
            While 1
                Sleep($SleepTime)
                Send($KeyPress2)
            WEnd
        EndIf
    EndIf
EndFunc

While 1
    Sleep(100)
WEnd

Func Pause()
    $Paused = NOT $Paused
    While $Paused
        ToolTip("Script is paused", 0, 0)
        sleep(100)
    ToolTip("")
    WEnd
EndFunc

While 1
    Sleep(100)
WEnd

Func Quit()
    Exit
EndFunc

It should also be in the example scripts section.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Reb and OmiKron,

Indeed, it works!!

:D

Posted Image

MiniKori,

Youve out done yourself. A GUI based script. Very cool.

I get a headache trying to understand the script. :D

I tested it both in custom time and slider time modes with

a letter and mouse movements. Works perfectly. I did have

one problem, I couldnt pause/exit it from the tool tray icon.

I had to kill it with the windows task manager.

Posted Image

What I would like to see enhanced in this script are:

- add an optional visual test mode like "it works"

- add an optional one-shot or infinite loop mode

- add a keyboard check before starting the counter

(merging your and the previous scripts)

Lisa

Edited by AV8R
Link to comment
Share on other sites

Ok so I have a script and want it to do stuff when I am idle, and stop when I return,

_Timer_GetIdleTime() seems to detect auto it's mouse movements not just mine.

How do I stop when the user starts doing things? or how do I determine the user idle time? any hints?

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