Jump to content
Sign in to follow this  
Hawkysoft

_IsPressed issue

Recommended Posts

Hawkysoft

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 ;/

Share this post


Link to post
Share on other sites
Hawkysoft

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 by Hawkysoft

Share this post


Link to post
Share on other sites
Hawkysoft

 

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?

Share this post


Link to post
Share on other sites
l3ill

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

Share this post


Link to post
Share on other sites
l3ill

But IF

    you are learning/playing with loops that do stuff THEN

:bye:    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)

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
Hawkysoft

 

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?

Share this post


Link to post
Share on other sites
mikell

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

Share this post


Link to post
Share on other sites
JohnOne

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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
mikell

I think so about hotkeys, else don't forget 60 to 69  :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×