Sign in to follow this  
Followers 0
chssoccer

Move GUI

5 posts in this topic

The code below moves a GUI (Merlin) which looks like an icon around using arrow keys. How can this be done except with the mouse?

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

do
    $msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
    $guiPos = WinGetPos($gui)
    WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc

Func left ()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]-10,$picPos[1])
EndFunc

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]+10,$picPos[1])
EndFunc

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]+10)
EndFunc

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]-10)
EndFunc

Share this post


Link to post
Share on other sites

You want say a thing like this?

#include <GUIConstants.au3>
$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)
GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_HIDE,$gui)
WinSetOnTop($pic,"",1)
HotKeySet("{ESC}","_exit")
do
    WinMove($gui,"",MouseGetPos(0),MouseGetPos(1))
    $msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Func _exit()
    Exit
EndFunc

,.-~*´¨¯¨`*·~-.¸-(_[M]¦•¦[A]¦•¦[T]¦•¦[T]¦ •¦[E]¦•¦[O]_)-,.-~*´¨¯¨`*·~-.¸

Share this post


Link to post
Share on other sites

If you mean you want to move the image in the way that the Arrow keys did then maybe this alteration to your script will do it.

#include <GUIConstants.au3>
#include <misc.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
$pic1 = GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")

do
    $msg = GUIGetMsg()
    switch $msg
        Case $pic1
            $gp = WinGetPos($pic)
            $mp = MouseGetPos()
            while _IsPressed("1")
                $cp = MouseGetPos()
                WinMove($pic,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1])
            WEnd
    EndSwitch
    
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
    $guiPos = WinGetPos($gui)
    WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you mean you want to move the image in the way that the Arrow keys did then maybe this alteration to your script will do it.

#include <GUIConstants.au3>
#include <misc.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
$pic1 = GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")

do
    $msg = GUIGetMsg()
    switch $msg
        Case $pic1
            $gp = WinGetPos($pic)
            $mp = MouseGetPos()
            while _IsPressed("1")
                $cp = MouseGetPos()
                WinMove($pic,'',$gp[0] - $mp[0] + $cp[0],$gp[1] - $mp[1] + $cp[1])
            WEnd
    EndSwitch
    
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
    $guiPos = WinGetPos($gui)
    WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc
Thank you! Edited by chssoccer

Share this post


Link to post
Share on other sites

take a look at Lazy Reader

but if I don't see why you're even trying, since

AutoIt is a suckass language and can't do shit ...

and

it's not up to standards

Therefore, just write it in a better language, maybe C++ since

C++ can easily do it. I've done it already.

Share this post


Link to post
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
Sign in to follow this  
Followers 0