basgen Posted July 27, 2010 Share Posted July 27, 2010 (edited) I tried looking at the help files and around the forum but couldnt find what i needed, also this should be pretty simple. This might seem like a weird request. When i press 'a' on my keyboard i need it to press 'a' followed by 'b' automatically. So that whenever i press 'a' it activates 'b' after 'a'. I tried using python but i'm not good enough. I'm trying this to make it easier to fill out certain information in spreadsheets. Thanks in advance, Bas Edited July 27, 2010 by basgen Link to comment Share on other sites More sharing options...
MasonMill Posted July 27, 2010 Share Posted July 27, 2010 There are a couple ways that i know of. One being hotkeyset and the other is _IsPressed. HotKeySet("a", "some_function_name") while 1 your loop or what ever your doing wend func some_function_name() send("a") sleep(10) send("b") sleep(10) endfunc is prob the easiest way. good luck! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 27, 2010 Moderators Share Posted July 27, 2010 MasonMill,Have you tried your code? I think not, because as it stands you enter an infinite loop. As you Send the "a", you trigger the HotKey again, which Sends another "a", triggering the HotKey yet again, which........ Your function needs to unset and then reset the HotKey - like this: Func some_function_name() ; Unset the HotKey HotKeySet("a") ; Send the keys Send("a") Sleep(10) Send("b") Sleep(10) ; Reset the HotKey HotKeySet("a", "some_function_name") EndFuncAll clear? 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...
MasonMill Posted July 27, 2010 Share Posted July 27, 2010 doh! So is pressed is the way to go? Link to comment Share on other sites More sharing options...
MasonMill Posted July 27, 2010 Share Posted July 27, 2010 Thats good to know! i lear many things every day lol. lately its al been from melba! Link to comment Share on other sites More sharing options...
basgen Posted July 27, 2010 Author Share Posted July 27, 2010 Let me see if i understand it right. You made the hotkey 'a' so that every time i press the key 'a' it starts the function? Then the function sends 'a', sleeps (is that 10s or 10 ticks or 10ms?), then sends 'b' Then it stops. Does it need to loop? I tried running that script but it doesnt seem to do anything, could be me tho. Sorry for not understanding, i'm guessing this is c++ based or something... to which i am clueless . Link to comment Share on other sites More sharing options...
basgen Posted July 27, 2010 Author Share Posted July 27, 2010 Let me see if i understand it right.You made the hotkey 'a' so that every time i press the key 'a' it starts the function?Then the function sends 'a', sleeps (is that 10s or 10 ticks or 10ms?), then sends 'b'Then it stops.Does it need to loop? I tried running that script but it doesnt seem to do anything, could be me tho.Sorry for not understanding, i'm guessing this is c++ based or something... to which i am clueless .I couldnt edit my last post sorry.I tried ------------------HotKeySet( "a", "foobar" )Func foobar( ) Send( "a" ) Send( "b" )EndfuncWhile 1 Sleep( 1 )WEnd-----------------instead. The thing is with your script is that if i run it, it closes right away.Mine stays running but doesnt really work Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 27, 2010 Moderators Share Posted July 27, 2010 basgen, A slightly belated welcome to the AutoIt forum. You will be able to edit your posts after the next one. Did you see my explanation above? It explains why nothing happens and you do not exit when you run MasonMill's code. Try running this: ; Set the HotKeys HotKeySet("a", "_ab") HotKeySet("{ESC}", "On_Exit") ; Now keep the script active While 1 Sleep(10) WEnd Func _ab() ; Unset the HotKey HotKeySet("a") ; Send the keys Send("a") Sleep(10) Send("b") Sleep(10) ; Reset the HotKey HotKeySet("a", "_ab") EndFunc Func On_Exit() Exit EndFunc Please ask if you have any questions. 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...
basgen Posted July 27, 2010 Author Share Posted July 27, 2010 Thanks, seems like a nice program to use.. lets hope python can help me a bit in the future. Yours works now, I'll try play around with it some more. This thread can get closed or wtv. Link to comment Share on other sites More sharing options...
basgen Posted July 27, 2010 Author Share Posted July 27, 2010 Apparently its rude to PM people for help, so sorry Is there a way that i can make it so i can only use the script once ever like second, now if i hold tab for a little too long it spams... its not a big problem but my key sensitivity is pretty high so its a little annoying if it repeats too fast. I tried changing the : While 1 Sleep(10) WEnd but maybe its not possible? since it jst registers every time i press tab. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 27, 2010 Moderators Share Posted July 27, 2010 basgen,Apology accepted! Try increasing the Sleep time just before you reset the HotKey in the function. That way the HotKey is not reset and so you cannot spam it.You will, of course, still get the typematic repeats of the the basic 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...
basgen Posted July 27, 2010 Author Share Posted July 27, 2010 Ah yes i tried to add it in the wrong spot, works now 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