Sign in to follow this  
Followers 0
IDaninator

TimerDiff behaving weird

6 posts in this topic

#1 ·  Posted (edited)

EDIT:

 

I found my mistake and the script works fine now.

But now I have another problem:

The script works fine with 'send' in e.g. my browser but not in the program I need it.

I already tried using 'controlsend' but that did not work either.

What else can I try?

 

 

 

Hello there,

 

I just started using AutoIT and I discovered a problem with TimerDiff.

What I want to do is a script, the emulates pressing the spacebar for me in a userdefined intervall.

This intervall is supposed to also be defined by the spacebar.

With Backspace I can stop the emulation of the spacebarpresses and Enter closes the script.

My problem is:

TimerDiff gives out strange, extremely high values.

Where is my Mistake?

MsgBox(0, "BPM Tapping", "Das Programm BPM-Tapping läuft jetzt")

HotKeySet("{SPACE}", "TapFunktion")            ;Funtion that is Used to get Time between Button presses
HotKeySet("{ENTER}", "Schliessen")             ;Function to exit the script
HotKeySet("{BS}", "TapStoppen")            ;Function that stops the 'Button press algorithm' from doing anything

Global $TapAn = 0
Global $wieoft = 0
Global $Timer
Global $Diff

While 1
   while $TapAn = 1                         ;Space is presses every Diff milliseconds
      Sleep($Diff)
      send("{SPACE}")
   WEnd
 WEnd

Func TapFunktion()
   if $wieoft = 0 Then                      ;when space gets pressed first time
      $Timer=TimerInit                      ;Timer starts
      $wieoft = 1                   ;Number of spacepresses set to 1
   ElseIf $wieoft = 1 Then                  ;in the second cycle
      $Diff = TimerDiff ($Timer)                    ;the timedifference to the first spacebar press is taken
      $TapAn = 1                    ;the 'button press algorithm' goes active
      $wieoft = 0                   ;spacebar presses set back to 0
      MsgBox(0, "Test", $Diff)              ;msg Box I made for debugging because of strange behaviour
   EndIf
EndFunc

Func TapStoppen()                   ;stop the loop
   $TapAn = 0
EndFunc

Func Schliessen()                   ;exit
   Exit 0
EndFunc

Simple test code like this works like it's supposed to do:

$begin = TimerInit()
Sleep(5000)
MsgBox(0, "Timer", "Duration = "& TimerDiff($begin))

Greetings,

Daniel

Edited by IDaninator

Share this post


Link to post
Share on other sites



There is a nice typo : $Timer=TimerInit()     :)

1 person likes this

Share this post


Link to post
Share on other sites

IDaninator,

 

The script works fine with 'send' in e.g. my browser but not in the program I need it

And what program would that be? :huh:

Might I suggest reading the Forum rules (there is also a link at bottom right of each page) before posting again. Not suggesting that is what you are doing, of course - but as this problem is so often caused by anti-automation measures within games it might well be the reason. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@mikell Thank you, I needed over half an hour to find the Mistake... :D

@Melba23 I read that and no, it's not the case, I will tell you what the program I need it for does.

No problem, I just thought it was not interesting for you. :D

The program is called LumiDMX. 

The lighting for events is controlled via a protocol that is called DMX. In the past you had physical DMX consoles to output that signal and control your fixtures.

Since fixtures get more complicated the requirements to the consoles raise and now we are at the point where it's cheaper to have a program like LumiDMX and a USB-to-DMX-Dongle than a well built lighting console.

LumiDMX has a function build in that is able to cycle through different lighting scenes automatically. This function does exactly what my script is supposed to do but there is a bug that doesnt get fixed:

When you give Lumi a new time to wait between changing scenes it skips to the next one no matter where it is in the current one.

You can also control the changing of the scenes manually with a keyboard button. The problem here is you can't give a rythm and then just leave it, you have to tap constantly.

That's where my script comes in and is supposed to keep on tapping when I stop doing it manually.

 

My problem now is, that Lumi doesn't seem to get my simulated keyboard input like every other program does. What can I do?

 

 

best regards, 

Daniel

Share this post


Link to post
Share on other sites

IDaninator,

If you use the Send function then you must ensure that Lumi is the currently active window.  You might be better off with ControlSend.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Hey,

 

Thank you for your suggestion but I can't get Control Send to work either.
I don't know wich Control in my window I have to use to get it to work. I tried the main window and a few things like the big control panel but I can't get LumiDMX to get my keystroke.


best regards, 

Daniel

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