mick200 Posted November 11, 2010 Share Posted November 11, 2010 Hello Everybody, I am having troubles with building a script that could be very handy for my daily work. I want it to do the following things: When i press "RCTRL+1" i want it to SEND the url "C:\FOLDER1" and then hit ENTER. And when i press "RCTRL+2" i want it to SEND the url "C:\FOLDER2" and then hit ENTER. Could someone help me with building this script ? I'm new to AutoIt. PS. Is it also possible to let the script run in the background the whole day, so i can use the hotkeys whenever i need them? Thanks in advance, Mick Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 11, 2010 Share Posted November 11, 2010 (edited) Check out _IsPressed and HotKeySet Edited November 11, 2010 by ZacUSNYR Link to comment Share on other sites More sharing options...
mick200 Posted November 11, 2010 Author Share Posted November 11, 2010 I tried _IsPressed but i can only use the Hotkey once then the script quits. Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 11, 2010 Share Posted November 11, 2010 It needs to be in a loop - i'd make it call a function. From the Example I assume you tried. While 1 Sleep ( 250 ) If _IsPressed("23", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") ExitLoop EndIf WEnd If you look at the example and try to understand it, it's starting the loop, taking a 250ms pause, then waiting for a key press. If the key press matches then it'll give you pop up msgbox and then it'll exit the loop, therefore it'll only run once. Removing the ExitLoop will keep it in the loop. Link to comment Share on other sites More sharing options...
mick200 Posted November 11, 2010 Author Share Posted November 11, 2010 This works thanks, now how do i add an extra line, this doesn't work. #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("A1"+"61", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") If _IsPressed("A1"+"62", $dll) Then MsgBox(0,"_IsPressed", "Other Key Pressed") EndIf WEnd DllClose($dll) Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 11, 2010 Share Posted November 11, 2010 (edited) #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("A1"+"61", $dll) Then MsgBox(0,"_IsPressed", "End Key Pressed") ElseIf _IsPressed("A1"+"62", $dll) Then ;You're doing a second If statement, try doing an ElseIf ;) MsgBox(0,"_IsPressed", "Other Key Pressed") EndIf WEnd DllClose($dll) Edit : Just looked at what you're doing, perhaps this is a lil bit cleaner? Don't check the other presses if Right Shift isn't held down. #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("A1", $dll) Then If _IsPressed("61", $dll) Then MsgBox(0,"_IsPressed", "1") If _IsPressed("62", $dll) Then MsgBox(0,"_IsPressed", "2") EndIf WEnd DllClose($dll) Edited November 11, 2010 by ZacUSNYR 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