Jump to content

Recommended Posts

Posted

Hi,

i just "coded" a simple script, including HotKeySet... but it doesn't work. It's closing itself after i started it without any message or error.

Here is the script:

HotKeySet("{F4}", "StartProg") 
Func StartProg()
    Sleep (100)
    MouseClick ("left", 569, 728)
    Sleep (100)
    MouseClick ("left", 607, 732)
    Sleep (100)
    MouseClick ("left", 469, 658)
    Sleep (100)
EndFunc

I just want the Script to make 3 clicks at different points, but just after i pressed a Hotkey (For example "F4"). I am a newbie on AutoIT... Can someone help me?

PS: "SyntaxCheck Prod" says, that there's no problem with the syntax' (or something like this :D).

  • Moderators
Posted

foxnbk,

Your script exits becasue you have not told it to do anything else! As soon as it sets the HotKey, it finishes.

Try this instead:

HotKeySet("{F4}", "StartProg") 
HotKeySet("{ESC}", "EndProg")

; Infinite loop
While 1
Sleep(100)
WEnd

Func StartProg()
    Sleep (100)
    MouseClick ("left", 569, 728)
    Sleep (100)
    MouseClick ("left", 607, 732)
    Sleep (100)
    MouseClick ("left", 469, 658)
    Sleep (100)
EndFunc

Func EndProg()
    Exit
EndFunc

This way your script keeps running until you stop it with the ESC key.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

The behavior is as you set it - you set the hot key, then your program exits. If you want the hot key to remain active, you need to keep the script active. For instance, keeping the script active while a certain process exists (While ProcessExists) or just globally keeping the script active (While 1). Look into control loops in the help file.

Bob

You can't see a rainbow without first experiencing the rain.

Posted

  foxnbk said:

Hi,

i just "coded" a simple script, including HotKeySet... but it doesn't work. It's closing itself after i started it without any message or error.

Here is the script:

HotKeySet("{F4}", "StartProg") 
Func StartProg()
    Sleep (100)
    MouseClick ("left", 569, 728)
    Sleep (100)
    MouseClick ("left", 607, 732)
    Sleep (100)
    MouseClick ("left", 469, 658)
    Sleep (100)
EndFunc

I just want the Script to make 3 clicks at different points, but just after i pressed a Hotkey (For example "F4"). I am a newbie on AutoIT... Can someone help me?

PS: "SyntaxCheck Prod" says, that there's no problem with the syntax' (or something like this :D).

Based on your wording, I assume this is the full content of your script. If that's the case, then basically what you need to do is to include some form of loop to keep the script active while it's waiting for input (in the form of your hotkey).

Give this a shot (press ESC to exit the script):

HotKeySet("{F4}", "StartProg")
HotKeySet("{ESC}","_ExitIt")

While 1
    Sleep(10)
Wend

Func _ExitIt()
    Exit()
EndFunc

Func StartProg()
    Sleep (100)
    MouseClick ("left", 569, 728)
    Sleep (100)
    MouseClick ("left", 607, 732)
    Sleep (100)
    MouseClick ("left", 469, 658)
    Sleep (100)
EndFunc

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...