foxnbk Posted April 7, 2009 Share Posted April 7, 2009 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 ). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2009 Moderators Share Posted April 7, 2009 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 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...
YellowLab Posted April 7, 2009 Share Posted April 7, 2009 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. Link to comment Share on other sites More sharing options...
Monamo Posted April 7, 2009 Share Posted April 7, 2009 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 ).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] Link to comment Share on other sites More sharing options...
foxnbk Posted April 7, 2009 Author Share Posted April 7, 2009 Hm, it does work now. Thank you all alot, it was very helpfull 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