Jump to content

Autoit Wrappers


Valuater
 Share

Recommended Posts

  • 1 month later...

; GUI snap to corners

; Author - Lazycat


#include <GUIConstants.au3>

Global Const $WM_WINDOWPOSCHANGING = 0x0046 

Global $nGap = 20

Global $ahGUI[3] 

$ahGUI[0] = GUICreate("Snapped window 1", 300, 200, 100, 100)
GUISetState()

$ahGUI[1] = GUICreate("Snapped window 2", 300, 400, 300, 400)
GUISetState()

$ahGUI[2] = GUICreate("Snapped window 3", 150, 300, 500, 100)
GUISetState()


GUIRegisterMsg($WM_WINDOWPOSCHANGING, "MY_WM_WINDOWPOSCHANGING")

While 1
    $GUIMsg = GUIGetMsg()
    
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func MY_WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
    Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)

    Local $nLeft   = DllStructGetData($stWinPos, 3)
    Local $nTop    = DllStructGetData($stWinPos, 4)

    $pos_cur = WinGetPos($hWnd)

    For $i = 0 To UBound($ahGUI) - 1
        If $hWnd = $ahGUI[$i] Then ContinueLoop
        $pos_win = WinGetPos($ahGUI[$i])

        If Abs(($pos_win[0] + $pos_win[2]) - $nLeft) <= $nGap Then DllStructSetData($stWinPos, 3, $pos_win[0] + $pos_win[2])
        If Abs($nLeft + $pos_cur[2] - $pos_win[0]) <= $nGap Then DllStructSetData($stWinPos, 3, $pos_win[0] - $pos_cur[2])

        If Abs(($pos_win[1] + $pos_win[3]) - $nTop) <= $nGap Then DllStructSetData($stWinPos, 4, $pos_win[1] + $pos_win[3])
        If Abs($nTop + $pos_cur[3] - $pos_win[1]) <= $nGap Then DllStructSetData($stWinPos, 4, $pos_win[1] - $pos_cur[3])
    Next
    
    Return 0
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I want to download "picture buttons". When I left-click directly on the link there is an error message that the file is not there. When I right-click and save I get a zip file "PicButton.zip", but when I want to extract it I get a message that this is not a valid zip-file. Any ideas about that?

Thanks

Maxpilot

Link to comment
Share on other sites

The following script shows how to determine which tab item the user secondary clicked on.

#NoTrayIcon
#include <GUIConstants.au3>
#include <GUITab.au3>
;===============================================================================
;
; Program Name:     Tab Item Context Menu
; Description:      Context menu for tab items
; Requirement(s):   None
; Author(s):        RazerM
;
;===============================================================================
;

;register message to handle context menu
Global Const $WM_CONTEXTMENU = 0x007B
GUIRegisterMsg($WM_CONTEXTMENU, "TabContext")

Global $iTabClicked ;global var to determine which tab was clicked

$GUI = GUICreate("Tab Item Context Menu", 600, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) ;create GUI
$hTab = GUICtrlCreateTab(10, 10, 580, 480) ;create tab
GUICtrlSetResizing($hTab, $GUI_DOCKBORDERS)
$hTabContext = GUICtrlCreateContextMenu($hTab) ;create context menu
$hTabContextClick = GUICtrlCreateMenuItem("Click Me", $hTabContext)
Local $ahTabs[5]
For $i = 0 to 4
    $ahTabs[$i] = GUICtrlCreateTabItem("Tab Item " & $i) ;create five tab items
Next
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTabContextClick
            MsgBox(0,"Clicked","You clicked 'Click Me' on tab item "& $iTabClicked)
    EndSwitch
WEnd

Func TabContext($hwnd, $MsgID, $wParam, $lParam)
    If $hwnd = $GUI Then ;check message is from correct GUI
        $iX = LoWord($lParam) ;get x and y values
        $iY = HiWord($lParam)
        For $i = 0 To UBound($ahTabs, 1) - 1 ;iterate through tab by index
            $aiTabPos = ControlGetPos($GUI, "", $hTab)
            $aiTabItemRect = _GUICtrlTabGetItemRECT($hTab, $i)
            ClientToScreen($GUI, $aiTabPos[0], $aiTabPos[1])
            $aiTabItemRect[1] += $aiTabPos[0]
            $aiTabItemRect[2] += $aiTabPos[1]
            $aiTabItemRect[3] += $aiTabPos[0]
            $aiTabItemRect[4] += $aiTabPos[1]
            If CoordsWithinRect($iX, $iY, $aiTabItemRect) Then
                ;_GUICtrlTabSetCurFocus($hTab, $i) ;un comment if you want tab item to steal focus
                $iTabClicked = $i
                ExitLoop
            EndIf
        Next
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>TabContext

Func CoordsWithinRect($iX, $iY, $aRect)
    If IsArray($aRect) And $aRect[0] = 4 Then
        If $iX >= $aRect[1] And $iX <= $aRect[3] And $iY >= $aRect[2] And $iY <= $aRect[4] Then Return 1
    EndIf
EndFunc   ;==>CoordsWithinRect

Func LoWord($dword)
    If BitAND($dword, 0x8000) = 0 Then
        Return BitAND($dword, 0xFFFF)
    Else
        Return BitOR($dword, 0xFFFF0000)
    EndIf
EndFunc   ;==>LoWord

Func HiWord($dword)
    Return BitAND($dword, 0xFFFF0000) / 0x10000
EndFunc   ;==>HiWord

;func from help file
; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hwnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")

    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hwnd, "ptr", DllStructGetPtr($stPoint))

    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local
    $stPoint = 0
EndFunc   ;==>ClientToScreen
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

I want to download "picture buttons". When I left-click directly on the link there is an error message that the file is not there. When I right-click and save I get a zip file "PicButton.zip", but when I want to extract it I get a message that this is not a valid zip-file. Any ideas about that?

The file is actually not on the server. Is it possible to put it up again?

Greetings

Maxpilot

Link to comment
Share on other sites

The file is actually not on the server. Is it possible to put it up again?

Greetings

Maxpilot

Sorry, I just firgured out the problem...

Dhilip removed his post ( or it was removed by the "old" storage )

I didn't make that demo, so i made the link go to a NEWER demo with alot of buttons to choose.

Hope that helps

8)

Original post/Thread

#288428

NEWHeader1.png

Link to comment
Share on other sites

; Author MHz with the directory delete addition by The Kandie Man
Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & ':loop2' & @CRLF _
            & 'rmdir /q "' & $dirToDelete & '"' & @CRLF _
            & 'if exist "' & $dirToDelete & '" goto loop2' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

This also removes the directory which the file is in. I find it useful for uninstalls when I need to delete the directory.

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Sorry, I just firgured out the problem...

Dhilip removed his post ( or it was removed by the "old" storage )

I didn't make that demo, so i made the link go to a NEWER demo with alot of buttons to choose.

Hope that helps

8)

Original post/Thread

#288428

Great - thank you very much. Helps me a lot.

Greetings

Maxpilot

Link to comment
Share on other sites

Improved MouseRepel Function:

This one doesn't jump - AT ALL.

The function is completely new, the example code is the same from the last version.

#include-once
#include<misc.au3>
; Mouse repel - keep mouse away from an area

; Author - Orange

Global $GUI = GUICreate("Can't Touch This", 200, 100, 200, 200)
GUISetState()
AdlibEnable("CallMouseRepel", 10)

While 1
    Sleep(1000)
WEnd


Func CallMouseRepel()
    $coords = WinGetPos($GUI)
    _MouseRepel($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
EndFunc   ;==>CallMouseRepel

;===============================================================================
;
; Description:    _MouseRepel
; Parameter(s):   $i_left - Left coord
;                 $i_top - Top coord
;                 $i_right - Right coord
;                 $i_bottom - Bottom coord
; User CallTip:   _MouseRepel([$i_left = 0[, $i_top = 0[, $i_right = 0[, $i_bottom = 0]]]]) Repel the Mouse Cursor to specified coords.
; Author(s):      Orange
; Note(s):        This function must be called constantly to prevent the mouse cursor from entering the area.
;                 It is therefore recommended that you call this function from another function that is called by AdlibEnable every 1 to 50ms.
;
;===============================================================================

Func _MouseRepel($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
    $i_Position = MouseGetPos()

    Select
        case $i_Position[0] > $i_right and $i_Position[1] > $i_bottom
            _MouseTrap() 
        Case $i_Position[0] > $i_right and $i_Position[1] < $i_top
            _MouseTrap() 
        Case $i_Position[0] < $i_left and $i_Position[1] < $i_top
            _MouseTrap() 
        Case $i_Position[0] < $i_left and $i_Position[1] > $i_bottom
            _MouseTrap() 
        case $i_Position[0] > $i_right
            _MouseTrap($i_right,0,@DesktopWidth,@DesktopHeight) 
        case $i_Position[0] < $i_left
            _MouseTrap(0,0,$i_left,@DesktopHeight) 
        case $i_Position[1] < $i_top
            _MouseTrap(0,0,@DesktopWidth,$i_top)    
        case $i_Position[1] > $i_bottom
            _MouseTrap(0,$i_bottom,@DesktopWidth,@DesktopHeight)        
    EndSelect
    
EndFunc   ;==>_MouseRepel
Link to comment
Share on other sites

Improved MouseRepel Function:

This one doesn't jump - AT ALL.

The function is completely new, the example code is the same from the last version.

@Orange,

The mouse is repelled even if the GUI isn't active...

I suggest changing the CallMouseRepel to:

Func CallMouseRepel()
    If Not WinActive($Gui) then 
        _MouseTrap()
    Else
        $coords = WinGetPos($GUI)
        _MouseRepel($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
    EndIf
EndFunc   ;==>CallMouseRepeloÝ÷ Ù8Z¶Ø^wzË"µ«^±§]xaz°±ë-jצz{m¢Ø^2¬y©zQnËb¢x§q«¶º»(®+0ØbØ^B)¢È­ðéíá"+rدj×jëh×6Func _MouseRepel($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
  $i_Position = MouseGetPos()
  Select
    Case $i_Position[0] < $i_right And $i_Position[0] > $i_left And $i_Position[1] > $i_top And $i_Position[1] < $i_bottom
      MouseMove($i_left, $i_top, 0)
      ContinueCase
    Case $i_Position[0] > $i_right And $i_Position[1] > $i_bottom
      _MouseTrap()
    Case $i_Position[0] > $i_right And $i_Position[1] < $i_top
      _MouseTrap()
    Case $i_Position[0] < $i_left And $i_Position[1] < $i_top
      _MouseTrap()
    Case $i_Position[0] < $i_left And $i_Position[1] > $i_bottom
      _MouseTrap()
    Case $i_Position[0] > $i_right
      _MouseTrap($i_right, 0, @DesktopWidth, @DesktopHeight)
    Case $i_Position[0] < $i_left
      _MouseTrap(0, 0, $i_left, @DesktopHeight)
    Case $i_Position[1] < $i_top
      _MouseTrap(0, 0, @DesktopWidth, $i_top)
    Case $i_Position[1] > $i_bottom
      _MouseTrap(0, $i_bottom, @DesktopWidth, @DesktopHeight)
  EndSelect
EndFunc   ;==>_MouseRepel
Link to comment
Share on other sites

  • 1 month later...

; Get Window Handle by PID

; Author Smoke_N

#include <array.au3>
$a1 = _WinGetHandleByPID(232)
$a2 = _WinGetHandleByPID("notepad.exe", -1)
$a3 = _WinGetHandleByPID("notepad.exe", 0)
$a4 = _WinGetHandleByPID("notepad.exe", 1)
_ArrayDisplay($a1, "1")
_ArrayDisplay($a2, "2")
_ArrayDisplay($a3, "3")
_ArrayDisplay($a4, "4")

;$nVisible = -1 "All (Visble or not)", $nVisible = 0 "Not Visible Only", $nVisible = 1 "Visible Only"
Func _WinGetHandleByPID($vProc, $nVisible = 1)
    $vProc = ProcessExists($vProc);
    If Not $vProc Then Return SetError(1, 0, 0)
    Local $aWL = WinList()
    Local $aTemp[UBound($aWL)][2], $nAdd = 0
    For $iCC = 1 To $aWL[0][0]
        If $nVisible = -1 And WinGetProcess($aWL[$iCC][1]) = $vProc Then
            $nAdd += 1
            $aTemp[$nAdd][0] = $aWL[$iCC][0]
            $aTemp[$nAdd][1] = $aWL[$iCC][1]
        ElseIf $nVisible = 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _
                BitAND(WinGetState($aWL[$iCC][1]), 2) = 0 Then
            $nAdd += 1
            $aTemp[$nAdd][0] = $aWL[$iCC][0]
            $aTemp[$nAdd][1] = $aWL[$iCC][1]
        ElseIf $nVisible > 0 And WinGetProcess($aWL[$iCC][1]) = $vProc And _
                BitAND(WinGetState($aWL[$iCC][1]), 2) Then
            $nAdd += 1
            $aTemp[$nAdd][0] = $aWL[$iCC][0]
            $aTemp[$nAdd][1] = $aWL[$iCC][1]
        EndIf
    Next
    If $nAdd = 0 Then Return SetError(2, 0, 0);No windows found
    ReDim $aTemp[$nAdd + 1][2]
    $aTemp[0][0] = $nAdd
    Return $aTemp
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

#1 Singleton ( Built-into Autoit )

#include "Misc.au3"
if  _Singleton("test\test",1) =  0 Then
    Msgbox(0,"Warning","An occurence of test is already running")
    Exit
EndIfoÝ÷ Ûd^©¶ºÚ"´xuéÖwhÁ«­¢+Ø졬¥ÁɽÍ̱Éäá¥ÍÑÌ(ÀÌØí}ÍéYÉÍ¥½¸ôÅÕ½Ðí5äa@
±¹ÈÅÕ½Ðì)%]¥¹á¥ÍÑÌ ÀÌØí}ÍéYÉÍ¥½¸¤Q¡¸(5½ÕÍ5½Ù ÔÀÀ°Ô¤(5Í ½à ÈØÈÈÀà°ÅÕ½Ðì¨9=Q¨ÅÕ½Ðì°ÅÕ½Ðì©aA
±¸5¹Ô¨Ý̱ÉäÉÕ¹¹¥¹ÅÕ½Ðì°Ô¤(M½Õ¹A±ä ÀÌØíM½Õ¹}±¹¬°Ä¤(á¥Ðì%ÐÌäí̱ÉäÉÕ¹¹¥¹)¹%)Õѽ%Ñ]¥¹MÑQ¥Ñ± ÀÌØí}ÍéYÉÍ¥½¸oÝ÷ Ûu,xúèqë,.+-jëh×6If UBound(ProcessList(@ScriptName)) > 2 Then
    MsgBox(64, "* NOTE * ", "*XPedite Pro* Demo was already running  ", 5)
    Exit
EndIf

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; Drag GUI

; Author - Zedna

#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)

Const $HTCAPTION = 2
;Const $WM_NCLBUTTONDOWN = 0xA1

$gui = GuiCreate("Title",300,200,-1,-1,$WS_POPUP,BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUISetOnEvent ($GUI_EVENT_CLOSE, "Quit" )
GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" )
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Drag()
    ;dllcall("user32.dll","int","ReleaseCapture")
    dllcall("user32.dll","int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

Func Quit()
    Exit
EndFuncoÝ÷ Ø è¶«jëh×6; Move any Window - Click & Drag

; Author Valuater

Run("notepad.exe")
WinWaitActive("")

While WinExists("Untitled -")
    _WinMove("Untitled -")
    Sleep(10)
WEnd

;===============================================================================
;
; Description:      Moves any Window by Left Mouse "Click & Drag"
; Syntax:           _WinMove($hWnd) or  _WinMove($s_Title)
; Parameter(s):     $s_hWnd = as returned by GUICreate()
;                   $s_Title = title of window to be moved
; Requirement(s):   None
; Return Value(s):  On Success - Repositions the Window
;                   On Failure - Returns ""
; Author(s):        Valuater,  Valuater [at] aol [.com], Inspired by Martin
;
;===============================================================================
Func _WinMove($hWnd)
    If Not WinActive($hWnd) Then Return
    Local $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1')
    If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return
    Local $a = WinGetPos($hWnd), $b = MouseGetPos()
    If $b[0] < $a[0] Or $b[1] < $a[1] Or $b[0] > $a[2] + $a[0] Or $b[1] > $a[3] + $a[1] Then Return
    While WinActive($hWnd)
        Local $c = MouseGetPos()
        WinMove($hWnd, '', $a[0] + $c[0] - $b[0], $a[1] + $c[1] - $b[1])
        $a_R = DllCall('user32.dll', "int", "GetAsyncKeyState", "int", '0x1')
        If @error Or BitAND($a_R[0], 0x8000) <> 0x8000 Then Return
    WEnd
EndFunc   ;==>_WinMove

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • 2 weeks later...

Window Drag using GUIRegister...

; Author - Ms Creator

#include <GuiConstants.au3>

Global Const $WM_LBUTTONDOWN = 0x0201
;Global Const $WM_SYSCOMMAND = 0x0112

$Gui = GuiCreate("Test", 200, 100, -1, -1, $WS_POPUP, $WS_EX_DLGMODALFRAME)
GuiRegisterMsg($WM_LBUTTONDOWN, "_WinMove")

GUISetState()


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
    EndSwitch
WEnd

Func _WinMove($HWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($HWnd), 32) Then Return $GUI_RUNDEFMSG
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

; Detect if System is Locked

; Author GaryFrost

Global Const $DESKTOP_ENUMERATE = 0x40
Global Const $SPI_GETSCREENSAVERRUNNING = 114
Global Const $DESKTOP_SWITCHDESKTOP = 0x100

HotKeySet("{ESC}", "_Terminate")
AdlibEnable("IsDeskTopLocked", 500)

While 1
    Sleep(10)
WEnd

Func IsDeskTopLocked()
    Local $p_lngHwnd, $p_lngRtn, $p_lngErr, $p_lngScreenSaver, $p_blnIsScreenSaver
   
;~    ' ------------------------------------------
;~    ' First check for screen saver one of 2 ways,
;~    '     based of OS
;~    ' ------------------------------------------
    If @OSTYPE = "WIN32_WINDOWS"  Then
;~       ' ---------------------------------------
;~       ' Pre W2K -- Note, will only be TRUE if
;~       '     the "Password Protected" box is
;~       '     checked.
;~       ' ---------------------------------------
        $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "screen-saver", "int", 0, "int", False, "int", $DESKTOP_ENUMERATE)
        If $p_lngHwnd[0] <> 0 Then
            $p_blnIsScreenSaver = True
        Else
            $p_blnIsScreenSaver = False
        EndIf
    Else
;~       ' ---------------------------------------
;~       ' W2K+ -- Will determine if screen saver
;~       '     is running whether or not the
;~       '     "Password Protected" box is checked
;~       ' ---------------------------------------
        $p_lngRtn = DllCall("user32.dll", "int", "SystemParametersInfoA", "int", $SPI_GETSCREENSAVERRUNNING, "int", 0, "int", $p_lngScreenSaver, "int", 0)
        If $p_lngRtn[0] = 0 Then
            ConsoleWrite("Error detecting screen saver" & @LF)
        Else
            $p_blnIsScreenSaver = $p_lngScreenSaver
        EndIf

    EndIf

;~    ' ------------------------------------------
;~    ' If screen saver is *not* running, then
;~    '     check for locked workstation
;~    ' ------------------------------------------
    If $p_blnIsScreenSaver Then
        If @OSTYPE = "WIN32_WINDOWS"  Then
            ConsoleWrite("Screen saver is running..., Handle #" & $p_lngHwnd[0] & @LF)
            $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0])
        Else
            ConsoleWrite("Screen saver is running on W2K+" & @LF)
        EndIf

    Else
        $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "Default", "int", 0, "int", False, "int", $DESKTOP_SWITCHDESKTOP)

        If $p_lngHwnd[0] = 0 Then
            ConsoleWrite("Error with OpenDesktop" & @LF)

        Else
            $p_lngRtn = DllCall("user32.dll", "int", "SwitchDesktop", "int", $p_lngHwnd[0])
            $p_lngErr = _GetLastErrorMessage()

            If $p_lngRtn[0] = 0 Then
                If $p_lngErr = 0 Then
                    ConsoleWrite("Desktop is locked" & @LF)
                Else
                    ConsoleWrite("Error with SwitchDesktop" & @LF)
                EndIf
            Else
                ConsoleWrite("Not locked!" & @LF)
            EndIf

            $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0])

        EndIf
    EndIf
EndFunc   ;==>IsDeskTopLocked

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

;===============================================
;    _GetLastErrorMessage($DisplayMsgBox="")
;    Format the last windows error as a string and return it
;    if $DisplayMsgBox <> "" Then it will display a message box w/ the error
;    Return        Window's error as a string
;===============================================
Func _GetLastErrorMessage($DisplayMsgBox = "")
    Local $ret, $s
    Local $p = DllStructCreate("char[4096]")
    Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000

    If @error Then Return ""

    $ret = DllCall("Kernel32.dll", "int", "GetLastError")

    $ret = DllCall("kernel32.dll", "int", "FormatMessage", _
            "int", $FORMAT_MESSAGE_FROM_SYSTEM, _
            "ptr", 0, _
            "int", $ret[0], _
            "int", 0, _
            "ptr", DllStructGetPtr($p), _
            "int", 4096, _
            "ptr", 0)
    $s = DllStructGetData($p, 1)
    If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & $s)
    Return $s
EndFunc   ;==>_GetLastErrorMessage

8)

NEWHeader1.png

Link to comment
Share on other sites

; Detect Window Flashing in TaskBar

; Author Rizo & Valuater
; This is Rizo's one-and-only post

$XP_Orange = 0xE47B09

Run_Notepad_Demo()

While 1

    $coord = PixelSearch(0, @DesktopHeight - 30, @DesktopWidth, @DesktopHeight, $XP_Orange, 10, 10)

    If Not @error Then
        TrayTip("Location", "X and Y are:" & $coord[0] & "," & $coord[1], 5) ; notification
        MouseClick("left", $coord[0], $coord[1], 1, 0) ; brings Flashing Window Active
        ExitLoop
    EndIf

    Sleep(100)
WEnd


Func Run_Notepad_Demo()
    If Not WinExists("Untitled - ") Then
        Run("Notepad.exe", "", @SW_MINIMIZE)
    EndIf

    WinWait("Untitled - ")

    ; flashes the window 4 times with a break in between each one of 1/2 second
    WinFlash("Untitled - ", "", 4, 500)
EndFunc   ;==>Run_DemooÝ÷ Ø  趫jëh×6; Requires DllCallBack UDF

; Author - siao

#include "DllCallBack.au3"
; No comments on this one. If you dont know whats happening just ignore it.
Global $pWinFlash, $vWinFlash_Jmp, $vWinFlash_Original

$pStub_WinFlash = _DllCallBack("_Stub_WinFlash", "ptr")
$hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll")
$pWinFlash = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "FlashWindowEx")
$vWinFlash_Original = DllStructCreate("ubyte[7]")
DllStructSetData($vWinFlash_Original, 1, DllStructGetData(DllStructCreate("ubyte[7]", $pWinFlash[0]), 1))
$vWinFlash_Jmp = DllStructCreate("ubyte[1];ptr;ubyte[2]")
DllStructSetData($vWinFlash_Jmp, 1, Binary("0xB8"))
DllStructSetData($vWinFlash_Jmp, 2, $pStub_WinFlash)
DllStructSetData($vWinFlash_Jmp, 3, Binary("0xFFE0"))
DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Jmp), "dword", 7, "long_ptr", 0)


Func _Stub_WinFlash($pFLASHWINFO)
    $tFLASHWINFO = DllStructCreate("uint;hwnd;dword;uint;dword", $pFLASHWINFO)
    ConsoleWrite("-----------" & @CRLF & _
                    "Flashing Window Detected:" & @CRLF & _
                    "handle = " & DllStructGetData($tFLASHWINFO, 2) & @CRLF & _
                    "flags = " & DllStructGetData($tFLASHWINFO, 3) & @CRLF & _
                    "count = " & DllStructGetData($tFLASHWINFO, 4) & @CRLF & _
                    "timeout = " & DllStructGetData($tFLASHWINFO, 5) & @CRLF & _
                    "-----------" & @CRLF)
    DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Original), "dword", 7, "long_ptr", 0)
    DllCall("user32.dll", "int", "FlashWindowEx", "ptr", $pFLASHWINFO)
    DllCall("kernel32.dll", "int", "WriteProcessMemory", "ptr", -1, "ptr", $pWinFlash[0], "ptr", DllStructGetPtr($vWinFlash_Jmp), "dword", 7, "long_ptr", 0)
    Return 1
EndFunc

;
Run("notepad","",@SW_MINIMIZE)
WinWait("Untitled - Notepad")
WinFlash("Untitled - Notepad", "",5, 200)

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

; Detect Window Flashing in TaskBar

; Author Rizo & Valuater
; This is Rizo's one-and-only post

$XP_Orange = 0xE47B09

Run_Notepad_Demo()

While 1

    $coord = PixelSearch(0, @DesktopHeight - 30, @DesktopWidth, @DesktopHeight, $XP_Orange, 10, 10)

    If Not @error Then
        TrayTip("Location", "X and Y are:" & $coord[0] & "," & $coord[1], 5) ; notification
        MouseClick("left", $coord[0], $coord[1], 1, 0) ; brings Flashing Window Active
        ExitLoop
    EndIf

    Sleep(100)
WEnd
Func Run_Notepad_Demo()
    If Not WinExists("Untitled - ") Then
        Run("Notepad.exe", "", @SW_MINIMIZE)
    EndIf

    WinWait("Untitled - ")

    ; flashes the window 4 times with a break in between each one of 1/2 second
    WinFlash("Untitled - ", "", 4, 500)
EndFunc   ;==>Run_Demo

http://www.autoitscript.com/forum/index.ph...st&p=300270

8)

<_<

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...