Leaderboard
Popular Content
Showing content with the highest reputation on 04/20/2019 in all areas
-
Check every 10sec _ImageSearch()
churaproth and one other reacted to El-Masry for a topic
You are lucky that I have seen your topic ! ======= First of all, you shouldn't use the ordinary image search function...as it is not good because it requires that the image appears on the screen, so you can't do any other thing while the script is running ,so you need the ~:{:}{ImageSearchEX}{:}:~ function by it,you can search for the image in a specific window...and the function don't require that the image appears on the screen >> only it should appear on the window ,so this function run in the background ======= Image Search EX Topic : https://www.autoitscript.com/forum/topic/196542-image-search-inactive-window-but-not-minimized/ ======= note that : 1 : This function doesn't run on X64 bit ,so you have to make the script run on 32 bit by using : #AutoIt3Wrapper_UseX64=NO 2 : This function requires the window to be shown ,not minimized or hidden. ,so if you want to hide the window : just move it to (-X , -Y) Position that is out of the screen ====== Eventually : Here is the code you need : #NoTrayIcon #AutoIt3Wrapper_UseX64=NO #include <imageSearchEX.au3> Global $imageSearchEX = imageSearchEX Global $_Check_Image = _Check_Image $Your_Window = "";your window $Your_Control = "";your Control $Your_Image = "";your Image While 1 $Coords = $_Check_Image($Your_Window,$Your_Control,$Your_Image) If $Coords <> 0 Then ;Do Something ExitLoop EndIf Sleep(10000) ;Sleep 10 Seconds WEnd Func _Check_Image($Window, $Control, $Image) $Hwnd = WinGetHandle($Window) $Control_Pos = ControlGetPos($Hwnd,$Control) $Coords = $imageSearchEX($Hwnd,$Image) Return $Coords EndFunc2 points -
Another easy solution is to use notification like this : GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = _WinAPI_LoWord($wParam) Local $iCode = _WinAPI_HiWord($wParam) If $iIDFrom = $idEdit Then If $iCode = $EN_SETFOCUS Then GUISetAccelerators("") If $iCode = $EN_KILLFOCUS Then GUISetAccelerators($Arr) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND1 point
-
Case $msg = $Enter_KEY If ControlGetFocus ($hGUI) = "Edit2" Then ControlSend ($hGUI,"","Edit2", @LF) Something as simple as that ?1 point
-
@Nine I believe the issue is related to browser restrictions limiting access to cross-domain elements. I was actually able to make it work by navigating to the domain that contains the desired data -- #include <IE.au3> #include <array.au3> $oIE = _IECreate("https://www.cmegroup.com/trading/interest-rates/countdown-to-fomc.html") _IENavigate($oIE, "https://cmegroup-tools.quikstrike.net/User/QuikStrikeView.aspx?viewitemid=IntegratedFedWatchTool") $oTable = _IETableGetCollection($oIE, 4) $aData = _IETableWriteToArray($oTable) _ArrayDisplay($aData)1 point
-
as i understand, TCPStartUp() works for the entire process, and is scope-agnostic. suppose i'm writing a UDF that makes use of TCP. i neither know nor care if the calling script uses TCP too. the calling script may or may not call TCPStartUp() or TCPShutDown() at its discretion. should i be concerned about that at all? my initial thought was to mandatory call TCPStartUp() in my UDF, and register an OnExit function for TCPShutDown(). but what if the calling script does the same? what if the calling script calls TCPShutDown() while my UDF is using it still? do i need to test for TCP status at the beginning of each function in my UDF, so i can start it if it isn't started yet? that seems too inelegant. ideas?1 point
-
TCPStartUp() in a UDF - best practice?
Xandy reacted to user4157124 for a topic
For a UDF, TCPStartUp() is the including script's responsibility (like caling _GDIPlus_Startup() or _SQLite_Startup() prior to using functions from a UDF that depend on these libraries). Check in each function helps debugging (uninitialized use will error eventually, a check at least identifies the cause), but TCP functions return @error WSANOTINITIALISED (10093) if called prior to TCPStartup() already. Generally speaking, anything of global effect is the script's (not UDF's) responsibility (code becomes inflexible/unmanageable otherwise). Of course you can do as you please (it's a convenience vs. flexibility trade off eventually).1 point -
Notify - New version 17 Mar 22
AndroidZero reacted to Melba23 for a topic
Hi, AndroidZero started another thread asking how to read the content of a clicked notification. Here is some Beta code which has this facility along with the title/message clicked functionality from the posts above: UDF: Example script: Let me know if it is of use to anyone, particularly AndroidZero! M231 point -
Getting Message from Notification - Notify.au3
AndroidZero reacted to Melba23 for a topic
AndroidZero, As the question was specific to the Notify UDF, why did you not post in the UDF thread where I am more likely to see it? Anyway, if you do go to the thread, you will see I have a new Beta which should help you get what you want without fiddling in the INTERNAL_USE_ONLY functions. M231 point -
Thanks a lot for your help! I'm sorry if I didn't replied, but I was sick 🤒1 point
-
Thanks for this 2nd chance 🙂. Also, I have studied the forum rules well. 😀1 point
-
Also, I have suffered from his problem.. And that took many time and effort of search.. Because no one helped me 😒💔1 point
-
I am just helping him, which is not against forum rules!.1 point
-
Hey @El-Masry, or should I say @ibrahem... and what an entrance 😟 Jos1 point
-
Sorry,the code is not complete ..i didn't revise it 🤒 Also, there is no (Edit) Button 🙄 Here it is : #NoTrayIcon #AutoIt3Wrapper_UseX64=NO #include <imageSearchEX.au3> Global $imageSearchEX = imageSearchEX Global $_Check_Image = _Check_Image $Your_Window = "";your window $Your_Control = "";your Control $Your_Image = "";your Image While 1 $Coords = $_Check_Image($Your_Window,$Your_Control,$Your_Image) If $Coords <> 0 Then ;Do Something ExitLoop EndIf Sleep(10000) ;Sleep 10 Seconds WEnd Func _Check_Image($Window, $Control, $Image) $Hwnd = WinGetHandle($Window) $Control_Pos = ControlGetPos($Hwnd,$Control) $Coords = $imageSearchEX($Hwnd,$Image) $Result = $Coords If $Coords <> 0 Then Local $Image_Pos[] = [ $Coords[0] - $Control_Pos[0], $Coords[1] - $Control_Pos[1] ] $Result = $Image_Pos EndIf Return $Result EndFunc1 point
-
Computer Info UDF's
RestrictedUser reacted to JSThePatriot for a topic
When I first visit a new client, I take inventory of their machines, what is on them, stats, and other useful information. Up till now I would either write the information down, or just try to remember it myself. Then I decided why not write a script that would allow me to gather all this useful information, and put it in a format that I can understand and possibly print. I created that program (its even listed in this thread). I then expounded on my ideas, and have created this great Computer Information Library. Feel free to use it as you see fit, but please credit when you use one of my functions. Keywords: CompInfo, CompInfo.au3, Library, Computer, Computers, Info, Information, WMI, Windows Management Instrumentation Requires: AutoIt v3.2 + or AutoIt Beta v3.2.1.2+ Software UDFs _ComputerGetStartup _ComputerGetSoftware _ComputerGetUsers _ComputerGetGroups _ComputerGetServices _ComputerGetThreads _ComputerGetProcesses _ComputerGetOSs _ComputerGetShares _ComputerGetEventLogs _ComputerGetBootConfig _ComputerGetExtensions _ComputerGetDesktops _ComputerGetDependentServices _ComputerGetPrintJobs _ComputerGetLoggedOnUsers Hardware UDFs _ComputerGetDrives _ComputerGetPrinters _ComputerGetProcessors _ComputerGetBIOS _ComputerGetSoundCards _ComputerGetVideoCards _ComputerGetKeyboard _ComputerGetMouse _ComputerGetSystemProduct _ComputerGetNetworkCards _ComputerGetSystem _ComputerGetMonitors _ComputerGetMotherboard _ComputerGetBattery _ComputerGetMemory I have finally created an include file with the above listed UDF's. I will be continually adding to this file. Include File: CompInfo.au3 | 1671 Previous Downloads (Total) Example File: CompInfoExamples.au3 | 929 Previous Downloads (Total) I have listed special thanks in the include file. Please note all example code will now start with #include "CompInfo.au3". I am working on adding error checking and standardizing the code. (Note: I haven't spent much time doing this as of late) NerdFencer has created a set of Drive UDF's that were inspired from this code. If you need more drive information please see his thread. ?do=embed' frameborder='0' data-embedContent> Edit 01: Added _ComputerGetPrinters Edit 02: Added _ComputerGetCPUs Edit 03: Changed _DriveGetInfo to _ComputerGetDrives Edit 04: Updated _ComputerGetDrives with documentation and error checking. Edit 05: Fixed _ComputerGetUsers @ComputerName wasnt being used properly. Edit 06: Added _ComputerGetGroups Edit 07: Updated _ComputerGet Printers/Groups with documentation and error checking. Edit 08: Changed _ComputerGetUsers to include more information. Updated _ComputerGetUsers with documentation and error checking. Edit 09: Changed _ComputerGetStartup to include more information. Updated _ComputerGetStartup with documentation and error checking. Edit 10: Added _ComputerGetServices Edit 11: Added to the top of the post about requiring AutoIt's Beta version. Edit 12: Added _ComputerGetBIOS Edit 13: Added _ComputerGetThreads Edit 14: Changed _ComputerGetCPUs to _ComputerGetProcessors and included more information. Edit 15: Added _ComputerGetProcesses Edit 16: Changed _ComputerGetPrinters to include more information and documentation. Edit 17: Added an Example file containing all 11 current UDF's in one simple file. Edit 18: Added _ComputerGetOSs, _ComputerGetShares, _ComputerGetEventLogs Edit 19: Added to the top about no longer requiring a Beta version to work correctly. Requires v3.2 + Edit 20: Added _ComputerGetSoundCards, _ComputerGetVideoCards Updated _ComputerGetGroups (moved "Description" to element 4 to match the rest of the library). Updated Processes, OSs, Processors, Services, Software, Threads, Printers, BIOS, and EventLogs to have the same header layout. Alphabetized CompInfo.au3 and CompInfoExamples.au3 Edit 21: Updated _ComputerGetOSs (Bug Fix) in CompInfoExamples.au3 (Thanks Koala) Edit 22: Added _ComputerGetKeyboard, _ComputerGetMouse Edit 23: Added _ComputerGetSystemProduct, _ComputerGetBootConfig Updated Spelling errors and misc items in CompInfoExamples.au3 Edit 24: Added _ComputerGetNetworkCards Edit 25: Added _ComputerGetExtensions, and _ComputerGetSystem Edit 26: Added _ComputerGetDesktops, _ComputerGetDependentServices, _ComputerGetPrintJobs, _ComputerGetBattery, _ComputerGetMotherboard, and _ComputerGetMonitor Edit 27: Added _ComputerGetMemory, and _ComputerGetLoggedOnUsers Edit 28: Updated CompInfo Version Information Error Edit 29: Linked ?do=embed' frameborder='0' data-embedContent> Thanks, JS1 point -
txt file read line by line
RestrictedUser reacted to Jos for a topic
Your code is quite messy when it comes to the use of the variable $file. It is both used as the original input filename and the output filehandle! What is the ClipPut & Clipget for? This should be close but is untested! Func Start() $file = "youtube.txt" $fhi = FileOpen($file, 0) If @error Then Return 0 $fho = FileOpen("youtubetitles.txt", 1) While 1 $line = FileReadLine($fhi) If @error Then ExitLoop ; EOF encountered ;~ What is this for? ;~ $NewURL = ClipPut($line) ;~ $NewURL = ClipGet() Local $oIE = _IECreate($NewURL) _IELoadWait($oIE) Local $oDiv = _IEGetObjById($oIE, "eow-title") FileWrite($fho, $oDiv.innertext & @CRLF) _IEQuit($oIE) WEnd FileClose($fhi) FileClose($fho) return 1 EndFunc ;==>Start Jos1 point -
I've solved the issue with the non-standard text drag and drop behaviour. RichEdit text drag and drop operations now work the same as Wordpad with this modification. The GetDragDropEffect callback has been modified to determine if the drag and drop operation is within the RichEdit, or between it and another source/destination. $pdwEffect in the IRichEditOleCallback::GetDragDropEffect method is returning 3 (DROPEFFECT_COPY + DROPEFFECT_MOVE) for every drag and drop event. It should be: DROPEFFECT_COPY = 1 for no key or Ctrl key dragging between source and destination. (The drag cursor should have the + box for DROPEFFECT_COPY) DROPEFFECT_MOVE = 2 for Alt key dragging between source and destination. DROPEFFECT_COPY + DROPEFFECT_MOVE = 3 for dragging text within source RichEdit with no key, Ctrl or Alt key (Key modifiers alter the drag behaviour within the same RichEdit) References: IRichEditOleCallback::GetDragDropEffect method http://msdn.microsoft.com/en-us/library/windows/desktop/bb774319(v=vs.85).aspx pdwEffect Type: LPDWORD Pointer to the variable that contains the effect used by a rich edit control. When fDrag is TRUE, on return, its content is set to the effect allowable by the rich edit control. When fDrag is FALSE, on return, the variable is set to the effect to use. IDropSource::QueryContinueDrag method http://msdn.microsoft.com/en-us/library/windows/desktop/ms690076(v=vs.85).aspx grfKeyState [in]: The current state of the keyboard modifier keys on the keyboard. Possible values can be a combination of any of the flags MK_CONTROL, MK_SHIFT, MK_ALT, MK_BUTTON, MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON. Disclaimer: If you are going to try this, please make a backup or use a renamed copy of GuiRichEdit.au3 Note: As of v3.3.8.0, you need to download the version of GuiRichEdit.au3 in post #7 Edit: Added additional handle checking, and MouseCoordMode option I was getting the odd case where text dragged from Wordpad to an AutoIt RichEdit was cut instead of copied. The problem is probably the least reliable area of this code: getting the source and destination handles. (and not all draggable text sources/destinations will have readable handles) This code just demonstrates the D&D issues. The proper fix is probably some COM object magic I noticed, memory usage increases with added text, but doesn't decrease when text deleted (occurs without this fix) Replacement GetDragDropEffect function and vars for GuiRichEdit.au3 ;Replace the function and add the vars to GuiRichEdit.au3 Global Const $DROPEFFECT_COPY = 1 Global Const $DROPEFFECT_MOVE = 2 Global Const $MK_ALT = 0x20 Global Const $MK_CONTROL = 0x8 Global $iMode, $hDragSource ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __RichCom_Object_GetDragDropEffect ; Description ...: ; Syntax.........: __RichCom_Object_GetDragDropEffect($pObject, $fDrag, $grfKeyState, $pdwEffect) ; Parameters ....: ; Return values .: ; Author ........: ; Modified.......: rover 2k12 ; Remarks .......: Patch to demonstrate issue with RichEdit defaulting to DROPEFFECT_COPY+DROPEFFECT_MOVE for drag and drop events between source/destination ($pdwEffect value = 3) ; ...............: Drop Effect should change depending on source/destination. Key modifiers should work the same way as Wordpads RichEdit (MS WordPad would be a RichEdit standard I assume?) ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func __RichCom_Object_GetDragDropEffect($pObject, $fDrag, $grfKeyState, $pdwEffect) #forceref $pObject, $fDrag, $grfKeyState, $pdwEffect If $fDrag Then ;only sent once at start of drag within same edit or between edits in script process ;TRUE if the query is for a IDropTarget::DragEnter or IDropTarget::DragOver. FALSE if the query is for IDropTarget::Drop. $hDragSource = _WinAPI_GetFocus() ;get drag source handle (only used for comparing to another AutoIt Richedit control) Return $_GCR_E_NOTIMPL EndIf If $grfKeyState = ($MK_CONTROL + $MK_ALT) Then $grfKeyState = 0 ; A Ctrl/Alt key combination does a drag copy between windows, so might as well allow for it. Switch $grfKeyState ;= 0 or key modifier only when mouse released, now we set the drop effect Case 0, $MK_CONTROL, $MK_ALT ;_WinAPI_GetFocus() not working here, always returns source handle of 1st richedit when over 2nd richedit in same gui Local $tDROPEFFECT = DllStructCreate("dword", Ptr($pdwEffect)) Local $tPoint = DllStructCreate($tagPOINT) Local $iOpt = Opt("MouseCoordMode", 1) DllStructSetData($tPoint, "x", MouseGetPos(0)) DllStructSetData($tPoint, "y", MouseGetPos(1)) Opt("MouseCoordMode", $iOpt) Local $hWnd = _WinAPI_WindowFromPoint($tPoint) $iMode = $DROPEFFECT_COPY ;default: $MK_LBUTTON Or $MK_RBUTTON - DD between source/destination If $grfKeyState = $MK_ALT Then $iMode = $DROPEFFECT_MOVE ;DD between source/destination If $hDragSource = $hWnd And (IsHWnd($hDragSource) + IsHWnd($hWnd)) <> 0 Then $iMode = $DROPEFFECT_COPY + $DROPEFFECT_MOVE ;DD within same edit (No key, $MK_ALT or $MK_CONTROL modifier keys) DllStructSetData($tDROPEFFECT, 1, $iMode) $hDragSource = 0 ;reset source handle (not set for a drag from an external process ($fDrag = False )) EndSwitch Return $_GCR_E_NOTIMPL EndFunc ;==>__RichCom_Object_GetDragDropEffect Example with restored selected text after drag event #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #Include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <WinAPI.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global $iDLLUser32 = DllOpen("User32.dll"), $hRich1, $hRich2 _DualRichEdit() Func _DualRichEdit() Local $hForm = GUICreate("", 600, 300, -1, -1,-1 ,BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate") GUICtrlCreateLabel("First Rich Text Field", 20, 20) GUICtrlCreateLabel("Second Rich Text Field", 300, 20) GUICtrlCreateLabel("Enter text into the first field ... then highlight it and drag/drop it into the second field.", 20, 250, 560, -1) GUICtrlSetFont(-1, 11, 400, -1, "Arial") GUICtrlCreateLabel("I need the dropped text to remain in the first field ... and preferably remain highlighted.", 20, 270, 560, -1) GUICtrlSetFont(-1, 10, 800, -1, "Arial") $hRich1 = _GUICtrlRichEdit_Create($hForm, "", 20, 40, 200, 200, BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetEventMask($hRich1, $ENM_DRAGDROPDONE) _GUIScrollBars_ShowScrollBar($hRich1, $SB_VERT, True) ;GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;does not work with UDF controls (-1 only works with native AutoIt controls) $hRich2 = _GUICtrlRichEdit_Create($hForm, "", 300, 40, 200, 200, BitOR($ES_WANTRETURN, $ES_MULTILINE, $WS_VSCROLL)) _GUICtrlRichEdit_SetEventMask($hRich2, $ENM_DRAGDROPDONE) _GUIScrollBars_ShowScrollBar($hRich2, $SB_VERT, True) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Sleep(50) WEnd EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam) #forceref $hWnd, $iMsg, $iWparam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $iLparam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch __WinAPI_GetClassName($hWndFrom) ;replace with handles, Case $_GRE_sRTFClassName ;if not restoring text selection on multiple richedits Switch $iCode Case $EN_DRAGDROPDONE If $hWndFrom <> _WinAPI_GetFocus() Then ;re-show selected text only on drag beween edits _GUICtrlRichEdit_HideSelection($hWndFrom, False) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func __WinAPI_GetClassName($hWnd) Local $aResult = DllCall($iDLLUser32, "int", "GetClassNameW", "hwnd", $hWnd, "wstr", "", "int", 4096) If @error Then Return "" Return $aResult[2] EndFunc ;==>__WinAPI_GetClassName Func Terminate() _GUICtrlRichEdit_Destroy($hRich1) _GUICtrlRichEdit_Destroy($hRich2) Exit EndFunc1 point