Jump to content

while error


Recommended Posts

when starting this script it says:

line 10...

Func _rkey()

error: "While" statement has no matching "Wend" statement.

what i want to do is when $status = on everytime i press b it writes an "r" and when i press v it writes an "e"

and when $status = off it goes back to normal

HotKeySet("{b}", "_rkey") 
HotKeySet("{v}", "_ekey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status = "on"

While $status = "on"
    Func _rkey() 
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    EndFunc
    Func _ekey() 
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    EndFunc 
    WEnd

While 1 
    Sleep("100") 
WEnd 

Func _exit() 
$status = "off"
EndFunc  

Func _start() 
$status = "on"
EndFunc
Link to comment
Share on other sites

Try This

HotKeySet("{b}", "_rkey") 
HotKeySet("{v}", "_ekey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status = "on"

While $status = "on"
    _rkey() 
    _ekey() 
WEnd

Func _rkey() 
    Send("{r down}")
    sleep("200")
    Send("{r up}") 
EndFunc

Func _ekey() 
    Send("{e down}")
    sleep("200")
    Send("{e up}") 
EndFunc

Edit: I just took another look, that will prolly not get what you want, try this instead

HotKeySet("{b}", "_rkey") 
HotKeySet("{v}", "_ekey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status = "on"

Func _rkey() 
    If $status="on" Then
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    EndIf
EndFunc

Func _ekey() 
    If $status="on" Then
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    EndIf
EndFunc
Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

wow thanks alot, now im using this:

HotKeySet("{v}", "_rkey") 
HotKeySet("{c}", "_ekey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status="on"

Func _rkey() 
    If $status="on" Then
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    EndIf
EndFunc

Func _ekey() 
    If $status="on" Then
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    EndIf
EndFunc

Func _exit()
    $status="off"
EndFunc

Func _start()
    $status="on"
EndFunc

While 1
    Sleep("100")
WEnd

now when status="off" i cant use the key v and c, they dont type anything

btw, how can i post the code in autoit thingy

Link to comment
Share on other sites

[ autoit ] put code here [ / autoit] Just delete spaces in the brackets

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

HotKeySet("{v}", "_rkey") 
HotKeySet("{c}", "_ekey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status="on"

Func _rkey() 
    If $status="on" Then
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    EndIf
EndFunc

Func _ekey() 
    If $status="on" Then
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    EndIf
EndFunc

Func _exit()
    $status="off"
EndFunc

Func _start()
    $status="on"
EndFunc

While 1
    Sleep("100")
WEnd

ok here´s the code again,

what do you mean delete spaces between brackets?

i just need that when its $status="off" i may type normal, the c and v are disabled :mellow:

Link to comment
Share on other sites

heres a script i tried

HotKeySet("{v}", "_vkey") 
HotKeySet("{c}", "_ckey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status="on"

Func _vkey() 
    If $status="on" Then
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    ElseIf $status="off" Then
        send("{v}")
    EndIf
EndFunc

Func _ckey() 
    If $status="on" Then
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    ElseIf $status="off" Then
        Send("{c}")
    EndIf   
EndFunc

Func _exit()
    $status="off"
EndFunc

Func _start()
    $status="on"
EndFunc

While 1
    Sleep("100")
WEnd

now when i use the keys in "off" mode it says smthig like "script shut down due to evade an overstack" smthing like that

Link to comment
Share on other sites

heres a script i tried

HotKeySet("{v}", "_vkey") 
HotKeySet("{c}", "_ckey") 
HotKeySet("{PAUSE}", "_exit") 
HotKeySet("{PRINTSCREEN}", "_start")

$status="on"

Func _vkey() 
    If $status="on" Then
        Send("{r down}")
        sleep("200")
        Send("{r up}") 
    ElseIf $status="off" Then
        send("{v}")
    EndIf
EndFunc

Func _ckey() 
    If $status="on" Then
        Send("{e down}")
        sleep("200")
        Send("{e up}") 
    ElseIf $status="off" Then
        Send("{c}")
    EndIf   
EndFunc

Func _exit()
    $status="off"
EndFunc

Func _start()
    $status="on"
EndFunc

While 1
    Sleep("100")
WEnd

now when i use the keys in "off" mode it says smthig like "script shut down due to evade an overstack" smthing like that

This is because you are setting a hotkey "X" and then in the function it calls, you are sending "X" again which inturn calls the function again, putting it in an infinite loop.

To resolve that behavior:

Unregister the hotkey, then send the key, then re register the hotkey.

Like this:

HotKeySet("{v}", "_rkey")
HotKeySet("{c}", "_ekey")
HotKeySet("{PAUSE}", "_exit")
HotKeySet("{PRINTSCREEN}", "_start")

$status = "on"

Func _rkey()
    If $status = "on" Then
        Send("{r down}")
        Sleep("200")
        Send("{r up}")
    Else
        HotKeySet("{v}")
        Send('v')
        HotKeySet("{v}", "_rkey")
    EndIf
EndFunc   ;==>_rkey

Func _ekey()
    If $status = "on" Then
        Send("{e down}")
        Sleep("200")
        Send("{e up}")
    Else
        HotKeySet("{c}")
        Send('c')
        HotKeySet("{c}", "_ekey")
    EndIf
EndFunc   ;==>_ekey

Func _exit()
    $status = "off"
EndFunc   ;==>_exit

Func _start()
    $status = "on"
EndFunc   ;==>_start

While 1
    Sleep(10)
WEnd
Edited by danwilli
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...