Code: Select all
; Read picture positions
IniRead, Pic1x, GUI.ini, PicPositions, Pic1x
IniRead, Pic1y, GUI.ini, PicPositions, Pic1y
IniRead, Pic2x, GUI.ini, PicPositions, Pic2x
IniRead, Pic2y, GUI.ini, PicPositions, Pic2y
IniRead, Pic3x, GUI.ini, PicPositions, Pic3x
IniRead, Pic3y, GUI.ini, PicPositions, Pic3y
; GUI
Gui, Add, Picture, w150 h150 x%Pic1x% y%Pic1y% hWndPic1, earth-img.jpg
Gui, Add, Picture, w150 h150 x%Pic2x% y%Pic2y% hWndPic2, earth-img.jpg
Gui, Add, Picture, w150 h150 x%Pic3x% y%Pic3y% hWndPic3, earth-img.jpg
Gui, Add, DropDownList, vDropDown gMovePicture, 1|2|3
Gui, Show, W640 h500
; Move wanted picture
MovePicture:
Gui, Submit, NoHide
If ( DropDown = 1 )
PostMessage, 0x112, 0xF010,,, ahk_id %Pic1%
If ( DropDown = 2 )
PostMessage, 0x112, 0xF010,,, ahk_id %Pic2%
If ( DropDown = 3 )
PostMessage, 0x112, 0xF010,,, ahk_id %Pic3%
Return
GuiCLose: ; Save picture positions
IniWrite, %Pic1x%, GUI.ini, PicPositions, Pic1y
IniWrite, %Pic1y%, GUI.ini, PicPositions, Pic1y
IniWrite, %Pic2x%, GUI.ini, PicPositions, Pic2x
IniWrite, %Pic2y%, GUI.ini, PicPositions, Pic2y
IniWrite, %Pic3x%, GUI.ini, PicPositions, Pic3x
IniWrite, %Pic3y%, GUI.ini, PicPositions, Pic3y
ExitApp
Return
EDIT for function:
I cannot seem to get PostMessage to work with my GUI pictures inside of a function.
I'm trying to hold the RButton to move a picture, and I'm vaguely new to using this method.
No matter what I try to do, I can't get PostMessage to work in this function.
Code: Select all
Gui, Add, Picture, vPic1 hWndPic1 w100 h100, Pic1.png
Gui, Add, Picture, vPic2 hWndPic2 w100 h100, Pic2.png
Gui, Show, w300 h300
OnMessage(0x204, "WM_RBUTTONDOWN")
return
WM_RBUTTONDOWN()
{
;static CurrControl, _rbdn
;CurrControl := A_GuiControl
ClickTime := A_TickCount
KeyWait, RButton
If A_TickCount - ClickTime > 1000
MouseGetPos,,,,ControlName
GuiControlGet, PicName, Name, % ControlName
;MsgBox % PicName
PostMessage, 0x112, 0xF010,,, ahk_id %PicName% ; I can't figure out how to make the variable accurate
}
return
GuiClose:
ExitApp