Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/28/2015 in all areas

  1. Two tiny, simple scripts (secondDesktop & desktopSwitch) that elaborate (slightly) on _WinAPI_CreateDesktop() to create a second workspace with some interesting features: Startup: define any number of programmes to be auto-started on the second desktop, hard-coded (by you, in desktopSwitch.au3) or parsed as parameters (from secondDesktop.au3);Full desktop mode: provides acccess to all your desktop shortcuts, start menu (Win7), taskbar, plus a one-button switch in both desktops;Kiosk mode: provides an empty workspace where only your designated startup entries will run; Switch button/GUI is absent; an unadvertised hotkey provides switching to the original desktop (Ctrl-Alt-Del still works, but a task manager started on the second desktop will appear on the original desktop). To enable kiosk mode, set flag $kioskmode=True in secondDesktop.au3;Security: software keyloggers running in your regular environment cannot capture keystrokes on the second desktop, and windows messages cannot be sent between desktops, so your apps won't be hijacked easily through remote control. (NB not extensively tested; use at your own risk!) In full desktop mode, the (red or green) background colour of the Switch GUI shows you whether you are on the exposed or secure desktop.I SecondDesktop.v0.8.7z (first beta release) Important: you'll need to compile desktopSwitch before running secondDesktop. You can test your edited version of desktopSwitch.au3 "dry," as a script on your regular desktop first, by setting its internal flag $testing=True; but don't forget to reset that flag again before compiling.
    3 points
  2. This is a simple func I made to write colored text to a rich edit, and I thought someone else might find it useful. What it does is format the text into RTF syntax so you don't need to mess with selecting and setting the color and such with multiple commands. ; _GUICtrlRichEdit_AppendTextEx($RichEdit, $text, $font="Arial", $color="000000", $size=12, $bold=0, $italic=0, $underline=0, $strike=0) ; This function was created to make it simpler to use RichEdit controls. ; ; Note: to set the line spacing to a size bigger than the text, ; you need to call this function once to write the text, and then call ; it again and write a space with a larger size, and that will give you ; spacing between the lines. ; ;Peramiters ; $RichEdit = handle of RichEdit control ; $text = the string to write. You need to add @CRLF for a newline ; $font = the font family to use, default = "Arial" ; $color = the rrggbb hex color code to use, default = "000000" (black) ; $size = the font size to use in points, will be rounded to the nearest 0.5 points before use, default = 12 ; $bold = flag to make the text bold, default = 0 (not bold) ; $italic = flag to make the text italic, default = 0 (not italic) ; $strike = flag to make the text strikethrough, default = 0 ; $underline = int, what kind of underlining to use. default = 0 ; 1 = Underline ; 2 = Double Underline ; 3 = Thick Underline ; 4 = Underline words only ; 5 = Wave Underline ; 6 = Dotted Underline ; 7 = Dash Underline ; 8 = Dot Dash Underline ; ;Return value ; On success: Returns the value from _GUICtrlRichEdit_AppendText() ; On failure: Sets @error to non-0 ; 1 = Error with color ; Func _GUICtrlRichEdit_AppendTextEx($RichEdit, $text, $font="Arial", $color="000000", $size=12, $bold=0, $italic=0, $strike=0, $underline=0) Local $command = "{\rtf1\ansi" Local $r, $g, $b, $ul[9] = ["8", '\ul', '\uldb', '\ulth', '\ulw', '\ulwave', '\uld', '\uldash', '\uldashd'] If $font <> "" Then $command &= "{\fonttbl\f0\f"&$font&";}" If $color <> "" Then If StringLen($color) <> 6 And StringLen($color) = 8 Then Return SetError(1) $b = dec(StringRight($color,2)) if @error Then seterror(1, 1) $color = StringTrimRight($color,2) $g = dec(StringRight($color,2)) if @error Then seterror(1, 2) $color = StringTrimRight($color,2) $r = dec(StringRight($color,2)) if @error Then seterror(1, 3) If $r+$b+$g > 0 Then $command &= "{\colortbl;\red"&$r&"\green"&$g&"\blue"&$b&";}\cf1" EndIf EndIf If $size Then $command &= "\fs"&round($size*2)&" " If $strike Then $command &= "\strike " If $italic Then $command &= "\i " If $bold Then $command &= "\b " If $underline > 0 and $underline < 9 Then $command &= $ul[$underline]&" " ;~ ConsoleWrite($command&$text&"}"&@CRLF) ; Debugging line Return _GUICtrlRichEdit_AppendText($RichEdit, $command&StringReplace($text,@CRLF,"\line")&"}" ) EndFuncAn example of it's use: #include <GuiRichEdit.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 331, 303, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 8, 240, 313, 21) $ButtonBob = GUICtrlCreateButton("Bob", 8, 264, 75, 25) $ButtonMar = GUICtrlCreateButton("Mary", 88, 264, 75, 25) $ButtonSus = GUICtrlCreateButton("Susan", 168, 264, 75, 25) $ButtonJoe = GUICtrlCreateButton("Joe", 248, 264, 75, 25) $RichEdit = _GUICtrlRichEdit_Create($Form1, "", 8, 8, 313, 225, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_READONLY)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $lastuser = "" demo() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonBob If GUICtrlRead($Input1) <> "" Then _Chat_SendMessage("Bob", "993333", GUICtrlRead($Input1)) Case $ButtonJoe If GUICtrlRead($Input1) <> "" Then _Chat_SendMessage("Joe", "339933", GUICtrlRead($Input1)) Case $ButtonSus If GUICtrlRead($Input1) <> "" Then _Chat_SendMessage("Susan", "333399", GUICtrlRead($Input1)) Case $ButtonMar If GUICtrlRead($Input1) <> "" Then _Chat_SendMessage("Mary", "339999", GUICtrlRead($Input1)) EndSwitch WEnd Func demo() _Chat_SendMessage("Bob", "993333", "Testin 123") _Chat_SendMessage("Bob", "993333", "Example script here") _Chat_SendMessage("Susan", "333399", "Enter something in the input and press a button") _Chat_SendMessage("Susan", "333399", "Try experimenting with it a bit") _Chat_SendMessage("Mary", "339999", "Messages between the same user are less spaced out than between other people") EndFunc ;use a function for wrapping messages with multiple parts of different formattings Func _Chat_SendMessage($user, $color, $text) Local $temp = ControlGetFocus($Form1) _GUICtrlRichEdit_AppendTextEx($RichEdit, $user&":", "Arial", $color, 10, 1) If $lastuser <> $user and $lastuser <> "" Then ; Add line spacing between users by using a taller font size for the space _GUICtrlRichEdit_AppendTextEx($RichEdit, " ", "Arial", "000000", 15) Else ; Same width as 15, but only as tall as 10 :P _GUICtrlRichEdit_AppendTextEx($RichEdit, " ", "Arial", "000000", 10) _GUICtrlRichEdit_AppendTextEx($RichEdit, " ", "Arial", "000000", 5) EndIf _GUICtrlRichEdit_AppendTextEx($RichEdit, $text&@CRLF, "Arial", "000000", 10) $lastuser = $user ControlFocus($Form1, "", $temp) EndFunc ; _GUICtrlRichEdit_AppendTextEx($RichEdit, $text, $font="Arial", $color="000000", $size=12, $bold=0, $italic=0, $underline=0, $strike=0) ; This function was created to make it simpler to use RichEdit controls. ; ; Note: to set the line spacing to a size bigger than the text, ; you need to call this function once to write the text, and then call ; it again and write a space with a larger size, and that will give you ; spacing between the lines. ; ;Peramiters ; $RichEdit = handle of RichEdit control ; $text = the string to write. You need to add @CRLF for a newline ; $font = the font family to use, default = "Arial" ; $color = the rrggbb hex color code to use, default = "000000" (black) ; $size = the font size to use in points, will be rounded to the nearest 0.5 points before use, default = 12 ; $bold = flag to make the text bold, default = 0 (not bold) ; $italic = flag to make the text italic, default = 0 (not italic) ; $strike = flag to make the text strikethrough, default = 0 ; $underline = int, what kind of underlining to use. default = 0 ; 1 = Underline ; 2 = Double Underline ; 3 = Thick Underline ; 4 = Underline words only ; 5 = Wave Underline ; 6 = Dotted Underline ; 7 = Dash Underline ; 8 = Dot Dash Underline ; ;Return value ; On success: Returns the value from _GUICtrlRichEdit_AppendText() ; On failure: Sets @error to non-0 ; 1 = Error with color ; Func _GUICtrlRichEdit_AppendTextEx($RichEdit, $text, $font="Arial", $color="000000", $size=12, $bold=0, $italic=0, $strike=0, $underline=0) Local $command = "{\rtf1\ansi" Local $r, $g, $b, $ul[9] = ["8", '\ul', '\uldb', '\ulth', '\ulw', '\ulwave', '\uld', '\uldash', '\uldashd'] If $font <> "" Then $command &= "{\fonttbl\f0\f"&$font&";}" If $color <> "" Then If StringLen($color) <> 6 And StringLen($color) = 8 Then Return SetError(1) $b = dec(StringRight($color,2)) if @error Then seterror(1, 1) $color = StringTrimRight($color,2) $g = dec(StringRight($color,2)) if @error Then seterror(1, 2) $color = StringTrimRight($color,2) $r = dec(StringRight($color,2)) if @error Then seterror(1, 3) If $r+$b+$g > 0 Then $command &= "{\colortbl;\red"&$r&"\green"&$g&"\blue"&$b&";}\cf1" EndIf EndIf If $size Then $command &= "\fs"&round($size*2)&" " If $strike Then $command &= "\strike " If $italic Then $command &= "\i " If $bold Then $command &= "\b " If $underline > 0 and $underline < 9 Then $command &= $ul[$underline]&" " ;~ ConsoleWrite($command&$text&"}"&@CRLF) ; Debugging line Return _GUICtrlRichEdit_AppendText($RichEdit, $command&StringReplace($text,@CRLF,"\line")&"}" ) EndFuncIf this was useful to you, or if you have any ideas / suggestions to make it better, let me know.
    1 point
  3. jchd

    Conditional compilation?

    If I were to make something like that I'd use #define #undef #if #ifdef #ifndef #else #elif #endif # for "stringification" But soon you'll have to handle real-world constructs: #if (!defined(_UTF_8) && !defined(_UTF_16)) || defined(_UTF_NONE) and #define UNICODE_VERSION_MAJOR 5 #define UNICODE_VERSION_MINOR 1 #define UNICODE_VERSION_MICRO 0 #define UNICODE_VERSION_BUILD 10 #define __UNICODE_VERSION_STRING(a,b,c,d) #a "." #b "." #c "." #d #define _UNICODE_VERSION_STRING(a,b,c,d) __UNICODE_VERSION_STRING(a,b,c,d) #define UNICODE_VERSION_STRING _UNICODE_VERSION_STRING(UNICODE_VERSION_MAJOR,UNICODE_VERSION_MINOR,UNICODE_VERSION_MICRO,UNICODE_VERSION_BUILD)
    1 point
  4. AU3Check has a bug. Use the au3check from the beta subdirectory or the au3check from the SciTE4AutoIt3 download directory. Jos
    1 point
×
×
  • Create New...