IDaninator Posted November 15, 2014 Share Posted November 15, 2014 (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? expandcollapse popupMsgBox(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 November 15, 2014 by IDaninator Link to comment Share on other sites More sharing options...
mikell Posted November 15, 2014 Share Posted November 15, 2014 There is a nice typo : $Timer=TimerInit() trancexx 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 16, 2014 Moderators Share Posted November 16, 2014 IDaninator, The script works fine with 'send' in e.g. my browser but not in the program I need itAnd what program would that be? 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
IDaninator Posted November 16, 2014 Author Share Posted November 16, 2014 @mikell Thank you, I needed over half an hour to find the Mistake... @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. 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 Link to comment Share on other sites More sharing options...
kylomas Posted November 17, 2014 Share Posted November 17, 2014 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 Link to comment Share on other sites More sharing options...
IDaninator Posted November 20, 2014 Author Share Posted November 20, 2014 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now