Jump to content

Move Images/GUI


Recommended Posts

I set a pic on a GUI so I could move the picture around with my mouse anywhere one the screen. Well it works, but when I let go of the picture to set it, I can't move it anymore. Please help.

$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 & "\icons\calling.gif", 0, 0, 24, 24)
    GUISetState(@SW_SHOW,$calling)
While 1
$msg = GUIGetMsg()
Select
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
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

I fixed some of your code, but this probably needs work still:

#include <GuiConstants.au3>
#Include <Misc.au3>
Opt("WinTitleMatchMode", 4)
$hudGUI = GUICreate("", 150, 250)
GUISetState()
GUISetBkColor(0xF2F2F2, $hudGUI)
WinSetOnTop($hudGUI, "", 1)
$exit = GUICtrlCreateButton("Close", 5, 230, 40, 18)
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 & "\icons\calling.gif", 0, 0, 24, 24)
GUISetState(@SW_SHOW, $calling)
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $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
            
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $exit
            Exit
            
    EndSwitch
    Sleep(40)
WEnd

If you are using SciTe, you should press Ctrl+F5 to do a syntax check every now and then, FireLordZi. :D

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Well, study the first post in this thread, and then the second post. Your posted code would crash big time.

I could probably fix your code if I had it all and knew everything about just what you want your script to do.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

I fixed some of your code, but this probably needs work still:

#include <GuiConstants.au3>
#Include <Misc.au3>
Opt("WinTitleMatchMode", 4)
$hudGUI = GUICreate("", 150, 250)
GUISetState()
GUISetBkColor(0xF2F2F2, $hudGUI)
WinSetOnTop($hudGUI, "", 1)
$exit = GUICtrlCreateButton("Close", 5, 230, 40, 18)
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 & "\icons\calling.gif", 0, 0, 24, 24)
GUISetState(@SW_SHOW, $calling)
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $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
            
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $exit
            Exit
            
    EndSwitch
    Sleep(40)
WEnd

If you are using SciTe, you should press Ctrl+F5 to do a syntax check every now and then, FireLordZi. :D

Did you even test your code? $WS_POPUP does NOT work with child GUIs.
Link to comment
Share on other sites

Well, study the first post in this thread, and then the second post. Your posted code would crash big time.

I could probably fix your code if I had it all and knew everything about just what you want your script to do.

My code doesn't crash when I run it. And I still don't "see" the difference between your code and my code beside WinTitleMatchMode(). What change makes your script have the ability to keep moving the pictures even after they have been set as compared to mine?

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

I think I found why I can't move it (rather them). I forgot that whenever a picture is moved out of its place on the gui another one is re-created in its place.

#include <GUIContstants.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 & "\icons\calling.gif", 0, 0, 24, 24)
    GUISetState(@SW_SHOW,$calling)
While 1
$msg = GUIGetMsg()
Select
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 & "\icons\calling.gif", 0, 0, 24, 24); Create new pic
                    GUISetState()
                EndIf
EndSelect
Wend
Edited by FireLordZi
While Alive() {
	 DrinkWine();
}
AutoIt Programmer
Link to comment
Share on other sites

My code doesn't crash when I run it.

Are you saving that this is valid code:

$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 & "\icons\calling.gif", 0, 0, 24, 24)
    GUISetState(@SW_SHOW,$calling)
While 1
$msg = GUIGetMsg()
Select
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 this is what you are saying, then, provided you are above the age of thirteen, somewhat sober, good with the English language and have a properly maintained computer that is operating fairly well - if all this is so - I am sadly obligated, sir, to refer you directly hence and irrevocably to Verse 1 of the Official Canon of Valik.

Maybe you need to reinstall AutoIt or something.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Are you saving that this is valid code:

$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 & "\icons\calling.gif", 0, 0, 24, 24)
    GUISetState(@SW_SHOW,$calling)
While 1
$msg = GUIGetMsg()
Select
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 this is what you are saying, then, provided you are above the age of thirteen, somewhat sober, good with the English language and have a properly maintained computer that is operating fairly well - if all this is so - I am sadly obligated, sir, to refer you directly hence and irrevocably to Verse 1 of the Official Canon of Valik.

Maybe you need to reinstall AutoIt or something.

Point me to the post where I said it was "valid" code. As I recall, I said that it didn't CRASH when I ran it. Big difference.

It may not be valid, but it doesn't crash either when I (as in myself) run it. And I see you didn't read my latest post.

Edit: And btw, don't edit your posts anymore. This feature should be denied to you for it gives you the chance to think of something even more retarded.

Edited by FireLordZi
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...