arkane Posted February 2, 2009 Share Posted February 2, 2009 Hi dudes. I have a problem with my script. #include <Misc.au3> If _IsPressed('11') Then $i=0 While $i = 2 Send("{SPACE down}") sleep (300) Send("{Space up}") $i = $i + 1 WEnd EndIf I want that when I press ctrl, space is pressed twice. But when I compile my project and launch it, nothing his launched, or maybe it is automaticly and quickly closed by itself. Do you have any idea why ? Thanks in advance. Link to comment Share on other sites More sharing options...
FireFox Posted February 2, 2009 Share Posted February 2, 2009 (edited) @arkane #include <Misc.au3> If _IsPressed('11') Then $i=0 While $i <= 2 Send("{SPACE down}") sleep (300) Send("{Space up}") $i = $i + 1 WEnd EndIf Cheers, FireFox. Edited February 2, 2009 by FireFox Link to comment Share on other sites More sharing options...
spudw2k Posted February 2, 2009 Share Posted February 2, 2009 Hi dudes. I have a problem with my script. #include <Misc.au3> If _IsPressed('11') Then $i=0 While $i = 2 Send("{SPACE down}") sleep (300) Send("{Space up}") $i = $i + 1 WEnd EndIf I want that when I press ctrl, space is pressed twice. But when I compile my project and launch it, nothing his launched, or maybe it is automaticly and quickly closed by itself. Do you have any idea why ? Thanks in advance.Well, While i = 2 never happens cause i = 0. Try While i < 2? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 (edited) Because you do not have your script wait until you press control. It just reads through the script... sees that _Ispressed('11') is not pressed at that split second of time, then it ends. You need to do a loop.. #include <Misc.au3> HotKeySet("{ESC}", "Terminate") While 1 Sleep(100) ; always a good idea so you dont max your cpu If _IsPressed('11') Then $i = 0 While $i < 2 Send("{SPACE down}") Sleep(300) Send("{Space up}") $i = $i + 1 WEnd EndIf WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate [edit] tweaked your other while loop so it would work too[/edit] Edited February 2, 2009 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
arkane Posted February 2, 2009 Author Share Posted February 2, 2009 (edited) wow ! what quick answers ! lol ! Thanks for your help, that was a syntax error ... But well, it seems to work very slowly !! I just want to convert this ahk script into an autoit one : LControl & RAlt:: Loop 2 { Sendinput {Space down} sleep 30 Sendinput {Space up} } Return but I'm struggling Edit : In fact, I want to use this for a game which use 60fps. I would like that on one frame it press space, and just on the next one, it press space again. Edited February 2, 2009 by arkane Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 what is slow? The response to pressing CTRL? The time between spaces? How long it is taking to do each space? [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
arkane Posted February 2, 2009 Author Share Posted February 2, 2009 The response to pressing control Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 Then tweak it... #include <Misc.au3> HotKeySet("{ESC}", "Terminate") While 1 Sleep(10) ; always a good idea so you dont max your cpu If _IsPressed('11') Then $i = 0 While $i = 2 Send("{SPACE down}") Sleep(20) ; 60 FPS means you will have a frame every 16.666666... miliseconds Send("{Space up}") $i = $i + 1 WEnd EndIf WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
arkane Posted February 2, 2009 Author Share Posted February 2, 2009 (edited) well, the problem is that it doesn't answer everytime I press control. Is there any way to set ALTGR key instead of control ? I tried #include <Misc.au3> While 1 If _IsPressed('!Gr') Then $i = 0 While $i <= 2 Send("{SPACE down}") Sleep(17); 60 FPS means you will have a frame every 16.666666... miliseconds Send("{Space up}") $i = $i + 1 WEnd EndIf WEnd but it doesn't work :/ Edited February 2, 2009 by arkane Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 How about: #include <Misc.au3> HotKeySet("{ESC}", "Terminate") While 1 Sleep(10) ; always a good idea so you dont max your cpu If _IsPressed('11') Then $i = 0 While $i = 2 Send("{SPACE}") Sleep(20) Send("{SPACE}") $i = $i + 1 WEnd EndIf WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 Try this, and play with the OPT values #include <Misc.au3> HotKeySet("{ESC}", "Terminate") Opt ("SendKeyDelay",15) ; delay between sending keys - default 5 Opt ("SendKeyDownDelay",5) ; how long to hold down a key - default 5 While 1 Sleep(10) ; always a good idea so you dont max your cpu If _IsPressed('11') Then Send ("{SPACE}{SPACE}") ; '11' = a CTRL key WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
SpookMeister Posted February 2, 2009 Share Posted February 2, 2009 FYI, on my machine checking _IsPressed() takes about 5 miliseconds all by itself... YMMV "Your Mileage May Vary" [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] 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