Jump to content

Coords


Recommended Posts

How do I check if an image is in a specific location in a gui? and if so take a certain action?

ControlGetPos?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

ControlGetPos?

$calling = GUICreate("", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI)
$callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24)
Case $msg = $callingpic
    $cPos = ControlGetPos("Full Tilt Buddy List - v1.0", "", $calling)
    MsgBox(0, "", $cPos[0] & "," & $cPos[1])

All it ever returns is 0,0

How do I fix this?

Edited by chssoccer
Link to comment
Share on other sites

Try with WinGetPos.

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

Try with WinGetPos.

It returns like 443,261 which I think are the Screen Coords of the pic. But how can I get the relative active client coords?

EDIT:

Never mind, I subracted its starting coords from the screen coords.

Edited by chssoccer
Link to comment
Share on other sites

Ok, the first question is solved but now I have another problem. I create a moveable picture and what I want is once I move that picture out of its starting location which is 5,5 in window coords it will automatically re-create a new picture in the other pictures place while leaving the other picture where it was moved to. But when I do this it messes up.

Case $msg = $callingpic
                $gp = WinGetPos($calling)
                $mp = MouseGetPos()
                While _IsPressed("1")
                $cp = MouseGetPos()
                WinMove($calling,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1])
                $cPos = WinGetPos("calling", "")
                $cPosX = $cPos[0] - 438
                $cPosY = $cPos[1] - 256
                If $cPosX = "5" AND $cPosY = "5" Then; If pic is in place
                ; do nothing
                Else
                    $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI)
                    $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24); Create new pic
                EndIf
            WEnd
Link to comment
Share on other sites

Does it require it all to reproduce the problem you're having?

Edit:

Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState())

Edited by FreeFry
Link to comment
Share on other sites

Does it require it all to reproduce the problem you're having?

Edit:

Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState())

No, but I think this is all that has to do with my question.

Func CreateHudGUI(); Creates the HUD interface
     $hudGUI = GUICreate("Heads-up Display Stickers", 150, 250)
     GUISetState()
     GUISetBkColor(0xF2F2F2, $hudGUI)
     WinSetOnTop("Heads-up Display Stickers", "", 1)
     $exit = GUICtrlCreateButton("Close", 5, 233, 40, 15)
     GUICtrlSetFont(-1, 8, 400, -1, "Arial Bold")
     $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI)
     $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24)
     GUISetState(@SW_SHOW,$calling)

     While 1
            $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_Event_Close
                GUISetState(@SW_HIDE, $hudGUI)
            Case $msg = $exit
                GUIDelete($hudGUI)
                ExitLoop
            Case $msg = $callingpic
                $gp = WinGetPos($calling)
                $mp = MouseGetPos()
                While _IsPressed("1")
                                     $cp = MouseGetPos()
                                     WinMove($calling,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1])
                     $cPos = WinGetPos("calling", "")
                     $cPosX = $cPos[0] - 438
                     $cPosY = $cPos[1] - 256
                     If $cPosX = "5" AND $cPosY = "5" Then; If pic is in place
               ; do nothing
                     Else
                    MsgBox(0, "", "")
                    $calling = GUICreate("calling", 24, 24, 5, 5,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hudGUI)
                    $callingpic = GUICtrlCreatePic(@scriptdir & "\poker icons\calling.gif", 0, 0, 24, 24); Create new pic
                EndIf
            WEnd
       Wend
EndFunc
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

Does it require it all to reproduce the problem you're having?

Edit:

Also, why're you creating a new GUI on the line just above the GuiCtrlCreatePic, that might be what's messing up(because that window will not be shown, unless you do GuiSetState())

I have no idea. :D

While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

I have no idea. :D

Hmm, you're wanting to be able to move the picture outside of the "main" gui's window, am I correct? If that's the case then it explains why you're creating a new Gui to be able to do that. :P

Still, have you tried adding a GuiSetState() (to make the new gui visible) after creating the picture? Might solve the problem...

Link to comment
Share on other sites

Hmm, you're wanting to be able to move the picture outside of the "main" gui's window, am I correct? If that's the case then it explains why you're creating a new Gui to be able to do that. :D

Still, have you tried adding a GuiSetState() (to make the new gui visible) after creating the picture? Might solve the problem...

Edit:

-Solved-

Much thanks to FreeFry.

8)

Edited by FireLordZi
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

Hihi, no problemo. Was a little slow to catch on what you where trying to do at first. :D

Edit:

I took the libery to optimize/clean it up a little(and also add a few features, like being able to move the newly created "stickys" after they have been created and positonized), I hope you don't mind:

#include <guiconstants.au3>
#include <misc.au3>
#include <array.au3>

Dim $Picture = @ScriptDir & "\toot.gif"

Dim $aGUIHandles[1] = [GUICreate("Heads-up Display Stickers", 150, 250)]

$exit = GUICtrlCreateButton("Close", 5, 233, 40, 15)
$pic = GUICtrlCreatePic(@ScriptDir & "\toot.gif", 0, 0, 24, 24)

GUISetBkColor(0xF2F2F2, $aGUIHandles[0])
GUICtrlSetFont($exit, 8, 400, -1, "Arial Bold")
WinSetOnTop($aGUIHandles[0], "", 1)

GUISetState()

While 1
    
    Switch GUIGetMsg()
        Case $GUI_Event_Close
            GUISetState(@SW_HIDE, $aGUIHandles[0])
        Case $exit
            Exit
        Case $pic
            _HandleChildGui()
    EndSwitch
    
    If _IsPressed("1") Then
        For $i = 1 To UBound($aGUIHandles) - 1
            If WinActive($aGUIHandles[$i]) Then _HandleChildGui($aGUIHandles[$i])
        Next
    EndIf
    
WEnd

Func _HandleChildGui($i_ChildHandle = 0)
    
    If $i_ChildHandle Then
        GUISwitch($i_ChildHandle)
    Else
        $i_ChildHandle = GUICreate("", 24, 24, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $aGUIHandles[0])
        GUICtrlCreatePic($Picture, 0, 0, 24, 24)
        GUISetState()
    EndIf
    
    While _IsPressed("1")
        WinMove($i_ChildHandle, "", MouseGetPos(0), MouseGetPos(1))
    WEnd
    
    ReDim $aGUIHandles[UBound($aGUIHandles) + 1]
    $aGUIHandles[UBound($aGUIHandles) - 1] = $i_ChildHandle
    
    GUISwitch($aGUIHandles[0])
    
EndFunc   ;==>_HandleChildGui
Edited by FreeFry
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...