laolas

Sending a key in randome time

18 posts in this topic

#1 ·  Posted

Hey my plan is to send a key in random time. In this case "S", it should send a S randomly in between 4 Sec.

 

Thanks

Code:


If ProcessExists("OS.exe") Then
  MsgBox(1,"Checking Client....","GEFUNDEN!!!")
  Else
      MsgBox(1,"Checking Client...","NICHT GEFUNDEN!!!")
      Exit

          EndIf

 


while 1
    Random (1000,4000,1)
      Send("{S}")


wend

 

 

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Welcome to AutoIt and the forum!

Ich konnte in Deinem Post keine Frage finden ;)  Wo liegt das Problem?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

4 minutes ago, water said:

Welcome to AutoIt and the forum!

Ich konnte in Deinem Post keine Frage finden ;)  Wo liegt das Problem?

Ich würde gerne in die While schleife einen cod reingeben der nach einer zufälligen zeit zwischen 1-4 sek den bustaben S schreibt. ich weiß ned wie ich das hinbekomm :D

Share this post


Link to post
Share on other sites

#5 ·  Posted

i dont know how to cod it :C pls help

Share this post


Link to post
Share on other sites

#7 ·  Posted

i also looked up many other forums and what they posted an tried it out, but i was not able to get it working... could you cod it for me pls

Share this post


Link to post
Share on other sites

#8 ·  Posted

Finally i maged to solve the problem :)

Share this post


Link to post
Share on other sites

#9 ·  Posted

laolas,

16 minutes ago, laolas said:

Finally i maged to solve the problem :)

Now you are ready to learn.  Lets see your solution, it may help others!

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

#10 ·  Posted

5 minutes ago, kylomas said:

laolas,

Now you are ready to learn.  Lets see your solution, it may help others!

kylomas

If ProcessExists(".exe") Then
  MsgBox(1,"Checking Client....","GEFUNDEN!!!")
  Else
      MsgBox(1,"Checking Client...","NICHT GEFUNDEN!!!     Soll das Client gestartet werden?")
    Run (.exe")

          EndIf

 

 

 

$pxs = PixelSearch(5,4,1916,1036,0xFE7427)

while 1

    If isArray($pxs) then
  ProcessClose ( "exe" )

EndIf

sleep(random(1000, 5000, 1))
       Send("{S}")

wend

there is my solution

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

I've tidied your source a little and it seems to me you have a logic issue in there as you one check for the pixel one time and use the outcome forever:

If ProcessExists(".exe") Then
    MsgBox(1, "Checking Client....", "GEFUNDEN!!!")
Else
    MsgBox(1, "Checking Client...", "NICHT GEFUNDEN!!!     Soll das Client gestartet werden?")
    Run(.exe")

EndIf

$pxs = PixelSearch(5, 4, 1916, 1036, 0xFE7427)

While 1
    If IsArray($pxs) Then
        ProcessClose("exe")
    EndIf
    Sleep(Random(1000, 5000, 1))
    Send("{S}")
WEnd

Is that what you want for the "program" to work correctly?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#12 ·  Posted

Yeah everything there has its role,

i have one more question i would like to have a timer how the program was opened, so i figured out a way to make it by making screenshots form the desktop where the time is in the right corner... but my problem is that when i make a screen only one is made because the file name allready exist, how i mage it to save the screenshot with a random generated name ? like "1232asd2.jpg"

 

#include <ScreenCapture.au3>
_ScreenCapture_Capture(@DesktopDir & "\GDIPlus_Image1.jpg")

 

Share this post


Link to post
Share on other sites

#13 ·  Posted

1 minute ago, laolas said:

Yeah everything there has its role,

Doubt you understood what I tried to tell you... maybe read that first sentence of my previous post again about doing one a pixelsearch one time.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#14 ·  Posted

I tested the script but it seam working :S now i tested it twice, yeah there is a problem :S it only check it one(pixel search) time and only when its opened :S how i manage to check if this pixel exist in a loop ?

Share this post


Link to post
Share on other sites

#15 ·  Posted

Putting the pixelsearch INTO the loop would seem to be the method to use don't you think?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#16 ·  Posted

The plan is that the script check if this pixel is found(this pixel only exist if there is an error) and then the programm will be closed, for this i need the pixel search in a loop

Share this post


Link to post
Share on other sites

#17 ·  Posted

20 minutes ago, laolas said:

for this i need the pixel search in a loop

So, what is stopping you from putting it into the loop you already have?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#18 ·  Posted

i found the mistake, now i only need to fix that sreenshot issue

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