[AutoIT] Window Mover Source

10/17/2010 20:10 theoneofgod#1
Code:
    #NoTrayIcon
    #RequireAdmin
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    MsgBox(0, "Instructions", "Use the arrow keys on the keyboard to move the active window", 7)

    $vDLL= DllOpen("user32.dll")

    ; (Main) GUI
    $hGUI = GUICreate("Window Mover", 167, 62)
    GUISetBkColor(0)
    ;-

    ; (Main) Label
    GUICtrlCreateLabel("Movement pixels:", 18, 23, 86, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ;-

    ; (Main) Input
    $hInput_Pixel = GUICtrlCreateInput("5", 108, 19, 43, 21, BitOR($ES_AUTOHSCROLL, $WS_BORDER), $WS_EX_STATICEDGE)
    GUICtrlSetLimit(-1, 6, 1)
    ;-

    GUISetState(@SW_SHOW, $hGUI)

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case -3
             Exit
       EndSwitch

       If _IsPressed("25", $vDLL) Then ; left
          $iPos = WinGetPos("[active]")
          WinMove("[active]", "", $iPos[0] - GUICtrlRead($hInput_Pixel), $iPos[1])
       EndIf

       If _IsPressed("26", $vDLL) Then ; up
          $iPos = WinGetPos("[active]")
          WinMove("[active]", "", $iPos[0], $iPos[1] - GUICtrlRead($hInput_Pixel))
       EndIf

       If _IsPressed("27", $vDLL) Then ; right
          $iPos = WinGetPos("[active]")
          WinMove("[active]", "", $iPos[0] + GUICtrlRead($hInput_Pixel), $iPos[1])
       EndIf

       If _IsPressed("28", $vDLL) Then ; down
          $iPos = WinGetPos("[active]")
          WinMove("[active]", "", $iPos[0], $iPos[1] + GUICtrlRead($hInput_Pixel))
       EndIf

       Sleep(10)
    WEnd

    Func _IsPressed($sHexKey, $vDLL = '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($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
       If @error Then Return SetError(@error, @extended, False)
       Return BitAND($a_R[0], 0x8000) <> 0
    EndFunc   ;==>_IsPressed
10/23/2011 07:14 zhangjm9#2
good,!!!!!!!!!!!!!!!!
good!!!!!!!!!!!!!!!