Jump to content

Placed icons won't move


Recommended Posts

I have a script that creates a gui about as small as an icon and I overlayed a picture file onto it so it looks like just like an icon.

I move this icon all over my desktop and when I move it from its starting position another one is created in it's place. Well when I place the icon/gui I can't move it anymore. How can I improve my code so I can move it after it is placed?

#include <GUIConstants.au3>
#include <Misc.au3>

$hudGUI = GUICreate("", 150, 250)
GUISetState()
GUISetBkColor(0xF2F2F2, $hudGUI)
WinSetOnTop("", "", 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
                GUIDelete($hudGUI)
                ExitLoop
            Case $msg = $exit
                GUISetState(@SW_HIDE, $hudGUI)
            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
                WEnd
                If Not ($cPosX = "5"  And $cPosY = "5") Then
                    $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
                    GUISetState()
                EndIf
        EndSelect
Wend

Help and suggestions would be greatly appreciated...

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

Alright, your code has an extra part that is causing your problem. I commented it out, try this: (I also changed the picture directory so you might need to change that back.)

#include <GUIConstants.au3>
#include <Misc.au3>

$hudGUI = GUICreate("", 150, 250)
GUISetState()
GUISetBkColor(0xF2F2F2, $hudGUI)
WinSetOnTop("", "", 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 & "\calling.gif", 0, 0, 24, 24)
GUISetState(@SW_SHOW,$calling)

$cPosX = 0
$cPosY = 0

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_Event_Close
                GUIDelete($hudGUI)
                ExitLoop
            Case $msg = $exit
                GUISetState(@SW_HIDE, $hudGUI)
            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
                WEnd
;~               If Not ($cPosX = "5"  And $cPosY = "5") Then
;~                   $calling = GUICreate("calling", 24, 24, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hudGUI)
;~                   $callingpic = GUICtrlCreatePic(@ScriptDir & "\calling.gif", 0, 0, 24, 24); Create new pic
;~                   GUISetState()
;~               EndIf
        EndSelect
Wend
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

You took out the most important and necessary part in the code. The code you commented out re-creates the picture when it is moved and I put that there on purpose. I need to find a way to edit it where it still re-creates a picture and the placed ones can still move.

While Alive() {
	 DrinkWine();
}
AutoIt Programmer
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...