Hawkysoft Posted November 8, 2013 Posted November 8, 2013 Can anyone be so kind to tell me what's wrong here? Basically what I want is when you press ALT + a number it goes to that website If _IsPressed(12) Then Local $i = 30 Do $i = $i + 1 If _IsPressed($i) Then goURL($i) EndIf Until $i = 39 EndIf It seems it goes stuck on the loop when pressing alt, might be that it skipped the number already however don't know another clean way to do this ;/
l3ill Posted November 8, 2013 Posted November 8, 2013 (edited) Hi Hawkysoft Is there some reason you dont want to use HotKeySet for this? Edited November 8, 2013 by billo My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Hawkysoft Posted November 8, 2013 Author Posted November 8, 2013 (edited) Hi Hawkysoft Is there some reason you dont want to use HotKey for this? Yeah I got an error with that as well >.< So basically I thought that would have been impossible... What I had was this... Local $i = 0 Do $i = $i + 1 HotKeySet("!" & $i, goURL($i)) Until $i = 9 Edited November 8, 2013 by Hawkysoft
l3ill Posted November 8, 2013 Posted November 8, 2013 If you just want to open a url with (ALT) + (#) then: HotKeySet("!9", "_URL") While 1 Sleep(28800) WEnd Func _URL() ShellExecute("www.autoitscript.com") EndFunc ;==>_f9 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Hawkysoft Posted November 8, 2013 Author Posted November 8, 2013 If you just want to open a url with (ALT) + (#) then: HotKeySet("!9", "_URL") While 1 Sleep(28800) WEnd Func _URL() ShellExecute("www.autoitscript.com") EndFunc ;==>_f9 But the problem is I don't want to add a numerous of functions, I like my scripts clean (since im learning as well you know) So isn't there a way to do it like you have all the numbers in it already? like how I shown before?
l3ill Posted November 8, 2013 Posted November 8, 2013 Not sure what you mean by numbers... Dont really need a count loop to call a function from a running script in this case. Wasnt really sure what you were doing, I got the idea from what you asked: Basically what I want is when you press ALT + a number it goes to that website My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
l3ill Posted November 8, 2013 Posted November 8, 2013 But IF you are learning/playing with loops that do stuff THEN Me too ! Local $iU = InputBox("Amount", "Enter Amount to count up to.") For $i = 1 To $iU Step +1 MsgBox(0, "Count up!", $i, .5) If $i = 5 Then ShellExecute("www.autoitscript.com") EndIf Next MsgBox(0, "Count up!", "Counted to: " & $iU, 3) My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
JohnOne Posted November 8, 2013 Posted November 8, 2013 I'm fairly sure that HotkeySet is best solution for this. Here is example of how you might employ it with just one function. #include <Array.au3> HotKeySet("!1", "_HotFunc") HotKeySet("!2", "_HotFunc") HotKeySet("!3", "_HotFunc") HotKeySet("!4", "_HotFunc") HotKeySet("!5", "_HotFunc") HotKeySet("!6", "_HotFunc") HotKeySet("!7", "_HotFunc") HotKeySet("!8", "_HotFunc") HotKeySet("!9", "_HotFunc") While 1 Sleep(1000) WEnd Func _HotFunc() Switch Int(StringRight(@HotKeyPressed, 1)) Case 1 ShellExecute("https://www.google.co.uk/") Case 2 ShellExecute("http://uk.yahoo.com/") Case 3 ShellExecute("http://www.autoitscript.com/forum/") EndSwitch EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Hawkysoft Posted November 8, 2013 Author Posted November 8, 2013 I'm fairly sure that HotkeySet is best solution for this. Here is example of how you might employ it with just one function. #include <Array.au3> HotKeySet("!1", "_HotFunc") HotKeySet("!2", "_HotFunc") HotKeySet("!3", "_HotFunc") HotKeySet("!4", "_HotFunc") HotKeySet("!5", "_HotFunc") HotKeySet("!6", "_HotFunc") HotKeySet("!7", "_HotFunc") HotKeySet("!8", "_HotFunc") HotKeySet("!9", "_HotFunc") While 1 Sleep(1000) WEnd Func _HotFunc() Switch Int(StringRight(@HotKeyPressed, 1)) Case 1 ShellExecute("https://www.google.co.uk/") Case 2 ShellExecute("http://uk.yahoo.com/") Case 3 ShellExecute("http://www.autoitscript.com/forum/") EndSwitch EndFunc Thank you! this is the most likely what I want, however the hotkeys can't i just loop em instead of writing all that text? to keep it more clean? or would that be bad for its performance?
mikell Posted November 8, 2013 Posted November 8, 2013 However if trouble using numpad this works for me : For $i = 1 to 9 HotKeySet("!{NUMPAD" & $i & "}", "_HotFunc") Next While 1 Sleep(1000) WEnd Func _HotFunc() Switch Int(StringMid(@HotKeyPressed, 9, 1)) Case 1 ShellExecute("https://www.google.co.uk/") Case 2 ShellExecute("http://uk.yahoo.com/") Case 3 ShellExecute("http://www.autoitscript.com/forum/") EndSwitch EndFunc
Solution JohnOne Posted November 8, 2013 Solution Posted November 8, 2013 (edited) Thank you! this is the most likely what I want, however the hotkeys can't i just loop em instead of writing all that text? to keep it more clean? or would that be bad for its performance? It's my opinion that for responsiveness, hotkeys are way to go. While _IsPressed(12) For $i = 30 To 39 If _IsPressed($i) Then goURL($i) ExitLoop 2 EndIf Next Sleep(10) WEnd Edited November 8, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
mikell Posted November 8, 2013 Posted November 8, 2013 I think so about hotkeys, else don't forget 60 to 69
Hawkysoft Posted November 8, 2013 Author Posted November 8, 2013 It's my opinion that for responsiveness, hotkeys are way to go. While _IsPressed(12) For $i = 30 To 39 If _IsPressed($i) Then goURL($i) ExitLoop 2 EndIf Next Sleep(10) WEnd thank you very much!
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