AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Clipboard Hex Viewer

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Larry



Joined: 03 Mar 2005
Posts: 23

PostPosted: Sat Mar 15, 2008 6:14 pm    Post subject: Clipboard Hex Viewer Reply with quote

Clipboard Hex Viewer v1.0
Use Shift-Control-Win-H to view the Clipboard Contents

Often in debugging scripts, I find the contents of the
clipboard contained an 8-Bit or Control Character that
I hadn't considered. This script will allow you to see
those characters that are causing your script to behave
differently than unexpected.

Please note that the Displayed Contents of the Clipboard contains
Vertical Bar Characters added to the front and to the end of the
display string for easy identification of white space.

To View Captured Clipboard Data, you will need to remove or
comment out the Line that assigns "test data" to the clipboard.


Code:

; Clipboard Hex Viewer v1.0
; Use Shift-Control-Win-H to view the Clipboard Contents

; Often in debugging scripts, I find the contents of the
; clipboard contained an 8-Bit or control character that
; I hadn't considered. This script will allow you to see
; those characters that are causing your script to behave
; differently than unexpected.

+^#h:: ; Display Hex Characters and Total Chars on Clipboard

; Comment out the test line below to view captured Clipboard Contents

clipboard := " 0123456789" . "`n`r" . chr(128) . "abcdefg~ "

String =

;Set format of integers to their Hex value
SetFormat, INTEGER, H

;Parse the String
Loop, Parse, clipboard
{
   if (A_Loopfield < " " or A_Loopfield > "~")
   {
   ;Get the ASCII value of the Character (will be converted to the Hex value by the SetFormat Line above)
    CharHex := Asc(A_LoopField)
    StringTrimLeft, CharHex, CharHex, 2

    if % strlen(CharHex) = 1 ; if Hex Value < 10, add a leading "0" for easy identification
      CharHex = 0%CharHex%

   ; Build the Display String
   string .= " ". CharHex . " " ; If an 8-Bit or Control Character, Add spaces for easy identification
   }
   else
   string .= A_Loopfield
}

; Remove Double Spaces between consecutive Hex Values
StringReplace, string, string, %A_Space%%A_Space%, %A_Space%, A

SetFormat, integer, d
slen := StrLen(clipboard) ; Get Number of Characters on Clipboard

; Vertical Bar Characters added to front and end of
; display string for easy identification of white space

MsgBox 8192, Total Clipboard Characters: %slen%, |%string%|
return
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group