Anyway, I have the following code, which almost works:
Code: Select all
#SingleInstance Force
Gui, PopMenu:Add, Button, , some other gui element
Gui, PopMenu:Add, Picture, w100 h100 gImageClick vPicNumber_01, 01-exampleWithSomeMoreInfoWrittenInTheFileName.PNG
Gui, PopMenu:Add, Picture, w100 h100 gImageClick vPicNumber_02, 02-exampleWithSomeOtherMoreInfoWrittenInTheFileName.PNG
Gui, PopMenu:Add, Picture, w100 h100 gImageClick vPicNumber_03, 03-exampleWithSomeOtheAndEvenMoreInfoWrittenInTheFileName.PNG
Gui, PopMenu:Show, AutoSize
return
ImageClick() {
clickedImageVarName := A_GuiControl ; e.g. "PicNumber_04"
MouseGetPos, , , ,clickedImageClassNN ; the ClassNN of the Control, over which the mous is hovering
GuiControlGet, clickedImagePath, PopMenu: , %clickedImageClassNN% ; get clickedImagePath
; MsgBox, clickedImage:%clickedImagePath%
while (GetKeyState("LButton")) { ; while LButton pressed
ToolTip, Bild auf anderes Bild ziehen`, um zu vertauschen
}
ToolTip ; delete tooltip again
MouseGetPos, , , ,draggedToImageClassNN ; the ClassNN of the Control, over which the mous is hovering now
GuiControlGet, draggedToImageVarName, PopMenu:Name , %draggedToImageClassNN% ; the variable name of this control "PicNumberXY"
if (Substr(draggedToImageVarName,1, 9) == "PicNumber") { ; if it is a picture
GuiControlGet, draggedToImagePath, PopMenu:, %draggedToImageClassNN% ; get draggedToImagePath
msgBox % draggedToImagePath
if (clickedImagePath != draggedToImagePath) {
SplitPath, clickedImagePath, clickedImageName, clickedImageDir
SplitPath, draggedToImagePath, draggedToImageName, draggedToImageDir
clickedImageNumber := SubStr(clickedImageName, 1, 2)
draggedToImageNumber := SubStr(draggedToImageName, 1, 2)
newClickedImagePath := draggedToImageNumber . SubStr(clickedImageName, 3)
newDraggedToImagePath := clickedImageNumber . SubStr(draggedToImageName, 3)
FileMove, %clickedImagePath%, %newClickedImagePath%
FileMove, %draggedToImagePath%, %newDraggedToImagePath%
GuiControl, PopMenu:, %clickedImageVarName%, %newDraggedToImagePath%
GuiControl, PopMenu:, %draggedToImageVarName%, %newClickedImagePath%
}
}
}
Esc:: ; Exit
GuiClose:
ExitApp
Simon