psgame_freak Posted August 3, 2006 Posted August 3, 2006 Let say I have a hotkey set on 'A'. Now, if user presses right arrow keythen 'A' it will perform the function. If user presses left arrow key then 'A' it will perform a different function? So A then Right arrow = do something A then Left arrow = do something else
zfisherdrums Posted August 3, 2006 Posted August 3, 2006 Let say I have a hotkey set on 'A'. Now, if user presses right arrow keythen 'A' it will perform the function. If user presses left arrow key then 'A' it will perform a different function? So A then Right arrow = do something A then Left arrow = do something else Something like this? expandcollapse popupHotKeySet("{RIGHT}", "SetRightModifier") HotKeySet("{LEFT}", "SetLeftModifier") HotKeySet("a", "ModifiedAction") Global $Modifier = "" While 1 Sleep(100) Wend Func ModifiedAction() If $Modifier = "Right" then FunctionA() ElseIf $Modifier = "Left" then FunctionB() Else FunctionC() EndIf $Modifier = "" EndFunc Func SetRightModifier() $Modifier = "Right" EndFunc Func SetLeftModifier() $Modifier = "Left" EndFunc Func FunctionA() MsgBox(0,"", "Function A") EndFunc Func FunctionB() MsgBox(0,"", "Function B") EndFunc Func FunctionC() MsgBox(0,"", "Function C") EndFunc Let me know if this helps. Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
psgame_freak Posted August 3, 2006 Author Posted August 3, 2006 That gave me the idea, but what about a record the last word that was typed? Thank you
zeroZshadow Posted August 3, 2006 Posted August 3, 2006 i think i'll be needing this too making a keychanger for a game, but i need to to wait for a keypress and then return the keypress. so is there any way to make a loop with hex ?? (for the _IsPressed function) i think this might help the fellow here also *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 Hey Functions work according to the combination of keys pressed. Now my problem is I want right button to also go right(its normal use) at the same time assigning "right" to modifier variable. When I go: Func SetRightModifier() $Modifier = "right" Send("{RIGHT}") EndFunc Func SetLeftModifier() $Modifier = "left" Send("{LEFT}") EndFunc I get a recursive error because it calls itself again
zeroZshadow Posted August 5, 2006 Posted August 5, 2006 Func _GetKey() while 1 for $i = 1 to 165 if _IsPressed(Hex($i,2)) Then return $i EndIf Next wend EndFunc this waits for a user to press a button, then returns the button pressed *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 Could you tell me how that works? When do I call that function? Whats in the _IsPressed function? Thank you
Paulie Posted August 5, 2006 Posted August 5, 2006 Could you tell me how that works? When do I call that function? Whats in the _IsPressed function? Thank youHis code works because it takes every number between 1 and 165, and gets what the mean in hex, and then says if the hex of that number is equal to the button pressed, then return that value and _IsPressed is part of 'Misc.au3' so make sure you put #Include <Misc.au3> at the top of your script
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 Here's what my Misc.au3 says: #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with Intenet. ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Function Name: _Iif() ; Description: Perform a boolean test within an expression. ; Parameter(s): $f_Test - Boolean test. ; $v_TrueVal - Value to return if $f_Test is true. ; $v_FalseVal - Value to return if $f_Test is false. ; Requirement(s): None. ; Return Value(s): One of $v_TrueVal or $v_FalseVal. ; Author(s): Dale (Klaatu) Thompson ; ;=============================================================================== Func _Iif($f_Test, $v_TrueVal, $v_FalseVal) If $f_Test Then Return $v_TrueVal Else Return $v_FalseVal EndIf EndFunc No _IsPressed. And when I replace _IsPressed with _Iif i get: Incorrect number parameters in function call
Paulie Posted August 5, 2006 Posted August 5, 2006 Here's what my Misc.au3 says: #include-once ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.0 ; Language: English ; Description: Functions that assist with Intenet. ; ; ------------------------------------------------------------------------------ ;=============================================================================== ; ; Function Name: _Iif() ; Description: Perform a boolean test within an expression. ; Parameter(s): $f_Test - Boolean test. ; $v_TrueVal - Value to return if $f_Test is true. ; $v_FalseVal - Value to return if $f_Test is false. ; Requirement(s): None. ; Return Value(s): One of $v_TrueVal or $v_FalseVal. ; Author(s): Dale (Klaatu) Thompson ; ;=============================================================================== Func _Iif($f_Test, $v_TrueVal, $v_FalseVal) If $f_Test Then Return $v_TrueVal Else Return $v_FalseVal EndIf EndFunc No _IsPressed. And when I replace _IsPressed with _Iif i get: Incorrect number parameters in function callAre you running beta? and if so, is this misc.au3 in the BETA include folder; C:/Program Files/Autoit3/Beta/Include
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 The first download on this pagehttp://www.autoitscript.com/autoit3/downloads.php
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 Come one, anyone? This is my last problem then my program will be up and running.
NELyon Posted August 5, 2006 Posted August 5, 2006 your running the production download beta at the bottom of the downloads page
Paulie Posted August 5, 2006 Posted August 5, 2006 The first download on this pagehttp://www.autoitscript.com/autoit3/downloads.phpNo its the last one with the red icon
zeroZshadow Posted August 5, 2006 Posted August 5, 2006 the one that says BETA *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
psgame_freak Posted August 5, 2006 Author Posted August 5, 2006 (edited) Bah, still doesn't work +.+ expandcollapse popupGlobal $Modifier = "" HotKeySet("{RIGHT}", "SetRightModifier") HotKeySet("{LEFT}", "SetLeftModifier") Func _GetKey() while 1 for $i = 1 to 165 if _IsPressed(Hex($i,2)) Then return $i EndIf Next wend EndFunc ;----- Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') ; $hexKey must be the value of one of the keys. ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is. Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed ;------ Func SetRightModifier() $Modifier = "right" _GetKey() EndFunc Func SetLeftModifier() $Modifier = "left" _GetKey() EndFunc ;--- I don't get errors this time. But it's not returning right (no pun intended). Edited August 5, 2006 by psgame_freak
zeroZshadow Posted August 6, 2006 Posted August 6, 2006 what do you want your program todo then ?? *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
psgame_freak Posted August 6, 2006 Author Posted August 6, 2006 I want it so when I press Right key, it will assign right to $Modifier and move cursor to right. But right now, it's just assigning "right" to $Modifier but not moving the cursor to the right. I tried Func SetRightModifier() $Modifier = "right" send("{RIGHT}") EndFunc But this does not work because it calls itself again.
Paulie Posted August 6, 2006 Posted August 6, 2006 But this does not work because it calls itself again.Thats why you use "_IsPressed", it doesn't steal keys expandcollapse popupGlobal $Modifier = "" If _IsPressed(##) then;Right arrow SetRightModifier() Endif If _IsPressed(##) then;Left arrow SetLeftModifier() Endif Func _GetKey() while 1 for $i = 1 to 165 if _IsPressed(Hex($i,2)) Then return $i EndIf Next wend EndFunc ;----- Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') ; $hexKey must be the value of one of the keys. ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is. Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed ;------ Func SetRightModifier() $Modifier = "right" _GetKey() EndFunc Func SetLeftModifier() $Modifier = "left" _GetKey() EndFunc
psgame_freak Posted August 6, 2006 Author Posted August 6, 2006 What do I put in the (##)? Where can I find the hex table of keys? Thanks alot for the replies and bearing with me
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