Jump to content

AlmarM

Active Members
  • Posts

    1,675
  • Joined

  • Last visited

  • Days Won

    1

Community Answers

  1. AlmarM's post in Making your own mouse move? (confusing) was marked as the answer   
    I must say I'm rather confused as well, but I gave it a try. Here's what I came up with:

    HotKeySet("{ESC}", "_Exit") Global Const $iStepSize = 32 Global $iX = 0, $iY = 0 Global $iTargetX, $iTargetY Global $hWnd = GUICreate("", 512, 512) Global $hTargetLabel = GUICtrlCreateLabel("", -$iStepSize, -$iStepSize, $iStepSize, $iStepSize) GUICtrlSetBkColor(-1, 0xFF0000) Global $hLabel = GUICtrlCreateLabel("", $iX, $iY, $iStepSize, $iStepSize) GUICtrlSetBkColor(-1, 0x0) _RandomizeTargetLocation() GUISetState() While 1     Switch GUIGetMsg()         Case -3             Exit     EndSwitch     ; loop     If ($iX < $iTargetX) Then $iX += $iStepSize     If ($iX > $iTargetX) Then $iX -= $iStepSize     If ($iY < $iTargetY) Then $iY += $iStepSize     If ($iY > $iTargetY) Then $iY -= $iStepSize     GUICtrlSetPos($hLabel, $iX, $iY)     If ($iX == $iTargetX And $iY == $iTargetY) Then         Sleep(1000)         _RandomizeTargetLocation()     EndIf     Sleep(300) WEnd Func _RandomizeTargetLocation()     $iTargetX = Int(Random(0, 512, 1) / $iStepSize) * $iStepSize     $iTargetY = Int(Random(0, 512, 1) / $iStepSize) * $iStepSize     GUICtrlSetPos($hTargetLabel, $iTargetX, $iTargetY) EndFunc Func _Exit()     Exit EndFunc
  2. AlmarM's post in return function? - simple question was marked as the answer   
    I'm not entirely sure what you want, but is this something you need?

    Global $bSomething = False Global $bSomethingElse = (Not $bSomething) MyFunc() Func MyFunc()     If ($bSomething) Then         Return MyFunc_Return(0)     ElseIf ($bSomethingElse) Then         Return MyFunc_Return(1)     Else         Return MyFunc_Return(2)     EndIf EndFunc Func MyFunc_Return($iReturnCode)     Switch ($iReturnCode)         Case 0             MsgBox(0, "Code #0", "Something for code 0.")         Case 1             MsgBox(0, "Code #1", "Do something else for the code 1?")         Case 2             MsgBox(0, "Code #2", "Maybe something for the 'else' here?")     EndSwitch     Return $iReturnCode EndFunc
×
×
  • Create New...