Jump to content

spike_s2

Members
  • Posts

    7
  • Joined

  • Last visited

spike_s2's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Link to Larry's post. http://www.autoitscript.com/forum/index.php?showtopic=55694 His code is somewhat cryptic to me. If anyone could shade some light of the differences between the mouse hooks used in the previous post and Larry's hooks, you are welcome to do so.
  2. I found MrCreatoR's code which uses mouse hooks in order to capture mouse events. Following is the link to the post. http://www.autoitscript.com/forum/index.php?showtopic=64738 I modified the code accordingly and tested it in the directx game. Still not working !!! The program is unable to capture mouse events from ingame. The code I tested. Works well outside the game. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <MouseSetOnEvent_UDF.au3> #include <GuiConstants.au3> Opt('MustDeclareVars', 1) Global $LBLSTATE Global $MBState; 1-started 0-stoped $MBState=0 ;using middle mouse button to control program ;capturing middle mouse button and enabling function _Main() ;was unable to set any other mouse buttons then left or right. for my application wheel scroll would do as well ;middle mouse botton had the windows vista function even after capture ;extra mouse button did not work at all Func MouseWheelScroll() if $MBState == 0 then ;capture LMB, enable function _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "MousePrimaryDown") ;capture started $MBState=1 GUICtrlSetData($LBLSTATE,"Capture started") ElseIf $MBState == 1 Then ;stop capture _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT) $MBState=0 GUICtrlSetData($LBLSTATE,"Capture stopped") EndIf EndFunc Func MousePrimaryDown() ;process left mouse button click ;disable capture so we can send our sequence _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT) ;send sequence MouseClick("left") sleep(100) MouseClick("right") ;reenable capture for next sequence _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "MousePrimaryDown") EndFunc Func _Main() Local $MSG, $parent $parent=GUICreate("Mouse Controls", 440, 200, 100, 100) ; will create a dialog box $LBLSTATE = GUICtrlCreateInput("Initialised: Stopped", 180, 100, 120, 30, $ES_READONLY) GUICtrlSetTip(-1, "Program State: Press middle mouse button to start/stop the program") GUISetState() ;enable wheel scroll capture _MouseSetOnEvent( $MOUSE_WHELLSCROLL_EVENT, "MouseWheelScroll") ; Run the GUI until the dialog is closed While 1 Sleep ( 100 ) $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE ;reenable wheel scroll _MouseSetOnEvent( $MOUSE_WHELLSCROLL_EVENT) Exit EndSelect WEnd EndFunc ;==>_Main
  3. I need to capture the left mouse button click. I don't know of a way of doing that with Hotkey.
  4. Function _isPressed() not capturing keys ingame. It is working properly whenever the game is not running. The game is a directx game, which runs full screen. Following is a sample code. Please let me know how to make the autoit program capture the keys that are sent ingame. Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. ; $hexKey should entered as a string, don't forget the quotes! ; (yeah, layer. This is for you) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc ;==>_IsPressed ..... While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE Exit Case $MSG = $BTNSET ;_SetControls() ;GUICtrlSetData($MB1, $MB1Func) ;GUICtrlSetData($MB2, $MB2Func) EndSelect If _IsPressed("71") Then GUICtrlSetData($LBLSTATE, "Running") MsgBox(1,"","Capture") ;_ProcessKeys() EndIf WEnd
  5. Can someone confirm it isn't possible ?
  6. Is there a way of getting the pixels of the mouse pointer insted of the pixels underneath the pointer ? Pls let me know.
  7. I've managed to write the code below. Detection is partially working tho it is far from satisfactory. In resume, screen is divided in a couple of area and each area is searched for a number of pixels. The pixel closer to the geometrical mean (?) is chosen to aquire the target. So far, the size of the areas is customizable and also the number of pixels required to aquire a target. Func Scan() ___$shadevariation = GUICtrlRead($input_sv) ___$step = GUICtrlRead($input_step) ______for $i=0 to $nbAreas-1 _________scanArea($i) ______Next EndFunc Func scanArea($areaNb) ___$found=0 ___$gMeanX=1 ___$gMeanY=1 ___Dim $ppos ___Dim $storePos[$nbPixels][2] ___Dim $targetCoord ___for $i=0 to $nbMonster-1 ______for $c=0 to $nbPixels-1 _________$ppos=getPosition($areaNb, $i, $c) _________If $errorstatus == 0 Then __________________$found=$found+1 __________________$gMeanX=$gMeanX*$ppos[0]/100 __________________$gMeanY=$gMeanY*$ppos[1]/100 __________________$storePos[$c][0]=$ppos[0] __________________$storePos[$c][1]=$ppos[1] _________EndIf ______Next ___if $found >= $plimit Then ______$gMeanX=Int($gMeanX^(1/$found)*100) ______$gMeanY=Int($gMeanY^(1/$found)*100) ______$targetCoord=getTargetCoord($storePos,$gMeanX,$gMeanY,$found) ______aquireTarget($targetCoord[0],$targetCoord[1]) ___EndIf ___$found=0 ___$gMeanX=0 ___$gMeanY=0 ___Next EndFunc Func getPosition($areaNb, $monsterNb, $pixelNb) ___Dim $ppos ___$ppos=PixelSearch($areas[$areaNb][0][0],$areas[$areaNb][1][1],$areas[$areaNb][1][0],$areas[$areaNb][0][1],Dec($monsterPixelData[$monsterNb][$pixelNb]),$shadevariation,$step) ___If Not @error Then ______$errorstatus=0 ___else ______$errorstatus=1 ___endif ___return $ppos EndFunc Func getTargetCoord($coordPixels,$gMeanX,$gMeanY,$nbPix) ___$sX=0 ___$sY=0 ___Dim $coord[2] ___$coord[0]=$coordPixels[0][0] ___$coord[1]=$coordPixels[0][1] ___for $i=0 to $nbPix-1 ______If (ABS($coordPixels[$i][0] - $gMeanX)) < (ABS($coord[0] - $gmeanX)) Then $coord[0]=$coordPixels[$i][0] ______If (ABS($coordPixels[$i][1] - $gMeanY)) < (ABS($coord[1] - $gmeanY)) Then $coord[1]=$coordPixels[$i][1] ___Next ___return $coord EndFunc
×
×
  • Create New...