Busti Posted September 25, 2006 Share Posted September 25, 2006 hi all, i wanted to make a programm that adds every new thing in the clipput to the tray, i get it only some working expandcollapse popup#Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. Dim $e=0,$menuID[100],$oldGet=ClipGet(),$msg="",$NewMenu[100],$NewMenuArray[100],$i=1 $item = TrayCreateItem( "-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() If $msg = $aboutitem Then Msgbox(64, "about:", "MultiClipBoard v1 - By Busti." & @CRLF & "Simply Click ctrl+c to add smt.") elseIf $msg = $exititem Then ExitLoop elseIf $msg = $cleanup Then _CleanUp() elseIf ClipGet() <> $oldGet Then TrayItemDelete($item) TrayItemDelete($aboutitem) TrayItemDelete($cleanup) TrayItemDelete($exititem) TrayItemDelete($emptyitem1) TrayItemDelete($emptyitem2) TrayItemDelete($emptyitem3) $item = TrayCreateItem( "-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $NewMenuArray[$i] = ClipGet() For $iCreate = 1 To $i $NewMenu[$iCreate] = TrayCreateItem(StringLeft($NewMenuArray[$iCreate],15) & " ...") Next $oldGet = ClipGet() $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $i += 1 EndIf If $i >= 2 Then For $iMsg = 1 To $i If $msg == $NewMenu[$i] Then MsgBox( 0,"",$NewMenuArray[$i] ) Next EndIf Sleep(1) WEnd Exit Func _CleanUp() TrayItemDelete($item) TrayItemDelete($aboutitem) TrayItemDelete($cleanup) TrayItemDelete($exititem) TrayItemDelete($emptyitem1) TrayItemDelete($emptyitem2) TrayItemDelete($emptyitem3) For $iDel = 1 To $i TrayItemDelete($NewMenu[$i]) $NewMenuArray[$i] = "" Next $item = TrayCreateItem( "-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") Global $i=1 TraySetState() EndFunc hope you understand and can help My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
GaryFrost Posted September 25, 2006 Share Posted September 25, 2006 Think you would be better off adapting this to what your wanting to do expandcollapse popup#include <GUIConstants.au3> Global Const $WM_DRAWCLIPBOARD = 0x0308 Global Const $WM_CHANGECBCHAIN = 0x030D Global $origHWND $gui = GUICreate("Clip Hook",400,400,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU)) ; remember last clip viewer in queue and set our GUI as first in queue $origHWND = DLLCall("user32.dll","hwnd","SetClipboardViewer","hwnd",$gui) $origHWND = $origHWND[0] GUIRegisterMsg($WM_DRAWCLIPBOARD,"OnClipBoardChange") GUIRegisterMsg($WM_CHANGECBCHAIN,"OnClipBoardViewerChange") GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; send notification that we no longer will be in clipboard hook queue DLLCall("user32.dll","int","ChangeClipboardChain","hwnd",$gui,"hwnd",$origHWND) Exit Func OnClipBoardChange($hWnd, $Msg, $wParam, $lParam) ; do what you need when clipboard changes ToolTip(ClipGet()) Sleep(3000) ToolTip("") ; send notification about clipboard change to next clipviewer dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_DRAWCLIPBOARD,"int",$wParam,"int",$lParam) EndFunc Func OnClipBoardViewerChange($hWnd, $Msg, $wParam, $lParam) ; if our remembered previous clipviewer is removed then we must remember new next clipviewer ; else send notification about clipviewr change to next clipviewer If $wParam = $origHWND Then $origHWND = $lParam Else dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_CHANGECBCHAIN,"hwnd",$wParam,"hwnd",$lParam) EndIf EndFunc SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Valuater Posted September 25, 2006 Share Posted September 25, 2006 @frosty..8) man... have you got those DllCall's...down pat! 8) someday i will...lol Link to comment Share on other sites More sharing options...
Busti Posted September 25, 2006 Author Share Posted September 25, 2006 the dlls are not the problem.... My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
Valuater Posted September 25, 2006 Share Posted September 25, 2006 the dlls are not the problem....I thought he helped you, if the DLL's aren't the problem ( just an enhanced direction ) then what is the problem8) Link to comment Share on other sites More sharing options...
Busti Posted September 25, 2006 Author Share Posted September 25, 2006 why you dont start it , i cant really explain it.. simply start , add something with ctrl+c oder copie and then another thing (only strings). then click on the tray and you will see My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
Valuater Posted September 25, 2006 Share Posted September 25, 2006 I dont think this will work because the clipboard does not return an array $NewMenuArray[$i] = ClipGet() For $iCreate = 1 To $i $NewMenu[$iCreate] = TrayCreateItem(StringLeft($NewMenuArray[$iCreate],15) & " ...") Next AFAIK 8) Link to comment Share on other sites More sharing options...
Busti Posted September 25, 2006 Author Share Posted September 25, 2006 did you test? My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
Busti Posted September 25, 2006 Author Share Posted September 25, 2006 *push* - why i dont ever get an answer that really helpst My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
GaryFrost Posted September 25, 2006 Share Posted September 25, 2006 *push* - why i dont ever get an answer that really helpst I gave you what you needed, like I said you just needed to adapt it and debug your code, found some things that had to be corrected. expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Global Const $WM_DRAWCLIPBOARD = 0x0308 Global Const $WM_CHANGECBCHAIN = 0x030D Global $origHWND, $i = 1 Dim $e = 0, $menuID[100], $oldGet = ClipGet(), $msg = "", $NewMenu[100], $NewMenuArray[100], $i = 1 $gui = GUICreate("Clip Hook", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) ;used to hook clipboard events only ; remember last clip viewer in queue and set our GUI as first in queue $origHWND = DllCall("user32.dll", "hwnd", "SetClipboardViewer", "hwnd", $gui) $origHWND = $origHWND[0] GUIRegisterMsg($WM_DRAWCLIPBOARD, "OnClipBoardChange") GUIRegisterMsg($WM_CHANGECBCHAIN, "OnClipBoardViewerChange") $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Switch $msg Case $aboutitem MsgBox(64, "about:", "MultiClipBoard v1 - By Busti." & @CRLF & "Simply Click ctrl+c to add smt.") Case $exititem ExitLoop Case $cleanup _CleanUp() EndSwitch WEnd ; send notification that we no longer will be in clipboard hook queue DllCall("user32.dll", "int", "ChangeClipboardChain", "hwnd", $gui, "hwnd", $origHWND) Exit Func OnClipBoardChange($hWnd, $msg, $wParam, $lParam) ; do what you need when clipboard changes TrayItemDelete($exititem) TrayItemDelete($emptyitem3) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($emptyitem2) For $iCreate = $i - 1 To 1 Step - 1 TrayItemDelete($NewMenu[$iCreate]) Next TrayItemDelete($emptyitem1) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $NewMenuArray[$i] = ClipGet() For $iCreate = 1 To $i $NewMenu[$iCreate] = TrayCreateItem(StringLeft($NewMenuArray[$iCreate], 15) & " ...") Next $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $i += 1 ; send notification about clipboard change to next clipviewer DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_DRAWCLIPBOARD, "int", $wParam, "int", $lParam) EndFunc ;==>OnClipBoardChange Func OnClipBoardViewerChange($hWnd, $msg, $wParam, $lParam) ; if our remembered previous clipviewer is removed then we must remember new next clipviewer ; else send notification about clipviewr change to next clipviewer If $wParam = $origHWND Then $origHWND = $lParam Else DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_CHANGECBCHAIN, "hwnd", $wParam, "hwnd", $lParam) EndIf EndFunc ;==>OnClipBoardViewerChange Exit Func _CleanUp() For $iDel = 1 To $i TrayItemDelete($NewMenu[$i]) $NewMenuArray[$i] = "" Next TrayItemDelete($emptyitem3) TrayItemDelete($emptyitem2) TrayItemDelete($emptyitem1) TrayItemDelete($exititem) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $i = 1 TraySetState() EndFunc ;==>_CleanUp SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Busti Posted September 26, 2006 Author Share Posted September 26, 2006 (edited) first of all, thank you , this is working BUT now i got this problem : For $iScan = 1 To $i If $msg = $NewMenu[$iScan] Then MsgBox(0,"",$NewMenuArray[$i]) Next Edited September 26, 2006 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
GaryFrost Posted September 26, 2006 Share Posted September 26, 2006 Just need a case else and make sure you use the correct variable, also in the check make sure the array item isn't empty expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Global Const $WM_DRAWCLIPBOARD = 0x0308 Global Const $WM_CHANGECBCHAIN = 0x030D Global $origHWND, $i = 1 Dim $e = 0, $menuID[100], $oldGet = ClipGet(), $msg = "", $NewMenu[100], $NewMenuArray[100], $i = 1 $gui = GUICreate("Clip Hook", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) ;used to hook clipboard events only ; remember last clip viewer in queue and set our GUI as first in queue $origHWND = DllCall("user32.dll", "hwnd", "SetClipboardViewer", "hwnd", $gui) $origHWND = $origHWND[0] GUIRegisterMsg($WM_DRAWCLIPBOARD, "OnClipBoardChange") GUIRegisterMsg($WM_CHANGECBCHAIN, "OnClipBoardViewerChange") $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Switch $msg Case $aboutitem MsgBox(64, "about:", "MultiClipBoard v1 - By Busti." & @CRLF & "Simply Click ctrl+c to add smt.") Case $exititem ExitLoop Case $cleanup _CleanUp() Case Else For $iScan = 1 To $i If $msg = $NewMenu[$iScan] And $NewMenu[$iScan] <> "" Then MsgBox(0, "", $NewMenuArray[$iScan]) Next EndSwitch WEnd ; send notification that we no longer will be in clipboard hook queue DllCall("user32.dll", "int", "ChangeClipboardChain", "hwnd", $gui, "hwnd", $origHWND) Exit Func OnClipBoardChange($hWnd, $msg, $wParam, $lParam) ; do what you need when clipboard changes TrayItemDelete($exititem) TrayItemDelete($emptyitem3) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($emptyitem2) For $iCreate = $i - 1 To 1 Step - 1 TrayItemDelete($NewMenu[$iCreate]) Next TrayItemDelete($emptyitem1) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $NewMenuArray[$i] = ClipGet() For $iCreate = 1 To $i $NewMenu[$iCreate] = TrayCreateItem(StringLeft($NewMenuArray[$iCreate], 15) & " ...") Next $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $i += 1 ; send notification about clipboard change to next clipviewer DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_DRAWCLIPBOARD, "int", $wParam, "int", $lParam) EndFunc ;==>OnClipBoardChange Func OnClipBoardViewerChange($hWnd, $msg, $wParam, $lParam) ; if our remembered previous clipviewer is removed then we must remember new next clipviewer ; else send notification about clipviewr change to next clipviewer If $wParam = $origHWND Then $origHWND = $lParam Else DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_CHANGECBCHAIN, "hwnd", $wParam, "hwnd", $lParam) EndIf EndFunc ;==>OnClipBoardViewerChange Exit Func _CleanUp() TrayItemDelete($exititem) TrayItemDelete($emptyitem3) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($emptyitem2) For $iCreate = $i - 1 To 1 Step - 1 TrayItemDelete($NewMenu[$iCreate]) Next TrayItemDelete($emptyitem1) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $i = 1 TraySetState() EndFunc ;==>_CleanUp SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Busti Posted September 26, 2006 Author Share Posted September 26, 2006 nice , really big thanx, <3 you My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
GaryFrost Posted September 26, 2006 Share Posted September 26, 2006 nice , really big thanx, <3 you yw, suggestion, change your $i to something like $Clips and when there is not clips in the tray it should be zero use a Select instead of Switch won't need an Case Else Good pratice is to declare all your variables For Example expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("MustDeclareVars", 1) Global Const $WM_DRAWCLIPBOARD = 0x0308 Global Const $WM_CHANGECBCHAIN = 0x030D Global $origHWND, $Clips = 0, $NewMenu[100], $NewMenuArray[100] Global $item, $emptyitem1, $emptyitem2, $aboutitem, $cleanup, $emptyitem3, $exititem _Main() Func _Main() Local $msg = "", $gui, $iScan $gui = GUICreate("Clip Hook", 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) ;used to hook clipboard events only ; remember last clip viewer in queue and set our GUI as first in queue $origHWND = DllCall("user32.dll", "hwnd", "SetClipboardViewer", "hwnd", $gui) $origHWND = $origHWND[0] GUIRegisterMsg($WM_DRAWCLIPBOARD, "OnClipBoardChange") GUIRegisterMsg($WM_CHANGECBCHAIN, "OnClipBoardViewerChange") $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = $aboutitem MsgBox(64, "about:", "MultiClipBoard v1 - By Busti." & @CRLF & "Simply Click ctrl+c to add smt.") Case $msg = $exititem ExitLoop Case $msg = $cleanup _CleanUp() Case $Clips > 0 For $iScan = 1 To $Clips If $msg = $NewMenu[$iScan] Then MsgBox(0, "", $NewMenuArray[$iScan]) Next EndSelect WEnd ; send notification that we no longer will be in clipboard hook queue DllCall("user32.dll", "int", "ChangeClipboardChain", "hwnd", $gui, "hwnd", $origHWND) EndFunc ;==>_Main Func OnClipBoardChange($hWnd, $msg, $wParam, $lParam) Local $iDel, $iCreate ; do what you need when clipboard changes TrayItemDelete($exititem) TrayItemDelete($emptyitem3) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($emptyitem2) For $iDel = $Clips To 1 Step - 1 TrayItemDelete($NewMenu[$iDel]) Next TrayItemDelete($emptyitem1) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $Clips += 1 $NewMenuArray[$Clips] = ClipGet() For $iCreate = 1 To $Clips $NewMenu[$iCreate] = TrayCreateItem(StringLeft($NewMenuArray[$iCreate], 15) & " ...") Next $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") ; send notification about clipboard change to next clipviewer DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_DRAWCLIPBOARD, "int", $wParam, "int", $lParam) EndFunc ;==>OnClipBoardChange Func OnClipBoardViewerChange($hWnd, $msg, $wParam, $lParam) ; if our remembered previous clipviewer is removed then we must remember new next clipviewer ; else send notification about clipviewr change to next clipviewer If $wParam = $origHWND Then $origHWND = $lParam Else DllCall("user32.dll", "int", "SendMessage", "hWnd", $origHWND, "int", $WM_CHANGECBCHAIN, "hwnd", $wParam, "hwnd", $lParam) EndIf EndFunc ;==>OnClipBoardViewerChange Func _CleanUp() Local $iDel TrayItemDelete($exititem) TrayItemDelete($emptyitem3) TrayItemDelete($cleanup) TrayItemDelete($aboutitem) TrayItemDelete($emptyitem2) For $iDel = $Clips - 1 To 1 Step - 1 TrayItemDelete($NewMenu[$iDel]) Next TrayItemDelete($emptyitem1) TrayItemDelete($item) $item = TrayCreateItem("-MultiClipBoard v1-") $emptyitem1 = TrayCreateItem("") $emptyitem2 = TrayCreateItem("") $aboutitem = TrayCreateItem("About") $cleanup = TrayCreateItem("CleanUP") $emptyitem3 = TrayCreateItem("") $exititem = TrayCreateItem("Exit") $Clips = 0 TraySetState() EndFunc ;==>_CleanUp SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Busti Posted September 26, 2006 Author Share Posted September 26, 2006 (edited) thanx, i think every one has his own coding style ^^ PS: i didnt use the "clippboard" thing, becouse i wanted to to it in autoit w/o DLL Calls^^ Edited September 26, 2006 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity 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