Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/12/2011 in all areas

  1. OK, so to make it simple use StringSplit() as suggested by rcmaehl >> #include <Array.au3> Global $aArray $aArray = _GetHotFixes() _ArrayDisplay($aArray) Func _GetHotFixes() Local $oColItems, $oWMIService, $sOutput $oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") $oColItems = $oWMIService.ExecQuery("Select HotFixID From Win32_QuickFixEngineering", "WQL", 0x30) For $oItem In $oColItems $sOutput &= $oItem.HotFixID & ";" Next Return StringSplit(StringTrimRight($sOutput, 1), ";") EndFunc ;==>_GetHotFixes
    1 point
  2. MrMitchell

    Self Update

    Examples: One Another Another
    1 point
  3. So who you calling a troll?... bot boy. If your to old to click the controls in a game and not smart enough to write your own bot then give up without posting here in AutoIt help forum. It's obvious your intent is to get a script written for you just to help you play a game. Also obvious is that this forum has rules against posting about automating games, which you refuse to adhere to. The ppl you refer to as trolls are users that could probably actually help you, but won't. As a guess from your own admission that your wanting help automating a game it won't be long before your thread is locked.
    1 point
  4. Never worked with PixelSearch before, but I think something like this would probably do it: Do PixelSearch(blah blah blah) Until Pixelsearch(blah blah blah) NOT @error
    1 point
  5. The mouse events should be captured with WH_MOUSEHOOK and MouseProc. It should be very similar to the keyboard hook. http://msdn.microsoft.com/en-us/library/ms644988%28VS.85%29.aspx Using _WinAPI_Keybd_Event as an example, you should be able to create the dllcall for mouse_event, too
    1 point
  6. The lowlevel-hook is not a good choice. Here is an example for WH_KEYBOARDHOOK. Click start, while the GUI is active type some keys, then stop, then choose an edit-area as target and press F9 #include<WinAPI.au3> #include<WinAPIEx.au3> Global $sStoredData = "", $fRecord = False HotKeySet("{F9}", "_Resend") $myGUI = GUICreate("") $btn = GUICtrlCreateButton("Start", 10, 10) GUISetState() Global Const $ghcbKeyboardProc = DllCallbackRegister("_KeyboardProc", "lresult", "int;wparam;lparam") Global Const $ghKeybordHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD, DllCallbackGetPtr($ghcbKeyboardProc), 0, _WinAPI_GetCurrentThreadId()) OnAutoItExitRegister("_gc") While 1 Switch GUIGetMsg() Case -3 Exit Case $btn $fRecord = Not $fRecord GUICtrlSetData($btn, "Start") If $fRecord Then GUICtrlSetData($btn, "Stop") EndSwitch WEnd Func _Resend() If WinActive($myGUI) Then Return $s = $sStoredData $sStoredData = "" ConsoleWrite($s & @LF) For $s In StringSplit($s, "|", 2) If $s = "" Then ContinueLoop $a = StringSplit($s, ";", 2) $iFlags = 0 If $a[1] = "true" Then $iFlags = BitOR($iFlags, $KEYEVENTF_EXTENDEDKEY) If $a[2] = "true" Then $iFlags = BitOR($iFlags, $KEYEVENTF_KEYUP) _WinAPI_Keybd_Event(Number($a[0]), $iFlags) Next EndFunc Func _gc() _WinAPI_UnhookWindowsHookEx($ghcbKeyboardProc) EndFunc Func _KeyboardProc($nCode, $wParam, $lParam) If $nCode < 0 Or Not $fRecord Then Return _WinAPI_CallNextHookEx($ghKeybordHook, $nCode, $wParam, $lParam) Local $nVKeyCode = Number($wParam) Local $fExtendedKey = BitAND($lParam, 2^24) <> 0 Local $fKeyUp = BitAND($lParam, 2^31) <> 0 $sStoredData &= $nVKeyCode & ";" & $fExtendedKey & ";" & $fKeyUp & "|" Return 0xDEAD ; kill the key event Return _WinAPI_CallNextHookEx($ghKeybordHook, $nCode, $wParam, $lParam) EndFunc PS: This should cover all keyboard input, even Winkey, Ctrl etc. As a result, keycombinations like Ctrl-C, Ctrl-V can be sent, too.
    1 point
  7. Play around with this function off the help docs, shows you just exactly how to do it right there. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Opt('MustDeclareVars', 1) Global $hHook, $hStub_KeyProc, $buffer = "" _Main() Func _Main() OnAutoItExitRegister("Cleanup") Local $hmod $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) MsgBox(4096, "", "Click OK, then in notepad type..." & _ @LF & @LF & "Jon" & @LF & "AutoIt" & @LF & @LF & "Press Esc to exit script") Run("Notepad") WinWait("Untitled -") WinActivate("Untitled -") While 1 Sleep(10) WEnd EndFunc ;==>_Main Func EvaluateKey($keycode) If (($keycode > 64) And ($keycode < 91)) _ ; a - z Or (($keycode > 96) And ($keycode < 123)) _ ; A - Z Or (($keycode > 47) And ($keycode < 58)) Then ; 0 - 9 $buffer &= Chr($keycode) Switch $buffer Case "Jon" ToolTip("What can you say?") Case "AutoIt" ToolTip("AutoIt Rocks") EndSwitch ElseIf ($keycode > 159) And ($keycode < 164) Then Return ElseIf ($keycode = 27) Then ; esc key Exit Else $buffer = "" EndIf EndFunc ;==>EvaluateKey ;=========================================================== ; callback function ;=========================================================== Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf If $wParam = $WM_KEYDOWN Then EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode")) Else Local $flags = DllStructGetData($tKEYHOOKS, "flags") Switch $flags Case $LLKHF_ALTDOWN ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF) Case $LLKHF_EXTENDED ConsoleWrite("$LLKHF_EXTENDED" & @CRLF) Case $LLKHF_INJECTED ConsoleWrite("$LLKHF_INJECTED" & @CRLF) Case $LLKHF_UP ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF) EndSwitch EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc ;==>Cleanup
    1 point
  8. I had this lying around >> Func _7Zip_Extract($sZipFile, $sDestinationFolder = @ScriptDir, $sPassword = "") If FileExists($sZipFile) = 0 Then Return SetError(1, 0, 0) EndIf If StringRight($sDestinationFolder, 1) <> "\" Then $sDestinationFolder &= "\" EndIf If FileExists($sDestinationFolder) = 0 Then DirCreate($sDestinationFolder) EndIf If $sPassword <> "" Then $sPassword = "-p" & '"' & $sPassword & '" ' EndIf If FileExists(@ScriptDir & "\" & "7za.exe") = 0 Then FileInstall("7za.exe", @ScriptDir & "\" & "7za.exe", 0) EndIf Return RunWait('7za.exe' & ' x "' & $sZipFile & '" ' & $sPassword & "-y -o" & '"' & $sDestinationFolder & '"', "", @SW_HIDE) EndFunc ;==>_7Zip_Extract
    1 point
  9. Yashied

    Center an image formula

    #Include <Math.au3> $ImageWidth = 1280 $ImageHeight = 960 $AreaWidth = 355 $AreaHeight = 275 $Scale = _Min($AreaWidth / $ImageWidth, $AreaHeight / $ImageHeight) $NewImageWidth = $ImageWidth * $Scale $NewImageHeight = $ImageHeight * $Scale ConsoleWrite(Round($NewImageWidth) & 'x' & Round($NewImageHeight) & @CR)
    1 point
×
×
  • Create New...