Hello guys, this is my first post and i will show a example of code (for newbies guide) of MousePos(). The MousePos() grants you locate a current position of mouse in your screen. (don't say). And let's stop talking.
Portugues
Olá galera, este é meu primeiro topico e eu vou mostrar um exemplo de codigo (para estudos) do MousePos(). O MousePos() permite voce localizar a posicao atual do mouse na sua tela. (nao me diga). E vamos parar de Falar
CODE
#requireadmin ;admin prompt for win vista and superior
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=c:\documents and settings\familia\desktop\nova pasta\k.o.d.a\forms\x y locator.kxf
$Main = GUICreate("Localizador de X e Y 0.1 Pre-Release", 239, 94, 437, 235, $WS_POPUP)
GUISetBkColor(0x000000)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "MainMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "MainMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "MainRestore")
$CaixaX = GUICtrlCreateInput("X", 8, 8, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetOnEvent(-1, "CaixaXChange")
$CaixaY = GUICtrlCreateInput("Y", 56, 8, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetOnEvent(-1, "CaixaYChange")
$Sair = GUICtrlCreateButton("Sair[F7]", 120, 48, 113, 33, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, "Sair")
$Localizar = GUICtrlCreateButton("Localizar[F6]", 120, 8, 113, 33, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, "Localizar")
$Creditos = GUICtrlCreateButton("Créditos", 0, 48, 113, 33, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1, "Creditos")
Dim $Main_AccelTable[2][2] = [["{F7}", $Sair],["{F6}", $Localizar]]
GUISetAccelerators($Main_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Creditos() ;------credits =D
MsgBox(0,"Créditos", "Escrito e Criado por Rodizipa")
EndFunc
Func Localizar() ;----- Script
Global $pos=MouseGetPos() ; The variable can be local or Global, i like global =S
GUICtrlSetData($CaixaX, $pos[0])
Guictrlsetdata($CaixaY, $pos[1])
EndFunc
Func Sair() ;-----Exit D=
Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(260,"Confirmar","Deseja realmente sair ?")
Select
Case $iMsgBoxAnswer = 6 ;Yes
Exit
Case $iMsgBoxAnswer = 7 ;No
EndSelect
EndFunc
How work. Hotkeys:
F6 - Localize - func Localizar()
F7 - Exit - func Sair()
when you press a hotkey for Localizar() the pos of mouse , the data is put in input box. [guictrlsetdata()]
Sorry For The Bad English
If you don't wanna copy the code, Download The .Exe =D
Please register or login to download attachments.