Code : Tout sélectionner
#cs
AutoIt script for MMB
Autoit Controls in MMB App
Written by Yuraj
#ce
#NoTrayIcon
#Include <WindowsConstants.au3>
#include <Constants.au3>
#Include <GDIPlus.au3>
#Include <GuiButton.au3>
#Include <GuiEdit.au3>
#Include <GuiToolBar.au3>
;~ Global Settings
AutoItSetOption("MustDeclareVars",1)
HotKeySet("{F2}","stop")
;~ Variables declaration
Global $Loop = true,$hwnd,$title
Local $btn,$hmod,$graphics,$edit,$toolbar ; Controls /hwnds
Local Enum $idNew = 1000,$idOpen,$idSave,$idHelp ; Toolbar buttons /hwnds
; Get Window handle by title
;~ $title = "Welcome!"
if @Compiled AND $CmdLine[0] == 0 then
MsgBox(16,"Error","Missing cmd parameters!")
Exit
endif
if @Compiled then
$title = $CmdLine[1] ; Get window title from CMD
Else
$title = "Welcome!" ; only for debugging
endif
$hwnd = WinGetHandle("[TITLE:" & $title & ";CLASS:#32770]")
if @error then
MsgBox(48,"","Can't find window with title: " & $title)
Exit
EndIf
;~ Constructor, create controls etc.
$btn = _GUICtrlButton_Create($hwnd,"Get text",55,50,80,20)
$edit = _GUICtrlEdit_Create($hwnd,"Type something here...",145,50,150,20,$ES_AUTOHSCROLL)
; Create toolbar
$toolbar = _GUICtrlToolbar_Create ($hwnd, BitOR(0x0800,$WS_DLGFRAME))
_GUICtrlToolbar_AddBitmap ($toolbar, 1, -1, $IDB_STD_SMALL_COLOR)
_GUICtrlToolbar_AddButton ($toolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton ($toolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton ($toolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep ($toolbar)
_GUICtrlToolbar_AddButton ($toolbar, $idHelp, $STD_HELP)
;
;~ Main loop (and check if the window exist)
While $Loop AND WinExists($hwnd)
;~ CONTROLS EVENTS
if BitAND(_GUICtrlButton_GetState($btn), $BST_PUSHED) then ; If is button pressed
Sleep(50)
MsgBox(64,"","You have written:" & @CRLF & _GUICtrlEdit_GetText($edit),0,$hwnd)
endif
; If is toolbar button pressed
if _GUICtrlToolbar_IsButtonPressed($toolbar,$idNew) then
Sleep(50)
MsgBox(64,"","New file ...",0,$hwnd)
elseif _GUICtrlToolbar_IsButtonPressed($toolbar,$idOpen) then
Sleep(50)
MsgBox(64,"","Open file ...",0,$hwnd)
elseif _GUICtrlToolbar_IsButtonPressed($toolbar,$idSave) then
Sleep(50)
MsgBox(64,"","Save file ...",0,$hwnd)
elseif _GUICtrlToolbar_IsButtonPressed($toolbar,$idHelp) then
Sleep(50)
MsgBox(64,"","AutoIt Script" & @CRLF & "Written by Yuraj!",0,$hwnd)
endif
;
Sleep(20)
WEnd
;~~~DESTUCTOR
;~ Destroy Controls
_GUICtrlToolbar_Destroy($toolbar)
_GUICtrlButton_Destroy($btn)
_GUICtrlEdit_Destroy($edit)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ FUNCTIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
Func stop()
$Loop = false
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;