Kyan Posted March 22, 2012 Share Posted March 22, 2012 (edited) Hi everyone does someone know, how can I execute a clipboard listening inside a while loop/Switch GUIGetMsg()?I want to paste a url when the website domain matches with the one I want and paste this url in a input >this part I know how to do it, the problem is, how can I do it inside the main while loop (I want to be able to receive GUI commands and read the clipboard data...)let me know if that is possible, and if it is, please give a tip thanks Edited April 3, 2012 by DiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 22, 2012 Moderators Share Posted March 22, 2012 DiOgO,Use ClipGet in the loop? Or perhaps use it in an Adlib function to reduce the overhead? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Kyan Posted March 22, 2012 Author Share Posted March 22, 2012 DiOgO,Use ClipGet in the loop? Or perhaps use it in an Adlib function to reduce the overhead? M23but the script will be listening the GUIGetMsg outputs, wouldn't be? inside the while loop/switch GUIGetMsg()? can it just be placed between switch tags? Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 22, 2012 Author Share Posted March 22, 2012 in this way, nothing happens :s $Form1 = GUICreate("test", 370, 200,-1,-1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[1] Case $Form1 Switch $nMsg[0] If (ClipGet() <> "") And (@error <> 2) Then If StringInStr(ClipGet(),"www.autoitscript.com") <> 0 Then MsgBox(0,"","URL") Sleep(5000) EndIf EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch EndSwitch WEnd Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Juvigy Posted March 23, 2012 Share Posted March 23, 2012 Use this : GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") There is example in the examples section for _ClipBoard_SetViewer Link to comment Share on other sites More sharing options...
Kyan Posted March 24, 2012 Author Share Posted March 24, 2012 Use this :GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")There is example in the examples section for _ClipBoard_SetViewercan you give a example of how can I use that commands? Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
qsek Posted March 24, 2012 Share Posted March 24, 2012 Use this :GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")There is example in the examples section for _ClipBoard_SetViewer Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
Juvigy Posted March 26, 2012 Share Posted March 26, 2012 Copy from the examples: expandcollapse popup#include <GuiConstantsEx.au3> #include <ClipBoard.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> Opt('MustDeclareVars', 1) Global $iMemo, $hNext = 0 _Main() Func _Main() Local $hGUI ; Create GUI $hGUI = GUICreate("Clipboard", 600, 400) $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Initialize clipboard viewer $hNext = _ClipBoard_SetViewer ($hGUI) GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") MemoWrite("GUI handle ....: " & $hGUI) MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer()) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Shut down clipboard viewer _ClipBoard_ChangeChain ($hGUI, $hNext) EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage = "") GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ; Handle $WM_CHANGECBCHAIN messages Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam) ; Show that message was received MemoWrite("***** $WM_CHANGECBCHAIN *****") ; If the next window is closing, repair the chain If $iwParam = $hNext Then $hNext = $ilParam ; Otherwise pass the message to the next viewer ElseIf $hNext <> 0 Then _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd") EndIf EndFunc ;==>WM_CHANGECBCHAIN ; Handle $WM_DRAWCLIPBOARD messages Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam) ; Display any text on clipboard MemoWrite(_ClipBoard_GetData ()) ; Pass the message to the next viewer If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam) EndFunc ;==>WM_DRAWCLIPBOARD Link to comment Share on other sites More sharing options...
Yashied Posted March 26, 2012 Share Posted March 26, 2012 Alternatively, if you have Windows Vista+, you can use _WinAPI_AddClipboardFormatListener() from My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Kyan Posted March 29, 2012 Author Share Posted March 29, 2012 (edited) sorry for that, I didn't read the final part Copy from the examples: expandcollapse popup#include <GuiConstantsEx.au3> #include <ClipBoard.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> Opt('MustDeclareVars', 1) Global $iMemo, $hNext = 0 _Main() Func _Main() Local $hGUI ; Create GUI $hGUI = GUICreate("Clipboard", 600, 400) $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Initialize clipboard viewer $hNext = _ClipBoard_SetViewer ($hGUI) GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") MemoWrite("GUI handle ....: " & $hGUI) MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer()) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Shut down clipboard viewer _ClipBoard_ChangeChain ($hGUI, $hNext) EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage = "") GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ; Handle $WM_CHANGECBCHAIN messages Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam) ; Show that message was received MemoWrite("***** $WM_CHANGECBCHAIN *****") ; If the next window is closing, repair the chain If $iwParam = $hNext Then $hNext = $ilParam ; Otherwise pass the message to the next viewer ElseIf $hNext <> 0 Then _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd") EndIf EndFunc ;==>WM_CHANGECBCHAIN ; Handle $WM_DRAWCLIPBOARD messages Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam) ; Display any text on clipboard MemoWrite(_ClipBoard_GetData ()) ; Pass the message to the next viewer If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam) EndFunc ;==>WM_DRAWCLIPBOARD thank you Alternatively, if you have Windows Vista+, you can use _WinAPI_AddClipboardFormatListener() from thanks, but I prefer to have compatibility with windows XP EDIT: how can I only write to my input only when the clip data is what I want? using this way it pastes all the data (like this "if" doesn't exists) If (StringInStr(_ClipBoard_GetViewer(),"www.autoitscript.com",0,1) <> 0) Then MemoWrite(_ClipBoard_GetViewer()) EndIf Edited March 29, 2012 by DiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 31, 2012 Author Share Posted March 31, 2012 Bump Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2012 Moderators Share Posted March 31, 2012 DiOgO,I told you what to do in the second post of this thread. - 1. Use ClipGet in the loop:#include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) ; Just to copy to check you get the correct response GUICtrlCreateEdit("www.autoitscript.com" & @CRLF & "www.fred.com" & @CRLF & "www.tom.com" & @CRLF & "www.dick.com" & @CRLF & "www.harry.com", 10, 50, 200, 200, $ES_READONLY) GUISetState() $sClipContent = "" ClipPut("") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $sCurrContent = ClipGet() If $sCurrContent <> $sClipContent Then If $sCurrContent = "www.autoitscript.com" Then GUICtrlSetData($cInput, "That is the one!!!") ;ClipPut("") Else GUICtrlSetData($cInput, "Not what we wanted") EndIf $sClipContent = $sCurrContent EndIf WEnd- 2. Use it in an Adlib function to reduce the overhead:expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlCreateEdit("www.autoitscript.com" & @CRLF & "www.fred.com" & @CRLF & "www.tom.com" & @CRLF & "www.dick.com" & @CRLF & "www.harry.com", 10, 50, 200, 200, $ES_READONLY) GUISetState() AdlibRegister("ClipCheck", 1000) $sClipContent = "" ClipPut("") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func ClipCheck() $sCurrContent = ClipGet() If $sCurrContent <> $sClipContent Then If $sCurrContent = "www.autoitscript.com" Then GUICtrlSetData($cInput, "That is the one!!!") ;ClipPut("") Else GUICtrlSetData($cInput, "Not what we wanted") EndIf $sClipContent = $sCurrContent EndIf EndFuncIf you do want to use the Windows messages than you are forced to poll ClipGet somehow. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Kyan Posted March 31, 2012 Author Share Posted March 31, 2012 DiOgO, I told you what to do in the second post of this thread. - 1. Use ClipGet in the loop: #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) ; Just to copy to check you get the correct response GUICtrlCreateEdit("www.autoitscript.com" & @CRLF & "www.fred.com" & @CRLF & "www.tom.com" & @CRLF & "www.dick.com" & @CRLF & "www.harry.com", 10, 50, 200, 200, $ES_READONLY) GUISetState() $sClipContent = "" ClipPut("") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $sCurrContent = ClipGet() If $sCurrContent <> $sClipContent Then If $sCurrContent = "www.autoitscript.com" Then GUICtrlSetData($cInput, "That is the one!!!") ;ClipPut("") Else GUICtrlSetData($cInput, "Not what we wanted") EndIf $sClipContent = $sCurrContent EndIf WEnd - 2. Use it in an Adlib function to reduce the overhead: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlCreateEdit("www.autoitscript.com" & @CRLF & "www.fred.com" & @CRLF & "www.tom.com" & @CRLF & "www.dick.com" & @CRLF & "www.harry.com", 10, 50, 200, 200, $ES_READONLY) GUISetState() AdlibRegister("ClipCheck", 1000) $sClipContent = "" ClipPut("") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func ClipCheck() $sCurrContent = ClipGet() If $sCurrContent <> $sClipContent Then If $sCurrContent = "www.autoitscript.com" Then GUICtrlSetData($cInput, "That is the one!!!") ;ClipPut("") Else GUICtrlSetData($cInput, "Not what we wanted") EndIf $sClipContent = $sCurrContent EndIf EndFunc If you do want to use the Windows messages than you are forced to poll ClipGet somehow. M23 ok, I'll follow your advice and see if it works, thanks Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Kyan Posted March 31, 2012 Author Share Posted March 31, 2012 works nicely, thanks Melba23 Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now