zypp0 Posted December 20, 2011 Share Posted December 20, 2011 (edited) Hello, how can I use IsPressed? I wrote this, but not work: #include <Misc.au3> if _IsPressed(01) Then msgbox("click sinistro") endif while 1 sleep(1) wend I' d send a message when left click.. Edited December 20, 2011 by zypp0 Link to comment Share on other sites More sharing options...
Developers Jos Posted December 20, 2011 Developers Share Posted December 20, 2011 You only test one time and then stick within the loop without testing: #include <Misc.au3> while 1 if _IsPressed(01) Then msgbox("click sinistro") endif sleep(1) wend SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 20, 2011 Moderators Share Posted December 20, 2011 zypp0,Welcome to the AutoIt forum. You need to put the If statement inside the loop - and increase the Sleep to at least 10:#include <Misc.au3> HotKeySet("{ESC}", "On_Exit") $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then MsgBox(0, "", "click sinistro") EndIf Sleep(10) WEnd Func On_Exit() DllClose($hDLL) Exit EndFuncI also gave you a HotKey to exit the script and did what the Help file tells you to do if you call _IsPressed in a loop and opened/closed the DLL. As a beginner, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. Have fun! 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...
Developers Jos Posted December 20, 2011 Developers Share Posted December 20, 2011 Show off TheSaint 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
zypp0 Posted December 20, 2011 Author Share Posted December 20, 2011 Thanks Yes, me! , also for guides Link to comment Share on other sites More sharing options...
Chimaera Posted March 2, 2012 Share Posted March 2, 2012 (edited) A small question on this if i may Melbas example works fine with a message box but when i add a send command it gets weird and my comp starts responding oddly The key i actually want it to press is the nought key above the p key because the keyboard this is to be used on doesn't have a numpad which is why i tried Send ("{ASC 48") can anyone tell me why it works with the message and not with the send? ps all i want is right ctrl pressed makes 0 pressed thats all and esc to exit HotKeySet("{ESC}", "On_Exit") $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("A3", $hDLL) Then ;~ MsgBox(0, "", "click sinistro") Send Send ("{ASC 48}") EndIf Sleep(10) WEnd Func On_Exit() DllClose($hDLL) Exit EndFunc Edited March 2, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2012 Moderators Share Posted March 2, 2012 Chimaera,Thanks for the reboot and having to rearrange my entire desktop and folder contents! Although you did say "starts responding oddly". I can only assume that RCtrl-0 does something pretty wacky to the system, but I have no idea what. However, after some careful exploration, I have found that you can use Send("{ASC 048}") if you wait for the RCtrl key to be released first and so do not use Send with it depressed: #include <Misc.au3> HotKeySet("{ESC}", "On_Exit") $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("A3", $hDLL) Then ; Wait for key to be released While _IsPressed("A3", $hDLL) Sleep(10) WEnd ;MsgBox(0, "", "click sinistro") Send ("{ASC 48}") ;Send ("0") EndIf Sleep(10) WEnd Func On_Exit() DllClose($hDLL) Exit EndFunc ;==>On_ExitNote the Help file tells you to add a leading 0 to the ASCII code - and why are you not just sending "0" anyway? 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...
Chimaera Posted March 2, 2012 Share Posted March 2, 2012 thanks for the help Melba and im sorry about the code although i did warn about the unpredictable stuff, everytime i pressed F1 it gave me scite help not normal and i got funny chars in the script and had to reboot a cple times although it didnt mess anything up for me on the desktop. I didn't use"0" because i didn't know i could, i checked the helpfile and it gave no reference for 1-0 so i used what was in the reference couldnt use numpad cmds so i went asc. It works fine although ive since found out when he has a full screen app running it doesn't work with the app Ill have to rethink how to send to a given app If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
SergioSchulte Posted June 12, 2013 Share Posted June 12, 2013 zypp0, Welcome to the AutoIt forum. You need to put the If statement inside the loop - and increase the Sleep to at least 10: #include <Misc.au3> HotKeySet("{ESC}", "On_Exit") $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then MsgBox(0, "", "click sinistro") EndIf Sleep(10) WEnd Func On_Exit() DllClose($hDLL) Exit EndFunc I also gave you a HotKey to exit the script and did what the Help file tells you to do if you call _IsPressed in a loop and opened/closed the DLL. As a beginner, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. Have fun! M23 Not sure if I did something wrong, I replace "01" for "32", which is the key 2 I need... but I had to keep key 2 down so it can work. I need something when I press "2" key only once, not keep it pressed. 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