Good morning everyone
I was playing a little bit with "Screen Capture" UDF, and I was trying to make a "Window" capture, but, since I made a GUI which through I fire the event "Capture", my GUI is captured as well, and I don't want to
This is the line of code that makes the capture:
_ScreenCapture_CaptureWnd($strScreenCaptureFileName, $objActiveWindow, 0, 0, -1, -1, False) And these are the lines of code which select the "active" window:
Local $objCurrentWindow = 9999 If _IsPressed("01") Then $objCurrentWindow = WinGetHandle("[ACTIVE]") If $objCurrentWindow <> $objMyGUI Then $objActiveWindow = $objCurrentWindow EndIf EndIf Sorry If I made stupid mistakes
Thanks in advance.
i need a script that can replace words in text with other words from a words list
it has to have 2 edit boxes input/output and a button "run"
from word_list.txt it choses which word to replace with. words are separated with commas for multiple choice
; AutoIt GUI Example ; Created: 17/01/2005 - CyberSlug ; Modifed: 05/12/2011 - guinness ; Modifed: 09/06/2014 - mLipok #Region INCLUDE #include <AVIConstants.au3> #include <GuiConstantsEx.au3> #include <TreeViewConstants.au3> #EndRegion INCLUDE #Region GUI GUICreate("Sample GUI", 400, 420) GUISetIcon(@SystemDir & "\mspaint.exe", 0) #EndRegion GUI #Region EDIT GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10, 10, 380, 175) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT #Region EDIT2 GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10, 185, 380, 175) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT2 #Region BUTTON GUICtrlCreateButton("Sample Button", 10, 360, 100, 30) GUICtrlSetTip(-1, '#Region BUTTON') #EndRegion BUTTON #Region GUI MESSAGE LOOP GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() #EndRegion GUI MESSAGE LOOP
So I'm needing a (better) way to get the selection in an edit control, while knowing which end of the selection is active vs anchor (ie, if you're holding shift while moving with the arrow keys, which end of the selection is moving and which is not). Since _GUICtrlEdit_GetSel() only returns the start and end positions, in the order of smallest to largest, if you were to pass that back to the _GUICtrlEdit_SetSel(), the user's selection could end up "backwards".
My solution has been this function:
Func _GUICtrlEdit_GetSelByAnchor($hWnd) ; Get selection range with anchor in first index If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $aActive, $aSelection = _GUICtrlEdit_GetSel($hWnd) ; Get base selection If $aSelection <> $aSelection Then ; Only proceed if actual selection range _GUICtrlEdit_SetSel($hWnd, -1, 0) ; Deselect, leaving only the active point $aActive = _GUICtrlEdit_GetSel($hWnd) ; Record the active point If $aActive = $aSelection Then ; If the active point is equal to the original first index ; Swap the original selection points (putting the anchor in  and active in ) $aSelection = $aSelection $aSelection = $aActive EndIf _GUICtrlEdit_SetSel($hWnd, $aSelection, $aSelection) ; Reset selection to the original points EndIf Return $aSelection EndFunc The problem with this, as you may have already guessed from the two SetSel calls, is that calling it in a tight loop causes a lot of flickering. Is there a better, more reliable way to do what I'm looking for?
I have tried several way sto get this to work to no avail. Any help would be appreciated. #include <ListViewConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" $idItem = GUICtrlCreateListViewItem($r & " | " & $c & $adoRs.Fields("TransactionAmount").value & " | " & $Timestamp & " | " & _StringProper($adoRs.Fields("Tillid").value) & @CRLF & @CRLF & "Card Number : " & $cardnum & " " , $idListView) ConsoleWrite( "IDITEM" & $idItem) If STRINGLEFT($adoRs.Fields("TransactionAmount").value,1)= "-" Then Consolewrite(" String is Negative" & @CRLF) ;Drops in Here as expected ;GUICtrlSetColor(-1, $COLOR_RED) ; Colour line if item is negative this didn' work $TxC= _GUICtrlListView_SetTextColor($hListView, $CLR_RED) ; I also tried $TxC= _GUICtrlListView_SetTextColor(-1, 0xFF0000) CONSOLEWRITE("TEXTCOLOUR RETURNED " & $TxC & @crlf) ; This is returning True ELSE Consolewrite(" String is NOT Negative" & @CRLF) EndIf
Here is a function that will return a 2D array of visible windows. You will notice that windows "Start" and "Program Manager" windows will always be in the array. The array returns the title of the window, the window handle, the PID of the process associated with the window, the process name associated with the window, the window's position, and the window's dimension, Please see comments in the code about the numbers returned about the window's position.
#include <Array.au3> #include <Process.au3> ;Get a list of visable windows with titles. $aWindows = _GetVisibleWindows() _ArrayDisplay($aWindows) Func _GetVisibleWindows() ;Retrieve a list of windows. Local $aWinList = WinList() If Not IsArray($aWinList) Then Return SetError(0, 0, 0) ;Loop through the array deleting no title or invisable windows. Local $sDeleteRows = "" For $i = 1 To $aWinList If $aWinList[$i] = "" Or Not BitAND(WinGetState($aWinList[$i]), $WIN_STATE_VISIBLE) Then $sDeleteRows &= $i & ";" EndIf Next $sDeleteRows = StringTrimRight($sDeleteRows, 1) ;Remove last ";". _ArrayDelete($aWinList, $sDeleteRows) $aWinList = UBound($aWinList) - 1 ;Get Window's Processor ID (PID), and add to the array. _ArrayColInsert($aWinList, UBound($aWinList, 2)) For $i = 1 To $aWinList $aWinList[$i] = WinGetProcess($aWinList[$i]) Next ;Get Window's Process Name from PID, and add to the array. _ArrayColInsert($aWinList, UBound($aWinList, 2)) For $i = 1 To $aWinList $aWinList[$i] = _ProcessGetName($aWinList[$i]) Next ;Get Windows's Position and Size, and add it to the array. ;For Position, -3200,-3200 is minimized window, -8,-8 is maximized window on 1st display, and ;x,-8 is maximized windown on the nth display were x is the nth display width plus -8 (W + -8). _ArrayColInsert($aWinList, UBound($aWinList, 2)) ;Position (X,Y). _ArrayColInsert($aWinList, UBound($aWinList, 2)) ;Dimension (WxH). Local $aWinPosSize For $i = 1 To $aWinList $aWinPosSize = WinGetPos($aWinList[$i]) $aWinList[$i] = $aWinPosSize & "," & $aWinPosSize $aWinList[$i] = $aWinPosSize & "x" & $aWinPosSize Next Return $aWinList EndFunc ;==>_GetVisibleWindows