click
here for more groovy stuff like this
global
$tips_live = false
func corz_TipsSystem(
$ts_file,
$parent,
$ts_path,
$ts_sect,
$ts_name,
$ts_h=
"",
$ts_w=
"",
$ts_func=
"",
$ts_tx=0,
$ts_ty=0,
$ts_pos=
"")
if
$tips_live then return
if not
$ts_file or not
$parent or not
$ts_path or not
$ts_sect or not
$ts_name then return
global
$tips_array = corz_GrabTips(
$ts_file)
if
$tips_array = 0 then global
$tips_array[3] = [2,
"no tips available",
"sorree"]
global
$tips_ini_path =
$ts_path global
$tips_ini_section =
$ts_sect global
$tips_name =
$ts_name global
$do_func =
$ts_func local
$last_coord_mode = AutoItSetOption(
"GUICoordMode", 1)
local
$last_event_mode = AutoItSetOption(
"GUIOnEventMode", 1)
local
$corz_no_tips = IniReadCheckboxValue(
$tips_ini_path,
$tips_ini_section,
"no_tips",
$GUI_UNCHECKED)
GUISetState(@SW_DISABLE,
$parent)
global
$tips_count = IniRead(
$tips_ini_path,
$tips_ini_section,
"tips_count", 0)
$tips_count += 1
if
$tips_count < 1 or
$tips_count >=
$tips_array[0] then
$tips_count = 1
$parent_size = WinGetPos(
$parent)
if not
$ts_w then
$ts_w =
$parent_size[2] - 8
if not
$ts_h then
$ts_h = 156
$ts_x =
$parent_size[0]
$ts_y =
$parent_size[1] +
$parent_size[3]
$tips_gui_fx =
"Slide Top" $check_x = true
$check_y = true
$do_nudge = true
switch
$ts_pos case
"left" $ts_y =
$parent_size[1]
$ts_x -=
$ts_w + 8
$tips_gui_fx =
"Slide Right" case
"right" $ts_y =
$parent_size[1]
$ts_x +=
$parent_size[2]
$tips_gui_fx =
"Slide Left" case
"center",
"centre" $ts_y = -1
$ts_x = -1
$check_x = false
$check_y = false
$do_nudge = false
$tips_gui_fx =
"Explode" case
"top" $tips_gui_fx =
"Slide Bottom" $ts_y =
$parent_size[1] -
$ts_h - 24
$do_nudge = false
case
"overlap" $ts_y =
$parent_size[1]
endswitch
if
$do_nudge then
$ts_x +=
$ts_tx $ts_y +=
$ts_ty endif
if
$check_x then
if
$ts_x > @DesktopWidth -
$ts_w then
$ts_x = @DesktopWidth -
$ts_w - 4
if
$ts_x < 0 then
$ts_x = 0
endif
if
$check_y then
if
$ts_y > @DesktopHeight -
$ts_h - 24 then
switch
$ts_pos case
"left",
"right" $ts_y = @DesktopHeight -
$ts_h - 24
case
"bottom" continuecase
case else
$ts_y =
$parent_size[1] -
$ts_h - 24
$tips_gui_fx =
"Slide Bottom" endswitch
elseif
$ts_y < 0 then
switch
$ts_pos case
"left",
"right" $ts_y = 0
case
"bottom" continuecase
case else
$ts_y =
$parent_size[1] +
$parent_size[3]
$tips_gui_fx =
"Slide Top" endswitch
endif
endif
global
$gui_tips = GUICreate(
" " &
$tips_name &
"..",
$ts_w,
$ts_h,
$ts_x,
$ts_y +
$ts_ty, _
BitOr(
$WS_CAPTION,
$WS_POPUP,
$WS_SYSMENU,
$WS_SIZEBOX),
$WS_EX_TOOLWINDOW,
$parent)
GUISetOnEvent(
$GUI_EVENT_CLOSE,
"corz_DoneTips",
$gui_tips)
HotKeySet(
"{ESC}",
"corz_EscDoneTips")
HotKeySet(
"{PGUP}",
"corz_PgUpPreviousTip")
HotKeySet(
"{PGDN}",
"corz_PgDnNextTip")
$edit_tricks = GUICtrlCreateEdit(
$tips_array[
$tips_count], 5, 5 ,
$ts_w-10,
$ts_h-30, _
BitOr(
$ES_MULTILINE,
$WS_VSCROLL))
GUICtrlSetResizing(-1,
$GUI_DOCKBORDERS)
$butt_copy_tip = GUICtrlCreateButton(
"copy tip", 5,
$ts_h-20, 50, 18)
GUICtrlSetOnEvent(-1,
"corz_CopyTip")
GUICtrlSetResizing(-1,
$GUI_DOCKLEFT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" copy the current tip to the clipboard ")
$butt_dump_tip = GUICtrlCreateButton(
"dump to a file", 57,
$ts_h-20, 70, 18)
GUICtrlSetOnEvent(-1,
"corz_DumpTips")
GUICtrlSetResizing(-1,
$GUI_DOCKLEFT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" dump all the tips to a plain text file")
$check_no_more_tips = GUICtrlCreateCheckbox(
"no startup tips", 137,
$ts_h-22)
GUICtrlSetResizing(-1,
$GUI_DOCKLEFT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" check this box to turn off the tips at startup ")
GUICtrlSetState(-1,
$corz_no_tips)
$butt_first_tip = GUICtrlCreateButton(
"|<<",
$ts_w-157,
$ts_h-22, 28, 20)
GUICtrlSetOnEvent(-1,
"corz_FirstTip")
GUICtrlSetResizing(-1,
$GUI_DOCKRIGHT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" back to the first tip ")
$butt_previous_tip = GUICtrlCreateButton(
"<<",
$ts_w-127,
$ts_h-22, 38, 20)
GUICtrlSetOnEvent(-1,
"corz_PreviousTip")
GUICtrlSetResizing(-1,
$GUI_DOCKRIGHT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" show the previous tip.. [Page UP] ")
$butt_next_tip = GUICtrlCreateButton(
">>",
$ts_w-87,
$ts_h-22, 38, 20)
GUICtrlSetOnEvent(-1,
"corz_NextTip")
GUICtrlSetResizing(-1,
$GUI_DOCKRIGHT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" show the next tip.. [Page DOWN] ")
$butt_donetips = GUICtrlCreateButton(
"done!",
$ts_w-37,
$ts_h-22, 32, 20)
GUICtrlSetOnEvent(-1,
"corz_DoneTips")
GUICtrlSetResizing(-1,
$GUI_DOCKRIGHT+
$GUI_DOCKBOTTOM+
$GUI_DOCKWIDTH+
$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1,
" close the tips.. [Esc]" )
GUICtrlSetState(-1,
$GUI_DefButton)
$tips_live = true
$current_count =
$tips_count corz_GUIAnimateOpen(
$gui_tips,
$tips_gui_fx)
WinSetOnTop(
$gui_tips,
"", 1)
$funcount = 0
while
$tips_live if
$current_count <>
$tips_count then
$current_count =
$tips_count GUICtrlSetData(
$edit_tricks,
$tips_array[
$tips_count])
endif
if
$do_func <>
"" and
$funcount >= 4 then
Call(
$do_func)
$funcount = 0
endif
$funcount += 1
Sleep(25)
wend
HotKeySet(
"{ESC}")
HotKeySet(
"{PGUP}")
HotKeySet(
"{PGDN}")
$corz_no_tips = GUICtrlRead(
$check_no_more_tips)
IniWriteCheckBoxValue(
$tips_ini_path,
$tips_ini_section,
"no_tips",
$corz_no_tips)
IniWrite(
$tips_ini_path,
$tips_ini_section,
"tips_count",
$tips_count)
$seen_tips_warning = IniRead(
$tips_ini_path,
$tips_ini_section,
"seen_tips_warning", 0)
if
$corz_no_tips = 1 and
$seen_tips_warning = 0 then
WinSetOnTop(
$gui_tips,
"", 0)
MsgBox(0,
"No More Tips For You!",
"To enable startup tips again, hold down the SHIFT key at launch. " & @CRLF & _
"If you want the tips back at any time, hit F1.")
IniWrite(
$tips_ini_path,
$tips_ini_section,
"seen_tips_warning", 1)
endif
AutoItSetOption(
"GUIOnEventMode",
$last_event_mode)
AutoItSetOption(
"GUICoordMode",
$last_coord_mode)
corz_GUIAnimateClose(
$gui_tips,
$tips_gui_fx)
WinSetOnTop(
$gui_tips,
"", 0)
GUIDelete(
$gui_tips)
GUISetState(@SW_ENABLE,
$parent)
GUISetState(@SW_SHOW,
$parent)
WinActivate(
$parent)
endfunc
func corz_CopyTip()
ClipPut(
$tips_array[
$tips_count])
endfunc
func corz_DumpTips()
WinSetOnTop(
$gui_tips,
"", 0)
$save_to = IniRead(
$tips_ini_path,
$tips_ini_section,
"save_tips", @DesktopDir)
$save_file = FileSaveDialog(
"Dump ALL the tips to a text file..",
$save_to,
"text files (*.txt)" , 16 ,
$tips_name &
".txt")
if
$save_file =
"" then
WinSetOnTop(
$gui_tips,
"", 1)
return
endif
IniWrite(
$tips_ini_path,
$tips_ini_section,
"save_tips", GetParent(
$save_file))
$dump_string =
$tips_name &
".." & @CRLF & @CRLF
for
$i = 1 to
$tips_array[0]-1
$dump_string &=
"Tip " &
$i &
".." & @CRLF &
$tips_array[
$i] & @CRLF & @CRLF & @CRLF
next
$dump_string &=
".." & @CRLF &
"end of " &
$tips_name & @CRLF
$save_file = FileOpen(
$save_file, 2)
FileWrite(
$save_file,
$dump_string)
FileClose(
$save_file)
WinSetOnTop(
$gui_tips,
"", 1)
endfunc
func corz_FirstTip()
$tips_count = 1
endfunc
func corz_PgUpPreviousTip()
if WinActive(
$gui_tips) then
corz_PreviousTip()
else
HotKeyset(
"{PGUP}")
Send(
"{PGUP}")
HotKeySet(
"{PGUP}",
"corz_PgUpPreviousTip")
endif
endfunc
func corz_PreviousTip()
$tips_count -= 1
if
$tips_count < 1 then
$tips_count =
$tips_array[0]
endfunc
func corz_PgDnNextTip()
if WinActive(
$gui_tips) then
corz_NextTip()
else
HotKeyset(
"{PGDN}")
Send(
"{PGDN}")
HotKeySet(
"{PGDN}",
"corz_PgDnNextTip")
endif
endfunc
func corz_NextTip()
if not WinActive(
$gui_tips) then return
$tips_count += 1
ConsoleWrite(
"tips_array[0]: " &
$tips_array[0] & @LF)
ConsoleWrite(
"tips_count: " &
$tips_count & @LF)
if
$tips_count >
$tips_array[0] then
$tips_count = 1
endfunc
func corz_EscDoneTips()
if WinActive(
$gui_tips) then
corz_DoneTips()
else
HotKeyset(
"{ESC}")
Send(
"{ESC}")
HotKeySet(
"{ESC}",
"corz_EscDoneTips")
endif
endfunc
func corz_DoneTips()
$tips_live = false
endfunc
func corz_GrabTips(
$file)
$corz_tipsfile = FileOpen(
$file, 0)
if
$corz_tipsfile = -1 then return 0
$tmp_tricks = StringSplit(StringStripCR(FileRead(
$corz_tipsfile, FileGetSize(
$file))), @CRLF)
FileClose(
$corz_tipsfile)
$tmp_str =
"" for
$i = 1 to
$tmp_tricks[0]
if
$tmp_tricks[
$i] <>
"" and StringLeft(
$tmp_tricks[
$i], 1) <>
" then $tmp_tricks[
$i] = StringReplace(
$tmp_tricks[
$i], '\n', @CRLF)
$tmp_str &=
$tmp_tricks[
$i] &
"|" endif
next
$tmp_str = StringTrimRight(
$tmp_str, 1)
return StringSplit(
$tmp_str,
"|")
endfunc