Jump to content

Recommended Posts

Hi All, 

 

I am a begginer in auto it. I am trying to build simple gui that will show me if for example notepad.exe process is currently running on the system. I have built something like this, but when I execute it shows me message boxes, but I want the results to show in gui. If you can help me start with this.

 

Thanks

 

 
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>

ActiveProcess()

Func ActiveProcess()
GUICreate("Act")
         ProcessExists("wuauclt.exe")

       If ProcessExists("wuauclt.exe") Then
 MsgBox($MB_SYSTEMMODAL, "", "Windows Upates are running")
     Else
 MsgBox($MB_SYSTEMMODAL, "", "Windows Updates are not running")
 EndIf
   ;Notepad

         ProcessExists("notepad.exe")

         If ProcessExists("notepad.exe") Then
MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
        Else
MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
EndIf

 

 

Link to post
Share on other sites

Hello and welcome to the forum. Here is a simple example:

$hMain = GUICreate('Notepad process')
$Label = GUICtrlCreateLabel('',10,10,380,380,0x201) ; BitOR(SS_CENTERIMAGE, SS_CENTER)
GUISetState(@SW_SHOW, $hMain)

Do
    $PID = ProcessExists('notepad.exe')
    If $PID Then
        GUICtrlSetData($Label, 'Process notepad.exe exists. (PID: ' & $PID & ')')
    Else
        GUICtrlSetData($Label, 'Process notepad.exe doesn''t exists')
    EndIf
    Sleep(10)
Until GUIGetMsg() = -3 ; GUI_EVENT_CLOSE

 

When the words fail... music speaks
Link to post
Share on other sites
  • Moderators

It looks like your ultimate goal is windows updates, where you may want a start and stop message. Something like this perhaps:

#include <Date.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $sText = ""
Local $hGUI = GuiCreate("Act", 300, 300)
Local $hEdit = GUICtrlCreateEdit("", 10, 10, 280, 280, $ES_READONLY)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case Else
                If ProcessExists("notepad.exe") Then
                    GUICtrlSetData($hEdit, "Notepad launched at " & _Now())
                        While ProcessExists("notepad.exe")
                            Sleep(100)
                        WEnd

                        If Not (ProcessExists("notepad.exe")) Then
                            $sText = GUICtrlRead($hEdit)
                            GUICtrlSetData($hEdit, $sText & @CRLF & "Notepad closed at " & _Now())
                        EndIf
                EndIf
        EndSwitch
    WEnd

As you can see, with AutoIt there are many ways to skin the proverbial cat

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
  • Moderators

Can you explain this more? Why do you want to save whether a process is running to an ini file? How about an example of what the ini file would look like?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Yes, so when I run the script, I want these processeses to save to a file to keep a record of them, so whether running or not I would like to log the processes to a file when running the script. I dont know if that makes sense.

Link to post
Share on other sites

Basic script based off JLogan3o13 script:

#include <Date.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $sIniFile = @ScriptDir & "\IniFile.ini"

_ProcessStartEndTime("Notepad.exe")

;~ Read the IniFile
ShellExecute($sIniFile)

Func _ProcessStartEndTime($_sProcess)
    Local $sDateTime, $sText = ""
    Local $hGUI = GuiCreate("Act", 300, 300)
    Local $hEdit = GUICtrlCreateEdit("", 10, 10, 280, 280, $ES_READONLY)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case Else
                If ProcessExists($_sProcess) Then
                    $sDateTime = _Now()
                    IniWrite($sIniFile, $_sProcess, $sDateTime, "Start Time")
                    GUICtrlSetData($hEdit, "Notepad launched at " & $sDateTime)
                        While ProcessExists($_sProcess)
                            Sleep(100)
                        WEnd

                        If Not (ProcessExists($_sProcess)) Then
                            $sDateTime = _Now()
                            IniWrite($sIniFile, $_sProcess, $sDateTime, "End Time")
                            $sText = GUICtrlRead($hEdit)
                            GUICtrlSetData($hEdit, $sText & @CRLF & "Notepad closed at " & $sDateTime)
                        EndIf
                EndIf
        EndSwitch
    WEnd
EndFunc

 

Link to post
Share on other sites

Cheers guys for helping me out. I have managed to do that, but have another problem. I am saving the output to .txt file and everytime I run the script it overwrites the file, but I want it to write it into the same file, but underneath the last output, so I can compare them.
 

Global $sFilePath = "" & $pcname & ".txt"

Updates()


Func Updates()

    IniWrite($sFilePath, "Date:",@ComputerName, _Now())
    IniWrite($sFilePath, "Update:",         $arr[1][0], $arr[1][1] )
    IniWrite($sFilePath, "xxx:",            $arr[2][0], $arr[2][1])
    IniWrite($sFilePath, "xxx:",            $arr[3][0], $arr[3][1])
    IniWrite($sFilePath, "xxx:",            $arr[4][0], $arr[4][1])
    IniWrite($sFilePath, "xxx:",            $arr[5][0], $arr[5][1])
    IniWrite($sFilePath, "xxx:",            $arr[6][0], $arr[6][1])
    IniWrite($sFilePath, "xxx:",            $arr[7][0], $arr[7][1])
    IniWrite($sFilePath, "xxx:",            $arr[8][0], $arr[8][1])
    IniWrite($sFilePath, "xxx:",            $arr[9][0], $arr[9][1])
   
EndFunc

_FileWriteFromArray($sFilePath, $arr)

$From = $sFilePath
$To = "C:\xxx\xxx"

Runwait(@ComSpec & " /c " & "xcopy " & '"' & $From & '"' & ' "' & $To& '"' & " /Y ","",@SW_HIDE

 

Edited by Jake_s
Link to post
Share on other sites

Doesn't FileOpen open a file in append mode? do you need INI or a formatted log? 

if you just looked up log4a.au3 thread like i suggested you would have everything you need to dump it to log super easy. all nice and formatted with date/time stamps. but instead you asked for code the post after that one. sigh.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to post
Share on other sites

Do you want to use an INI file? Then use the INI functions.

Do you want to write it directly from the array, then use _FileWriteFromArray correctly. From the help file:

Quote

If a string path is provided, the file will be overwritten and closed.
To use other write modes, like append or Unicode formats, open the file with FileOpen() first and pass the file handle instead.
If a file handle is passed, the file will still be open after writing.

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites
Just now, Earthshine said:

log4a is better though. more configurable too. you can have it log to the Editor console running from editor, and auto generate a hard log once compiled.

That may be.  My only real point is that INI probably should not be used in this case

Link to post
Share on other sites

really? I said that already in post 2 or 3 but the OP doesn't read it. I also repeated myself a few posts above yours. I guess I'm done with the "Gimme deh codez" posts like this, and the folks who make them ignored.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mLipok
      I check this snippet:
      https://www.autoitscript.com/wiki/Snippets_(_GUI_)#GUI_With_Scrollable_TabItem
      Modified them and I refactored. That's because I needed to adapt it to my needs (I'll write later).
      I thought I understood how it works.
      But I was wrong.
       
      This is my example which is showing what I want to achieve.
      #include <AutoItConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <GUIScrollbars_Ex.au3> #include <StringConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> GUIRegisterMsg($WM_VSCROLL, WM_VSCROLL) _Example() Func _Example() Local $i_Count = 30 Local $a_Options_List[$i_Count + 1] $a_Options_List[0] = $i_Count For $i = 1 To $i_Count $a_Options_List[$i] = 'Test #' & $i Next ConsoleWrite("- " & _my_gui_Wybierz('Testing', $a_Options_List) & @CRLF) EndFunc ;==>_Example Func _my_gui_Wybierz($s_Description, $a_Options_List = "", $i_Left = Default, $i_Top = Default, $i_Width = Default, $hWnd_Parent = 0) ;~ WinSetOnTop($ACROBAT_TITLE, "", $WINDOWS_NOONTOP ) If $i_Left = Default Then $i_Left = -1 If $i_Top = Default Then $i_Top = -1 If $i_Width = Default Then $i_Width = 400 #Region _my_gui_Wybierz - GUI Creation Local $i_Height = 600 Local $hWND_DateForm = GUICreate("", $i_Width, $i_Height, $i_Left, $i_Top, BitOR(0, $WS_SIZEBOX), -1, $hWnd_Parent) WinSetOnTop($hWND_DateForm, "", $WINDOWS_ONTOP) Local $hChild = GUICreate("Scroll area", $i_Width - 15, $i_Height - 40, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $hWND_DateForm) _GUIScrollBars_Init($hChild, -1) _GUIScrollBars_ShowScrollBar($hChild, $SB_HORZ, False) _GUIScrollBars_ShowScrollBar($hChild, $SB_VERT, True) ;~ _GUIScrollBars_SetScrollRange($hChild, $SB_VERT, 3, 30) GUICtrlCreateLabel("", 10, 7, $i_Width - 45, 80) Local $id_Label1 = GUICtrlCreateLabel("", 10, 7 + 5, $i_Width - 45, 80 - 5) GUICtrlSetBkColor(-1, 0x88AABB) Local $a_List_of_Button_ID[$a_Options_List[0] + 1] For $IDX_Item = 1 To $a_Options_List[0] If $IDX_Item > 0 And $IDX_Item < 10 Then $a_List_of_Button_ID[$IDX_Item] = GUICtrlCreateButton( _ $IDX_Item & ". " & $a_Options_List[$IDX_Item], _ 10, 90 + ($IDX_Item - 1) * 21, $i_Width - 45, 20, BitOR($BS_LEFT, $WS_GROUP)) Else $a_List_of_Button_ID[$IDX_Item] = GUICtrlCreateButton( _ Chr(Asc('A') + $IDX_Item - 10) & ". " & $a_Options_List[$IDX_Item], _ 10, 90 + ($IDX_Item - 1) * 21, $i_Width - 45, 20, BitOR($BS_LEFT, $WS_GROUP)) EndIf Next Local $temp_var = $a_Options_List[0] Local $a_accelerators[($temp_var * 2) + 1][2] Local $i_Accelerators_Counter = 0 Local $i_Accelerator_Char1 = '' Local $i_Accelerator_Char2 = '' For $IDX_Item = 1 To $a_Options_List[0] If $IDX_Item > 9 Then $i_Accelerator_Char1 = Chr(Asc('A') + $IDX_Item - 10) $i_Accelerator_Char2 = Chr(Asc('a') + $IDX_Item - 10) Else $i_Accelerator_Char1 = "{NUMPAD" & $IDX_Item & "}" ;Chr(48 + $IDX_Item) $i_Accelerator_Char2 = $IDX_Item EndIf $a_accelerators[($IDX_Item * 2) - 1][0] = $i_Accelerator_Char1 $a_accelerators[($IDX_Item * 2) - 1][1] = $a_List_of_Button_ID[$IDX_Item] $a_accelerators[($IDX_Item * 2) - 1 + 1][0] = $i_Accelerator_Char2 $a_accelerators[($IDX_Item * 2) - 1 + 1][1] = $a_List_of_Button_ID[$IDX_Item] $i_Accelerators_Counter += 2 Next $a_accelerators[0][0] = $i_Accelerators_Counter GUISetAccelerators($a_accelerators, $hChild) GUICtrlSetData($id_Label1, $s_Description) GUISetState(@SW_SHOW, $hWND_DateForm) GUISetState(@SW_SHOW, $hChild) #EndRegion _my_gui_Wybierz - GUI Creation #Region - _my_gui_Wybierz - Handling messages Local $i_Selected_item = 0 Local $v_Return_Value = "" Local $a_GUI_Messages While 1 $a_GUI_Messages = GUIGetMsg($GUI_EVENT_ARRAY) If $a_GUI_Messages[0] = $GUI_EVENT_NONE Then ; do nothing ElseIf $a_GUI_Messages[1] = $hWND_DateForm Then If $a_GUI_Messages[0] = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $a_GUI_Messages[1] <> $hChild Then ; .... Else For $IDX_Check = 1 To $a_Options_List[0] If $a_List_of_Button_ID[$IDX_Check] = $a_GUI_Messages[0] Then $v_Return_Value = GUICtrlRead($a_List_of_Button_ID[$IDX_Check]) $i_Selected_item = $IDX_Check $v_Return_Value = _RegExpFirstMatch($v_Return_Value, '.+?\. (.+)') ExitLoop 2 ; exit from ForNext and also from WhileWend EndIf Next EndIf WEnd #EndRegion - _my_gui_Wybierz - Handling messages GUIDelete($hChild) GUIDelete($hWND_DateForm) Return SetError(0, $i_Selected_item, $v_Return_Value) EndFunc ;==>_my_gui_Wybierz Func WM_VSCROLL($hWnd, $msg, $wParam, $lParam) #forceref $msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $yChar = $aSB_WindowInfo[$index][3] ExitLoop EndIf Next If $index = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch ; Set the position and then retrieve it. Due to adjustments ; by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; If the position has changed, scroll the window and update it $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Func _RegExpFirstMatch($s_Data, $s_Pattern) Local $a_Results = StringRegExp($s_Data, $s_Pattern, $STR_REGEXPARRAYGLOBALMATCH) If @error Then Return SetError(@error, @extended, '') Return SetError(0, UBound($a_Results), $a_Results[0]) EndFunc ;==>_RegExpFirstMatch  
      I have few problems with this code, and many question related to them.
      Question 1:
      How to make the Scrollbars to work ?
      I mean to scroll buttons.
      Question 2:
      Do I must to ues Child Window, or is it possible to scroll buttons without using Child Window ?
      Question 3:
      Why after uncommenting this following line:
      ;~ _GUIScrollBars_SetScrollRange($hChild, $SB_VERT, 3, 30) the ScrollBar disapears ?
    • By Mo0C0w
      Hey guys!
      I just started working with the GUI yesterday and it has only brought more fun to the Autoit adventure  
      Basically I have a GUI windows that opens and based on the selection of the combo box the button will do something different. This specific scenario I am talking about the Client Update Verification  combo selection. When selected and the button is pressed my second gui window opens. As of now if I only paste comp1 or comp2 by itself it works correctly, but if I paste both, it has a fit.
      What would the correct way to do this be? Any help or examples, would be greatly appreciated! Thank you in advance
       
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Client_List.au3> #Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiibox v4.kxf Global $Form1_1 = GUICreate("Plexii", 336, 419, 1548, 586) GUISetBkColor(0xFFFFFF) Global $Pic1 = GUICtrlCreatePic("C:\Users\dnoble\Pictures\plexii.jpg", 41, 0, 252, 268, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE)) Global $Label2 = GUICtrlCreateLabel("Select Test", 125, 280, 95, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $Combo2 = GUICtrlCreateCombo("Select Test", 39, 312, 257, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Client Update Verification|Bids") GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Global $Button1 = GUICtrlCreateButton("Proceed", 111, 352, 129, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Combo2) = "Client Update Verification" Then _Form2() ;clientupdateverification() EndSwitch WEnd Func _Form2() #Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiiboxclientupdate verification.kxf $Form1_1 = GUICreate("Plexii", 336, 521, 866, 454) GUISetBkColor(0xFFFFFF) $Edit1 = GUICtrlCreateEdit("", 57, 72, 241, 345) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Execute", 95, 440, 145, 41) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Edit1) = "comp1" Then comp1() If GUICtrlRead($Edit1) = "comp2" Then comp2() EndSwitch WEnd EndFunc  

    • By XGamerGuide
      I'm trying to assign a faint text in the background to an input field that disappears after the input has started. This should have a certain color such as gray.
    • By Bruceway
      Hi All, 
      I am trying to mark out the middle square of this Magnify Routine "window on right" (stolen from M23 - Thanks) - I assume the DllCall is overwriting the boxes. But wherever I try and redraw, they won't stay on the Magnify Window. Can anyone advise, bet way to keep boxes around the middle square.
      Please be kind with my code, it is ripped from a MUCH bigger exe.
      The "half" transparent window, is for dragging to where you want it, and the buttons are for more precise placement.
      #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $hMag_GUI, $hMagDC, $hDeskDC, $hPen, $oObj, $aWinPos[2], $iLast_Mouse_X = 0, $iLast_Mouse_Y = 0 Global $pWindowCaptureX, $pWindowCaptureY Global $pWindowMagWinX, $pWindowMagWinY #Region - GUI3 ; *** Grabber/Picker Window Global $hGUI3 = GUICreate("Capture", 150, 150, $pWindowCaptureX, $pWindowCaptureY, $WS_EX_TOOLWINDOW) Global $Pic1 = GUICtrlCreatePic("", 70, 40, 10, 10, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER)) Global $hButtonUp = GUICtrlCreateButton("U", 65, 60, 20, 20) Global $hButtonDown = GUICtrlCreateButton("D", 65, 100, 20, 20) Global $hButtonLeft = GUICtrlCreateButton("L", 40, 80, 20, 20) Global $hButtonRight = GUICtrlCreateButton("R", 90, 80, 20, 20) Global $hButtonOK = GUICtrlCreateButton("OK", 60, 80, 30, 20) #EndRegion - GUI3 #Region - GUI4 Global $hGUI4 = GUICreate("MagWin", 250, 250, 325, 195) Global $hButtonMOK = GUICtrlCreateButton("OK", 45, 140, 30, 20) Global $hButtonMUp = GUICtrlCreateButton("U", 50, 120, 20, 20) Global $hButtonMDown = GUICtrlCreateButton("D", 50, 160, 20, 20) Global $hButtonMLeft = GUICtrlCreateButton("L", 25, 140, 20, 20) Global $hButtonMRight = GUICtrlCreateButton("R", 75, 140, 20, 20) Global $hLabelWindow = GUICtrlCreateLabel("Window", 5, 185, 44, 15) Global $hLabelWindowText = GUICtrlCreateLabel("", 60, 185, 176, 15) Global $hLabelCheck = GUICtrlCreateLabel("Check", 5, 205, 44, 15) Global $hLabelCheckText = GUICtrlCreateLabel("", 60, 205, 176, 15) Global $hLabelScreen = GUICtrlCreateLabel("Screen", 5, 225, 44, 15) Global $hLabelScreenText = GUICtrlCreateLabel("", 60, 225, 176, 15) #EndRegion - GUI4 ;GUISetState(@SW_HIDE, $hGUI1) GUISetState(@SW_SHOW, $hGUI3) GUISetState(@SW_SHOW, $hGUI4) WinSetTrans($hGUI3, "", 100) $hMag_GUI = WinGetHandle("MagWin") ; Get device context for Mag GUI $hMagDC = _WinAPI_GetDC($hMag_GUI) If @error Then Exit ; Get device context for desktop $hDeskDC = _WinAPI_GetDC(0) If @error Then _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) Exit EndIf ; Create pen $hPen = _WinAPI_CreatePen($PS_SOLID, 5, 0x7E7E7E) $oObj = _WinAPI_SelectObject($hMagDC, $hPen) ; Loop until the user exits. ; *** Static Window While 1 ; Reset position Local $aWinPos = WinGetPos("Capture") If $aWinPos[0] <> $iLast_Mouse_X Or $aWinPos[1] <> $iLast_Mouse_Y Then ; Redraw Mag GUI _FOEA_Loupe($aWinPos) ;~ Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle ;~ Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;~ ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) GUISetState(@SW_HIDE, $hGUI3) Local $output1 = PixelCheckSum($aWinPos[0]+81, $aWinPos[1]+75, $aWinPos[0]+91, $aWinPos[1]+85) Local $output2 = PixelCheckSum($aWinPos[0]+73, $aWinPos[1]+66, $aWinPos[0]+83, $aWinPos[1]+76) If $aWinPos[0] < 1440 Then GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81 & "(" & $aWinPos[0]+81+1440 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 & ")," & $aWinPos[1]+66 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 &")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) Else GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81-1440 & "(" & $aWinPos[0]+81 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+89-1440 & "(" & $aWinPos[0]+89 &")," & $aWinPos[1]+84 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73-1440 & "(" & $aWinPos[0]+73 & ")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) ;GUICtrlSetData($hLabel2, $aWinPos[1]+75) EndIf GUISetState(@SW_SHOW, $hGUI3) $iLast_Mouse_X = $aWinPos[0] $iLast_Mouse_Y = $aWinPos[1] $pWindowCaptureX = $aWinPos[0] $pWindowCaptureY = $aWinPos[1] ; *** Box ; Tried it here - doesn't work ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(194, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 73, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(0, 0, 1, 1) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Local $aWinPos = WinGetPos("MagWin") $pWindowMagWinX = $aWinPos[0] $pWindowMagWinY = $aWinPos[1] ;GUISetState(@SW_HIDE, $hGUI3) GUIDelete($hGUI3) ; Clear up Mag GUI _WinAPI_SelectObject($hMagDC, $oObj) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDeskDC) _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) ;GUISetState(@SW_HIDE, $hMag_G GUIDelete($hGUI4) GUIDelete($hMag_GUI) ExitLoop Case $hButtonMOK GUISetState(@SW_HIDE, $hGUI3) Local $aWinPos = WinGetPos("Capture") Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) If $aWinPos[0] > 1440 Then $aWinPos[0] = $aWinPos[0]-1440 $TWPx = $TWPx-1440 EndIf Local $output0 = PixelCheckSum($TWPx-8, $TWPy-9, $TWPx-8+10, $TWPy+1) ;_FOEA_WinAPI_DrawRect(LRChecksum($TWPx-8), $TWPy-9, LRChecksum($TWPx-8)+10, $TWPy+1, 0xFFFFFF, 50) MsgBox($MB_SYSTEMMODAL, "Results ", _ "Window Coords" & @CRLF & _ $TWPx & "(" & $TWPx+1440 & "), " & $TWPy & @CRLF & _ "Checksum0: " & $output0 & @CRLF) GUISetState(@SW_SHOW, $hGUI3) WinActivate($hGUI3, "Capture") Case $hButtonMUp _FOEA_ButtonMUp() Case $hButtonMDown _FOEA_ButtonMDown() Case $hButtonMRight _FOEA_ButtonMRight() Case $hButtonMLeft _FOEA_ButtonMLeft() EndSwitch WEnd Func _FOEA_Loupe($aWinPos) Local $iX, $iY DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 10, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+68, "int", $aWinPos[1]+61, "int", 20, "int", 20, _ "long", $SRCCOPY) DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 130, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+70, "int", $aWinPos[1]+63, "int", 7, "int", 7, _ "long", $SRCCOPY) ; Appears initially - then disappears... Global $Graph1 = GUICtrlCreateGraphic(170, 57, 8, 16, $SS_WHITERECT) Global $Graph2 = GUICtrlCreateGraphic(170, 73, 31, 8, $SS_WHITERECT) Global $Graph3 = GUICtrlCreateGraphic(193, 57, 8, 16, $SS_WHITERECT) Global $Graph4 = GUICtrlCreateGraphic(170, 49, 31, 8, $SS_WHITERECT) ; This apears to be needed to stop the Magnify window moving Global $Graph5 = GUICtrlCreateGraphic(0, 0, 1, 1) ;Tried this too - no difference GUISetState(@SW_SHOW, $Graph1) GUISetState(@SW_SHOW, $Graph2) GUISetState(@SW_SHOW, $Graph3) GUISetState(@SW_SHOW, $Graph4) EndFunc ;==>Loupe Func _FOEA_ButtonMUp() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]-1) EndFunc Func _FOEA_ButtonMDown() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]+1) EndFunc Func _FOEA_ButtonMRight() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]+1, $aWinPos[1]) EndFunc Func _FOEA_ButtonMLeft() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]-1, $aWinPos[1]) EndFunc  
    • By XGamerGuide
      I'm trying to display a GIF. However, the GUI should not be visible. Here is an attempt that doesn't work:
      $sGIF = "MyGIF.gif" #Include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <SendMessage.au3> Global Const $SC_DRAGMOVE = 0xF012 HotKeySet("{ESC}", "_Exit") $hGui = GUICreate("Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) $oIE = _IECreateEmbedded() GUICtrlCreateObj($oIE, 10, 10, 380, 280) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) _IENavigate($oIE, $sGIF) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd Func _Exit() Exit  
×
×
  • Create New...