Jump to content

_IsPressed .. works but key function still working


 Share

Recommended Posts

Hi all, thanks for your time:

I've just coded that little script, as you can see thats working great:

#Include <Misc.au3>

Global $spd=5
$esc=_IsPressed('1B')

While $esc<>1

$esc=_IsPressed('1B')
$left=_IsPressed('25')
$right=_IsPressed('27')
$up=_IsPressed('26')
$down=_IsPressed('28')
$enter=_IsPressed('0D')

$pos=MouseGetPos()
Select
Case $left=1    
    MouseMove( $pos[0]-$spd, $pos[1],0)
Case $right=1 
    MouseMove( $pos[0]+$spd, $pos[1],0)
Case $up=1
    MouseMove( $pos[0], $pos[1]-$spd,0)
Case $down=1
    MouseMove( $pos[0], $pos[1]+$spd,0)
Case $enter=1
    MouseClick ( 'left')
EndSelect
Wend

But when you use it, and press for exemple : left arrow, it really send left arrow... its really a problem when i press enter to clic, it sometimes add carriage return of press whatever button.

How can I disable key's normal function ?

Thanks a lot

Sorry for my Bad English.
Link to comment
Share on other sites

hotkeyset() disables the keys normal function.

replace this .

$esc=_IsPressed('1B')
$left=_IsPressed('25')
$right=_IsPressed('27')
$up=_IsPressed('26')
$down=_IsPressed('28')
$enter=_IsPressed('0D')

with this.

$esc=_IsPressed('1B')
$left=hotkeyset('{left}')
$right=hotkeyset('{right}')
$up=hotkeyset('{up}')
$down=hotkeyset('{down}')
$enter=hotkeyset('{enter}')
Link to comment
Share on other sites

hotkeyset() disables the keys normal function.

Funny you refer to the helpfile, because to me that's at least what seems to be said in the helpfile...

When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application...

Oops, this reminds me of something...
Link to comment
Share on other sites

Helge, I see why you are confused. When doing exactly as told, e.g. replacing the _IsPressed function by HotKeySet.. It does not work as expected. Run this piece of code and see what it does:

#Include <Misc.au3>

Global $spd=5
$esc=_IsPressed('1B')

While $esc<>1
$esc=_IsPressed('1B')
$left=hotkeyset('{left}')
$right=hotkeyset('{right}')
$up=hotkeyset('{up}')
$down=hotkeyset('{down}')
$enter=hotkeyset('{enter}')

$pos=MouseGetPos()
Select
Case $left=1   
    MouseMove( $pos[0]-$spd, $pos[1],0)
Case $right=1
    MouseMove( $pos[0]+$spd, $pos[1],0)
Case $up=1
    MouseMove( $pos[0], $pos[1]-$spd,0)
Case $down=1
    MouseMove( $pos[0], $pos[1]+$spd,0)
Case $enter=1
    MouseClick ( 'left')
EndSelect
Wend
Link to comment
Share on other sites

oh jesus my lord. du e en kuk manadar.

#Include <Misc.au3>

Global $spd=5
$esc=_IsPressed('1B')

While $esc<>1
$esc=_IsPressed('1B')
$left=hotkeyset('{left}','ost')
$right=hotkeyset('{right}','ost')
$up=hotkeyset('{up}','ost')
$down=hotkeyset('{down}','ost')
$enter=hotkeyset('{enter}','ost')
Wend


func ost()
$pos=MouseGetPos()
Select
Case @HotKeyPressed = '{left}'
    MouseMove( $pos[0]-$spd, $pos[1],0)
Case @HotKeyPressed = '{right}'
    MouseMove( $pos[0]+$spd, $pos[1],0)
Case @HotKeyPressed = '{up}'
    MouseMove( $pos[0], $pos[1]-$spd,0)
Case @HotKeyPressed = '{down}'
    MouseMove( $pos[0], $pos[1]+$spd,0)
Case @HotKeyPressed = '{enter}'
    MouseClick ( 'left')
EndSelect
endfunc
Link to comment
Share on other sites

@Manadar : I was only quoting his statement and not his code, and as far as I know it's not a load of crap.

His code is, but not his statement.

du e en kuk manadar.

Just so that you know it Manadar... if ignoring the typo this would be translated into :

"You are a cock Manadar" - For some reason I don't think he's thinking of the male chicken.

Edited by Helge
Link to comment
Share on other sites

oh jesus my lord. du e en kuk manadar.

Lik me bolle reet en leer AutoIt sukkel. :whistle:

Dim $spd=5

HotKeySet("{ESC}", "Terminate")

HotKeySet("{LEFT}", "Left")
HotKeySet("{RIGHT}", "Right")
HotKeySet("{UP}", "Up")
HotKeySet("{DOWN}", "Down")

HotKeySet("{ENTER}", "Enter")

While 1
    Sleep(0xFFFFFF)
WEnd

Func Left()
    $pos=MouseGetPos()
    MouseMove( $pos[0]-$spd, $pos[1],0)
EndFunc

Func Right()
    $pos=MouseGetPos()
     MouseMove( $pos[0]+$spd, $pos[1],0)
EndFunc

Func Up()
    $pos=MouseGetPos()
    MouseMove( $pos[0], $pos[1]-$spd,0)
EndFunc

Func Down()
    $pos=MouseGetPos()
    MouseMove( $pos[0], $pos[1]+$spd,0)
EndFunc

Func Enter()
    MouseClick("Left")
EndFunc

Func Terminate()
    Exit
EndFunc

: Thanks Helge, for point that out..

Edited by Manadar
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...