Hi,
You can save the content of each control to its associated variable (e.g.
cardx) before calling
MouseMove command using
Gui, submit. Also, if you are using
MouseMove command, you should set
CoordMode(see:
CoordMode) in order to make mouse coordinates to be relatives to the active window (or screen at your option according to your aim).
Code: Select all
CoordMode, Mouse, Window ; make mouse coordinates to be ralatives to the active window
Gui, Color, C000000
Gui +AlwaysOnTop +LastFound +HWNDa_ID ; strore in a_ID the GUI ID
WinSet, Transparent, 250
Gui, Font, S10 C000000 , Tahoma
Gui, Show, x131 y91 h90 w200,Mouse
Gui, Add, Text, x4 y50 c00FFFF, X:
Gui, Add, Edit, x27 y50 w30 h24 vcardx
Gui, Add, Text, x65 y50 c00FFFF, Y:
Gui, Add, Edit, x87 y50 w30 h24 vcardy
; #Persistent ; any script that uses the GUI command anywhere is automatically persistent
SetTimer, aa, 500
return
aa:
WinGet, a1_ID, ID, A
If ( a_ID != a1_ID )
k_ID = %a1_ID%
return
F4::
Gui, Submit, NoHide ; saves the contents of each control to its associated variable (ex: vcardx) and hides the window unless the NoHide option is present (see documentation)
if (cardx != "" and cardy != "")
MouseMove, %cardx%, %cardy%, 0 ; R -- uncomment the R if you want the X and Y coordinates to be be treated as offsets from the current mouse position
return
GuiClose:
ExitApp
Hope this helps.
EDIT:
you also can replace you timer subroutine by this one, more efficient:
Code: Select all
SetTimer, aa, -100 ; If timer period is negative, the timer will run only once (since the subroutine below specified a loop)
return
aa:
Loop {
WinGet, this_ID, ID, A ; get ID of active window
WinWaitNotActive, ahk_id %this_ID% ; wait until the active window is not active.
if not (WinActive("ahk_id " . a_ID)) ; if it's not GUI
k_ID := WinExist() ; returns the ID of the last found window and stores it in k_ID
}
return