Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/07/2017 in all areas

  1. Features: Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support for aerosnap etc. Many color schemes/themes included. See MetroThemes.au3 for more details. 3 type of Windows 8/10 style buttons. Modern checkboxes, radios, toggles and progressbar. All buttons, checkboxes etc. have hover effects! Windows 10 style modern MsgBox. Windows 10/Android style menu that slides in from left. Windows 10 style right click menu Credits: @UEZ, for the function to create buttons with text using GDIPlus. @binhnx for his SSCtrlHover UDF Changelog: Download UDF with example:
    1 point
  2. here is a free inspection tool for you, get it off GitHub https://github.com/blackrosezy/gui-inspect-tool this is a BUNCH of free stuff, including Inspect.exe. lots of tools there.
    1 point
  3. Do you have access to Windows SDK's, you can download many. It comes with a gem I love called inspect.exe, one for your platform is included. that is a wonderful tool that can see almost any control. Also, the .NET CLR stuff developed by people here can help as many apps are now .NET based using Winforms or WPF
    1 point
  4. maybe this will help out. when you make the autoit form sizable, it can auto resize stuff built in. this sample can LIMIT the amount the AutoIt Form can be resized so you can possibly fit it. https://www.autoitscript.com/wiki/Snippets_(_GUI_)#Limit_GUI_Resize I copied the code and ran it, when you try to resize it it limits it, you could do this possibly with your forms? limit them to small forms so you can determine your XY coords.
    1 point
  5. kylomas

    lisview

    BewmanNH's code without loop... #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Local $idListview, $Select = False GUICreate("ListView Get Item Checked State", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) $idButton = GUICtrlCreateButton("Select All", 10, 270, 70) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Check item 2 ; Loop until the user exits. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idButton $Select = Not $Select _GUICtrlListView_SetItemChecked($idListview, -1, $Select) GUICtrlSetData($idButton, ($Select ? "Deselect" : "Select") & " All") EndSwitch WEnd GUIDelete() kylomas
    1 point
  6. BrewManNH

    lisview

    Try modifying this. #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $idListview, $Select = False GUICreate("ListView Get Item Checked State", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) $idButton = GUICtrlCreateButton("Select All", 10, 270, 70) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Check item 2 ; Loop until the user exits. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idButton $Select = Not $Select For $Loop = 0 To _GUICtrlListView_GetItemCount($idListview) - 1 _GUICtrlListView_SetItemChecked($idListview, $Loop, $Select) Next GUICtrlSetData($idButton, ($Select ? "Deselect" : "Select") & " All") EndSwitch WEnd GUIDelete() EndFunc ;==>Example
    1 point
  7. iamtheky

    Systeminformations

    You can search for my stuff in powershell if you want to do it that way, but its the same object calls but slower. I still havent cleaned this up, but auditshot has a nice template for gathering info into an excel spreadsheet. (commenting those lines, and _ArrayToString with comma delimeters would be just as well).
    1 point
  8. kylomas

    Systeminformations

    AnnoUS, This will get you started. There are plenty of examples of the user and network stuff in the forum. You did not specify how you wanted the CSV file formatted so I took my best guess... ; added fileopen routine ; added file write after each routine ; declared variables used for accumulation ; changed from assignment (=) to concatenation (&=) for accumulation variables ; added date formatting routine Local $hfl = FileOpen(@ScriptDir & '\sysinfo.csv', 2) If $hfl = -1 Then Exit MsgBox(17, 'Error', 'Output file faled to open') $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('SELECT * FROM Win32_LogicalDisk') Local $tdrive For $oItem In $cItems $tdrive &= $oItem.Name & ',' & $oItem.Size & ',' & $oItem.FreeSpace & @CRLF Next ConsoleWrite($tdrive) FileWrite($hfl, $tdrive) EndIf $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_OperatingSystem') Local $tOSDate For $oItem In $cItems $tOSDate &= CNVTDate($oItem.InstallDate) & @CRLF Next ConsoleWrite($tOSDate) FileWrite($hfl, $tOSDate) EndIf $oWMI = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2') ; If (IsObj($oWMI)) And (Not @error) Then $cItems = $oWMI.ExecQuery('Select * from Win32_Printer') Local $tprinter For $oItem In $cItems $tprinter &= $oItem.Name & ',' Next ConsoleWrite($tprinter) FileWrite($hfl, $tprinter) EndIf FileClose($hfl) Func CNVTDate($dtmDate) ; reformat date to mm/dd/yyyy hh:mm:ss and zero fill single digit values Return StringRegExpReplace(StringRegExpReplace($dtmDate, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).*', '$2/$3/$1 $4:$5:$6'), '(?<!\d)(\d/)', '0$1') EndFunc ;==>CNVTDate kylomas
    1 point
  9. You have separate the gfx handle with the rotation / zoom and the background. #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <ButtonConstants.au3> #include <File.au3> #include <Array.au3> #include <GDIPlus.au3> #include <TabConstants.au3> #include <MsgBoxConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> ;~ Global Const $STM_SETIMAGE = 0x0172 Global $_CTRL_GUI, $hImage, $_External_Width, $_External_Height AutoItSetOption("GUIOnEventMode", 1) CONTROL_GUI() Func CONTROL_GUI() Local $_Play_Back, $aPlaySize, $_strip_X, $_strip_Y ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf ; Initialize GDI+ library _GDIPlus_Startup() $_CTRL_GUI = GUICreate("Positioning", 600, 350) GUISetBkColor(0xFFFFFF) ;set GUI background to 'White'... GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform") GUISetState(@SW_SHOW, $_CTRL_GUI) $aPlaySize = WinGetClientSize($_CTRL_GUI) ;get the X, Y size of the 'PLAY' GUI Window... ;**BACKGROUND IMAGE FOR "window"... $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\back_reference3.jpg") ;create the image to be watermarked... ;~ $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $_External_Height = _GDIPlus_ImageGetHeight($hImage) $_External_Width = _GDIPlus_ImageGetWidth($hImage) $_strip_X = ($aPlaySize[0] / 2) - ($_External_Width / 2) $_strip_Y = ($aPlaySize[1] / 2) - ($_External_Height / 2) $_Play_Back = GUICtrlCreatePic("", $_strip_X, $_strip_Y, $_External_Width, $_External_Height, $SS_NOTIFY) if $_Play_Back == 0 Then MsgBox(64, "Image Error:", "Problem creating desired image in 'CONTROL GUI'...error:" & @error) if $_Play_Back <> 0 Then ;~ _WinAPI_DeleteObject(GUICtrlSendMsg($_Play_Back, $STM_SETIMAGE, 0, $hHBITMAP)) ;~ _GDIPlus_ImageDispose($hImage) GuiCtrlSetState($_Play_Back, $GUI_DISABLE) GuiCtrlSetState($_Play_Back, $GUI_SHOW) EndIf ;'$_Play_Back' NOT "0" (image should have been created successfuly)... ;** ;**** ;**** Global $_adjusts = _GDIPlus_GraphicsCreateFromHWND($_CTRL_GUI) Global $hBmp_Buffer = _GDIPlus_BitmapCreateFromScan0($_External_Width, $_External_Height) Global $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer) Global $hImage3 = _GDIPlus_ImageLoadFromFile($sFile) Global $iMouseX, $iMouseY GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE") GUISetState(@SW_SHOW) _Draw() While Sleep(10) WEnd ;**** ;**** EndFunc ;"CONTROL_GUI()" updates the various controls used for image positioning as necessary... Func _ResetGraphicsTransform() _GDIPlus_GraphicsResetTransform($hGfx_Buffer) _Draw() EndFunc ;==>_ResetGraphicsTransform Func WM_LBUTTONDOWN($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam $iMouseX = BitAND($lParam, 0x0000FFFF) $iMouseY = BitShift($lParam, 16) Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONDOWN Func WM_MOUSEMOVE($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg Switch BitAND($wParam, 0x0000FFFF) Case 1 Local $iX = BitAND($lParam, 0x0000FFFF) Local $iY = BitShift($lParam, 16) _GDIPlus_GraphicsTranslateTransform($hGfx_Buffer, $iX - $iMouseX, $iY - $iMouseY, True) $iMouseX = $iX $iMouseY = $iY _Draw() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEMOVE Func WM_MOUSEWHEEL($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $lParam Switch BitAND($wParam, 0x0000FFFF) Case 1 Local $iAngle = -3 If BitShift($wParam, 16) < 0 Then $iAngle = 3 Local $aMousePos[2][2] = [[1]] $aMousePos[1][0] = $iMouseX $aMousePos[1][1] = $iMouseY _GDIPlus_GraphicsTransformPoints($hGfx_Buffer, $aMousePos) _GDIPlus_GraphicsTranslateTransform($hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1]) _GDIPlus_GraphicsRotateTransform($hGfx_Buffer, $iAngle) _GDIPlus_GraphicsTranslateTransform($hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1]) Case Else Local $aInfo = GUIGetCursorInfo($_CTRL_GUI) Local $iScale = 1.1 If BitShift($wParam, 16) < 0 Then $iScale = 0.9 _GDIPlus_GraphicsTranslateTransform($hGfx_Buffer, -$aInfo[0], -$aInfo[1], True) _GDIPlus_GraphicsScaleTransform($hGfx_Buffer, $iScale, $iScale, True) _GDIPlus_GraphicsTranslateTransform($hGfx_Buffer, $aInfo[0], $aInfo[1], True) EndSwitch _Draw() Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL Func _Draw() _GDIPlus_GraphicsClear($hGfx_Buffer, 0x00000000) ;****PROBLEM IS CAUSED BY REMOVING THIS 'GraphicsClear' STATEMENT...BUT HOW TO COMPENSATE THE LOSS OF THE ; BACKGROUND IMAGE...??? _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hImage3, 216, 166) Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsDrawRect($hGfx_Buffer, 10, 10, 200, 100, $hPen) _GDIPlus_PenDispose($hPen) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 260, 400) _GDIPlus_GraphicsDrawStringEx($hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($_adjusts, $hImage, 0, 0, $_External_Width, $_External_Height) _GDIPlus_GraphicsDrawImage($_adjusts, $hBmp_Buffer, 0, 0) _GDIPlus_FontDispose($hFont) $hFont = _GDIPlus_FontCreate($hFamily, 10) _GDIPlus_StringFormatSetAlign($hFormat, 0) DllStructSetData($tLayout, "X", 10) DllStructSetData($tLayout, "Y", 10) _GDIPlus_GraphicsDrawStringEx($_adjusts, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 30) _GDIPlus_GraphicsDrawStringEx($_adjusts, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 50) _GDIPlus_GraphicsDrawStringEx($_adjusts, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 70) _GDIPlus_GraphicsDrawStringEx($_adjusts, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush) Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_GraphicsGetTransform($hGfx_Buffer, $hMatrix) Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix) _GDIPlus_MatrixDispose($hMatrix) DllStructSetData($tLayout, "Y", 110) _GDIPlus_GraphicsDrawStringEx($_adjusts, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "X", 20) DllStructSetData($tLayout, "Y", 130) _GDIPlus_GraphicsDrawStringEx($_adjusts, StringFormat("%.2f %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 150) _GDIPlus_GraphicsDrawStringEx($_adjusts, StringFormat("%.2f %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 170) _GDIPlus_GraphicsDrawStringEx($_adjusts, StringFormat("%.2f %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_Draw Func _Exit() _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hImage3) _GDIPlus_GraphicsDispose($hGfx_Buffer) _GDIPlus_BitmapDispose($hBmp_Buffer) _GDIPlus_GraphicsDispose($_adjusts) _GDIPlus_Shutdown() GUIDelete($_CTRL_GUI) Exit EndFunc ;==>_Exit
    1 point
  10. anthonyjr2

    Pandora Get

    This is a verrrry old thread, you probably could have gotten away with creating your own and then linking to this one, and gotten better replies with a better title. EDIT: That said, it seems that the song information is within the "trackData" div on the now playing page. If you do a CTRL+F for that div you should be able to find the location. My guess is the song is pulled through Javascript, but there are probably other ways to pull the song information off of the page. If you go to inspect element you can do a search for the song you're listening to to find it's location. EDIT 2: You should be able to pull the live page source every 15 seconds or so and just use some sort of Regex to pull the song name/artist off of the page.
    1 point
  11. Added an example how to get the last cell of a column to the wiki.
    1 point
  12. I just downloaded this version then copied the DLL in the @scriptdir from the zip file. Then this exemple works as intended: #include <SQLite.au3> ; don't include sqlite.dll.au3 !!! Local $path = @ScriptDir & "\mydb.sql" _SQLite_Startup ("System.Data.SQLite.dll") ConsoleWrite(_SQLite_LibVersion() & @LF) Local $row ; using encryption _SQLite_Open($path) _SQLite_Exec(-1, "pragma key = 'Radu is happy!';create table if not exists test (id integer, val text);" & _ "insert into test values (1, 'abc');") _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite($row[1] & @LF) _SQLite_Close(-1) ; not using encryption over the encrypted DB gives a failure _SQLite_Open($path) _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite(_SQLite_ErrMsg(-1) & @LF) _SQLite_Close(-1) ; changing back to no encryption _SQLite_Open($path) _SQLite_Exec(-1, "pragma key = 'Radu is happy!'") _SQLite_Exec(-1, "pragma rekey = ''") _SQLite_QuerySingleRow(-1, "select * from test;", $row) ConsoleWrite($row[1] & @LF) _SQLite_Close(-1) _SQLite_Shutdown()
    1 point
  13. I use enumdisplaymonitors for this purpose, (I have a number of scripts to start apps on specific monitors, or on the monitor the mouse is on (from toolbars or other apps tool menus etc.)) here is the MultiMon.au3 I wrote and am currently using (could have a whole bunch more capability, but does what i need it to, the one thing I keep meaning to add is a custom MsgBox that I can place on a specific monitor) It all seems to still work, (I just cleaned up the code a bit, added some minimal info above each function and renamed a bunch of variables ($t1, $t2, $h etc just doesn't cut it if someone else is looking at the code ) #include-Once Global $__MonitorList[1][5] $__MonitorList[0][0] = 0 ; Just for testing _ShowMonitorInfo() ;================================================================================================== ; Function Name: _ShowMonitorInfo() ; Description:: Show the info in $__MonitorList in a msgbox (line 0 is entire screen) ; Parameter(s): n/a ; Return Value(s): n/a ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _ShowMonitorInfo() If $__MonitorList[0][0] == 0 Then _GetMonitors() EndIf Local $Msg = "" Local $i = 0 For $i = 0 To $__MonitorList[0][0] $Msg &= $i & " - L:" & $__MonitorList[$i][1] & ", T:" & $__MonitorList[$i][2] $Msg &= ", R:" & $__MonitorList[$i][3] & ", B:" & $__MonitorList[$i][4] If $i < $__MonitorList[0][0] Then $Msg &= @CRLF Next MsgBox(0, $__MonitorList[0][0] & " Monitors: ", $Msg) EndFunc ;==>_ShowMonitorInfo ;================================================================================================== ; Function Name: _MaxOnMonitor($Title[, $Text = ''[, $Monitor = -1]]) ; Description:: Maximize a window on a specific monitor (or the monitor the mouse is on) ; Parameter(s): $Title The title of the window to Move/Maximize ; optional: $Text The text of the window to Move/Maximize ; optional: $Monitor The monitor to move to (1..NumMonitors) defaults to monitor mouse is on ; Note: Should probably have specified return/error codes but haven't put them in yet ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _MaxOnMonitor($Title, $Text = '', $Monitor = -1) _CenterOnMonitor($Title, $Text, $Monitor) WinSetState($Title, $Text, @SW_MAXIMIZE) EndFunc ;==>_MaxOnMonitor ;================================================================================================== ; Function Name: _CenterOnMonitor($Title[, $Text = ''[, $Monitor = -1]]) ; Description:: Center a window on a specific monitor (or the monitor the mouse is on) ; Parameter(s): $Title The title of the window to Move/Maximize ; optional: $Text The text of the window to Move/Maximize ; optional: $Monitor The monitor to move to (1..NumMonitors) defaults to monitor mouse is on ; Note: Should probably have specified return/error codes but haven't put them in yet ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _CenterOnMonitor($Title, $Text = '', $Monitor = -1) $hWindow = WinGetHandle($Title, $Text) If Not @error Then If $Monitor == -1 Then $Monitor = _GetMonitorFromPoint() ElseIf $__MonitorList[0][0] == 0 Then _GetMonitors() EndIf If ($Monitor > 0) And ($Monitor <= $__MonitorList[0][0]) Then ; Restore the window if necessary Local $WinState = WinGetState($hWindow) If BitAND($WinState, 16) Or BitAND($WinState, 32) Then WinSetState($hWindow, '', @SW_RESTORE) EndIf Local $WinSize = WinGetPos($hWindow) Local $x = Int(($__MonitorList[$Monitor][3] - $__MonitorList[$Monitor][1] - $WinSize[2]) / 2) + $__MonitorList[$Monitor][1] Local $y = Int(($__MonitorList[$Monitor][4] - $__MonitorList[$Monitor][2] - $WinSize[3]) / 2) + $__MonitorList[$Monitor][2] WinMove($hWindow, '', $x, $y) EndIf EndIf EndFunc ;==>_CenterOnMonitor ;================================================================================================== ; Function Name: _GetMonitorFromPoint([$XorPoint = -654321[, $Y = 0]]) ; Description:: Get a monitor number from an x/y pos or the current mouse position ; Parameter(s): ; optional: $XorPoint X Position or Array with X/Y as items 0,1 (ie from MouseGetPos()) ; optional: $Y Y Position ; Note: Should probably have specified return/error codes but haven't put them in yet, ; and better checking should be done on passed variables. ; Used to use MonitorFromPoint DLL call, but it didn't seem to always work. ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _GetMonitorFromPoint($XorPoint = 0, $y = 0) If @NumParams = 0 then local $MousePos = MouseGetPos() Local $myX = $MousePos[0] Local $myY = $MousePos[1] Elseif ( @NumParams = 1 ) and IsArray($XorPoint) Then Local $myX = $XorPoint[0] Local $myY = $XorPoint[1] Else Local $myX = $XorPoint Local $myY = $y EndIf If $__MonitorList[0][0] == 0 Then _GetMonitors() EndIf Local $i = 0 Local $Monitor = 0 For $i = 1 To $__MonitorList[0][0] If ($myX >= $__MonitorList[$i][1]) _ And ($myX < $__MonitorList[$i][3]) _ And ($myY >= $__MonitorList[$i][2]) _ And ($myY < $__MonitorList[$i][4]) Then $Monitor = $i Next Return $Monitor EndFunc ;==>_GetMonitorFromPoint ;================================================================================================== ; Function Name: _GetMonitors() ; Description:: Load monitor positions ; Parameter(s): n/a ; Return Value(s): 2D Array of Monitors ; [0][0] = Number of Monitors ; [i][0] = HMONITOR handle of this monitor. ; [i][1] = Left Position of Monitor ; [i][2] = Top Position of Monitor ; [i][3] = Right Position of Monitor ; [i][4] = Bottom Position of Monitor ; Note: [0][1..4] are set to Left,Top,Right,Bottom of entire screen ; hMonitor is returned in [i][0], but no longer used by these routines. ; Also sets $__MonitorList global variable (for other subs to use) ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _GetMonitors() $__MonitorList[0][0] = 0 ; Added so that the global array is reset if this is called multiple times Local $handle = DllCallbackRegister("_MonitorEnumProc", "int", "hwnd;hwnd;ptr;lparam") DllCall("user32.dll", "int", "EnumDisplayMonitors", "hwnd", 0, "ptr", 0, "ptr", DllCallbackGetPtr($handle), "lparam", 0) DllCallbackFree($handle) Local $i = 0 For $i = 1 To $__MonitorList[0][0] If $__MonitorList[$i][1] < $__MonitorList[0][1] Then $__MonitorList[0][1] = $__MonitorList[$i][1] If $__MonitorList[$i][2] < $__MonitorList[0][2] Then $__MonitorList[0][2] = $__MonitorList[$i][2] If $__MonitorList[$i][3] > $__MonitorList[0][3] Then $__MonitorList[0][3] = $__MonitorList[$i][3] If $__MonitorList[$i][4] > $__MonitorList[0][4] Then $__MonitorList[0][4] = $__MonitorList[$i][4] Next Return $__MonitorList EndFunc ;==>_GetMonitors ;================================================================================================== ; Function Name: _MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam) ; Description:: Enum Callback Function for EnumDisplayMonitors in _GetMonitors ; Author(s): xrxca (autoit@forums.xrx.ca) ;================================================================================================== Func _MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam) Local $Rect = DllStructCreate("int left;int top;int right;int bottom", $lRect) $__MonitorList[0][0] += 1 ReDim $__MonitorList[$__MonitorList[0][0] + 1][5] $__MonitorList[$__MonitorList[0][0]][0] = $hMonitor $__MonitorList[$__MonitorList[0][0]][1] = DllStructGetData($Rect, "left") $__MonitorList[$__MonitorList[0][0]][2] = DllStructGetData($Rect, "top") $__MonitorList[$__MonitorList[0][0]][3] = DllStructGetData($Rect, "right") $__MonitorList[$__MonitorList[0][0]][4] = DllStructGetData($Rect, "bottom") Return 1 ; Return 1 to continue enumeration EndFunc ;==>_MonitorEnumProc Edited Jan 8, 2009 to correct minor bug in _GetMonitors routine (Pointed out by Cusem).
    1 point
×
×
  • Create New...