Sign in to follow this  
Followers 0
mojzekinohokker

Noob here please help !

9 posts in this topic

#1 ·  Posted (edited)

I'm pretty new in writing scripts so I need help. ( Also sorry for my bad grammar. English isn't my native language)

So I would like to accomplish the following :

* Automated pressing of a certain button ( key "F5" in my case ) in a certain time.

* The pressing of the button must be random between 2 values (4-5 sec in my case )

So far I've come this far and it's even working but the problem is that when I hit the button "F5" to start the loop it begings with 4-5 sec delay. 

BreakLoop = 0

F5:: 
    If BreakLoop := Not BreakLoop
    {
        SetTimer TheLoop, 5000
    } Else
        SetTimer TheLoop, Off
Return

wheeldown::
    BreakLoop = 0
    SetTimer TheLoop, Off
    Send {wheeldown}
Return

TheLoop:
    RandomSleep(4500,5000)
    Send {F5}
Return

RandomSleep(min,max)
{
    Random, random, %min%, %max%
    Sleep %random%
}

How do I get the script to start with the pressing of the button as I hit F5 and only after then the delayed automated pressing ?

Edited by mojzekinohokker

Share this post


Link to post
Share on other sites



Welcome to Autoit and the forum!

Can you please tell us which program you try to automate? Most of the time there are more reliable ways to automate an application than to press keys.


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

It's a program at work used to handle our inventory. It lacks the feature auto refresh. Automated pressing of F5 will do fine for me.

Share this post


Link to post
Share on other sites

Does this application have a "Refresh" button?

Sending a key always goes to the active application. So pressing F5 when there is another application active can lead to undesired results.


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

F5 is the Refresh button. This is supposed to be pressed every 4-5 second. My problem is that the cycle begins with the delay not the refresh ! It's nothing major it's just bugs me.

How do I fix the scipt ? 

Share this post


Link to post
Share on other sites

The code you posted is not written for AutoIt. I assume it is written for AHK.

Do you want to translate your AHK script to AutoIt?


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

Damn wrong forum my mistake. I guess I should post there right ?

Share this post


Link to post
Share on other sites

Correct.


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

JTLYK - you can use AutoIt to do it though.

Several things:

1. Why is an inventory script worried about having the F5 key be random? That is extreamly odd. What happens if it is NOT random?

2. What is the NAME of this "Inventory" program you use at work? I would like to google it and see what it does for my knowledge purposes.

3. Why do you have a mousewheel command in your script?

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