Jump to content

GUI Clipboard Library


erifash
 Share

Recommended Posts

Here is a cool script I just threw together. It copies the clipboard to a GUI combobox and you select what you want to re-copy. Useful if you're copying multiple functions between programs or from the help file. It's like a shopping cart!

Here's the code:

(Thanks to Valik for the Semaphore function!)

(Thanks to gosu for the idea here!)

Singleton("GUI Clipboard Library")

#include <GUIConstants.au3>

HotkeySet("{ESC}", "myexit")
HotkeySet("{F1}", "move")

$last = -1

GUICreate("GUI Clipboard Library", 400, 21, 25, 1, $WS_EX_TOPMOST + $WS_BORDER + $WS_POPUP, $WS_EX_TOOLWINDOW)
$combo = GUICtrlCreateCombo("GUI Clipboard Library", 0, 0, 400, 50)

GUISetState()

WinSetOnTop("GUI Clipboard Library", "GUI Clipboard Library", 1)

While 1
  $clip = ClipGet()
  If $last <> $clip Then GUICtrlSetData($combo, $clip)
  $msg = GUIGetMsg()
  Select
    Case $msg = $combo
      ClipPut(GUIRead($combo))
      $last = ClipGet()
      $clip = ClipGet()
  EndSelect
  Sleep(10)
  $last = $clip
Wend

Func Singleton($semaphore)
    Local $ERROR_ALREADY_EXISTS = 183
    DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $semaphore)
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    If $lastError[0] = $ERROR_ALREADY_EXISTS Then Exit -1
EndFunc;==>Semaphore

Func move()
  $pos = MouseGetPos()
  WinMove("GUI Clipboard Library", "", $pos[0], $pos[1])
EndFunc

Func myexit()
  Exit
EndFunc

Oh, yeah! I forgot: the hotkeys are:

{ESC} to exit

hold down {F1} to move the window to where the mouse is plus you can move the mouse at the same time!

^^^(or you can just press it, I like the effect it makes when you hold it :D )

Any questions/comments would be greatly appreciated! :idiot:

Edit: Code updated, put it as "always on top" because it would get lost behind the windows.

Edited by erifash
Link to comment
Share on other sites

Here is a cool script I just threw together. It copies the clipboard to a GUI combobox and you select what you want to re-copy. Useful if you're copying multiple functions between programs or from the help file. It's like a shopping cart!

Here's the code:

(Thanks to Valik for the Semaphore function!)

(Thanks to gosu for the idea here!)

Singleton("GUI Clipboard Library")

#include <GUIConstants.au3>

HotkeySet("{ESC}", "myexit")
HotkeySet("{F1}", "move")

$last = -1

GUICreate("GUI Clipboard Library", 400, 21, 25, 1, $WS_EX_TOPMOST + $WS_POPUP, $WS_EX_TOOLWINDOW)
$combo = GUICtrlCreateCombo("GUI Clipboard Library", 0, 0, 400, 50)

GUISetState()

While 1
  $clip = ClipGet()
  If $last <> $clip Then GUICtrlSetData($combo, $clip)
  $msg = GUIGetMsg()
  Select
    Case $msg = $combo
      ClipPut(GUIRead($combo))
      $last = ClipGet()
      $clip = ClipGet()
  EndSelect
  Sleep(10)
  $last = $clip
Wend

Func Singleton($semaphore)
    Local $ERROR_ALREADY_EXISTS = 183
    DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $semaphore)
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    If $lastError[0] = $ERROR_ALREADY_EXISTS Then Exit -1
EndFunc;==>Semaphore

Func move()
  $pos = MouseGetPos()
  WinMove("GUI Clipboard Library", "", $pos[0], $pos[1])
EndFunc

Func myexit()
  Exit
EndFunc

Oh, yeah! I forgot: the hotkeys are:

{ESC} to exit

hold down {F1} to move the window to where the mouse is plus you can move the mouse at the same time!

^^^(or you can just press it, I like the effect it makes when you hold it  :lol: )

Any questions/comments would be greatly appreciated!  :idiot:

<{POST_SNAPBACK}>

Cool Script!

And np, this is what open source is about: everyone can modify/"steal" everything :D

(man, I like open source. Because of open source, there are so many programs, because everyone can edit what he needs and make the program better!)

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

Cool Script!

And np, this is what open source is about: everyone can modify/"steal" everything :idiot:

(man, I like open source. Because of open source, there are so many programs, because everyone can edit what he needs and make the program better!)

<{POST_SNAPBACK}>

Yes, exactly. You can modify anything you need to make it better or more suit your OS.
Link to comment
Share on other sites

  • 2 weeks later...

That's a great little script. It will be very useful in my everyday work. Since I'm still a newbie when it comes to programming and AuoIT I have a question about the two marked lines below. Do I really need them? It seems to work correctly without. Sorry if this is a very basic question or the wrong forum for that. I'm just trying to understand the script. Maybe I should look at it tomorrow again - it's too late anyway :idiot:

Thanks for any reply and for sharing this script with us

While 1
  $clip = ClipGet()
  If $last <> $clip Then GUICtrlSetData($combo, $clip)
  $msg = GUIGetMsg()
  Select
    Case $msg = $combo
      ClipPut(GUIRead($combo))
      $last = ClipGet()   <===
      $clip = ClipGet()   <===
  EndSelect
  Sleep(10)
  $last = $clip
Wend
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...