fisofo Posted November 8, 2006 Posted November 8, 2006 Just thought it would be interesting to hear what everyone's favorite, or most useful, or most used script/scrap is!Personally, I have a Hotkeys app that's always running that flips windows from one monitor to the next, closes apps/tabs with a mouse button, grabs autoit code off the forums, and prioritizes tickets for work:expandcollapse popup#NoTrayIcon Opt("WinTitleMatchMode", 4) Global $Paused HotKeySet("#`", "CodeGrabber") ;bound to logitech keyboard button HotKeySet("^\", "Clozer") ;bound to mouse key using ultramon HotKeySet("#p", "Prioritizer") ;bound to logitech keyboard button HotKeySet("{PAUSE}", "TogglePause") HotKeySet("#{ESC}", "Terminate") While 1 Sleep(100) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() MsgBox(0,"Terminated","Script Closed",1) Exit 0 EndFunc Func Prioritizer() ;(can't list this one, sorry ;) ) EndFunc Func Clozer() Select Case WinActive("classname=SciTEWindow") $oTitle = WinGetTitle("active") Send("^w") if WinGetTitle("active") = $oTitle Then Send("!{F4}") EndIf Case WinActive("Microsoft Excel -") Send("^w") Case WinActive("C:\WINDOWS\system32\cmd.exe") Send("^c") Send("exit") Send("{ENTER}") Case WinActive("view-source:") ; case for firefox source viewer Send("!{F4}") Case WinActive("active") $oTitle = WinGetTitle("active") If StringInStr($oTitle, "Firefox") Then Send("^w") Else Send("!{F4}") EndIf Case Else Send("!{F4}") EndSelect EndFunc Func CodeGrabber() $aSciteLocation = "C:\Program Files\AutoIt3\SciTE\scite.exe" $WebsiteCreated = False $qContinue = False Dim $aDivArray[10] $oTitle = WinGetTitle("active") If WinActive("classname=IEFrame") Then $oIE = _IEAttach("AutoIt") if $oIE = 0 Then MsgBox(0,"Error","Sorry, this window is not an AutoIt website") Else $qContinue = True EndIf ElseIf StringInStr($oTitle, "Firefox") Then Send("g") Send("^c") $aWebAddress = ClipGet() if StringInStr($aWebAddress, "autoit") Then $oIE = _IECreate($aWebAddress, 0, 0) $WebsiteCreated = True $qContinue = True Else MsgBox(0,"Error","Sorry, this window is not an AutoIt website") EndIf EndIf if $qContinue Then $oDivs = _IETagNameGetCollection($oIE, "div") $oCount = 1 For $oDiv In $oDivs Select Case $oDiv.classname = "0" ; do nothing Case $oDiv.classname = "autoit" $aDivArray[$oCount] = $oDiv.innertext $oCount = $oCount + 1 Case Else ; do nothing EndSelect Next If $WebsiteCreated Then _IEQuit($oIE) EndIf For $x = 1 to $oCount - 1 if WinExists("classname=SciTEWindow") Then WinActivate("classname=SciTEWindow") Else run($aSciteLocation) WinActivate("classname=SciTEWindow") EndIf ClipPut($aDivArray[$x]) WinWaitActive("classname=SciTEWindow") Send("^n") Send("^v") Next EndIf EndFuncperhaps not my favorite, definitely most used. I really dig the MathMagic Screensaver that coepsx made awhile back though.What's yours?
Moderators SmOke_N Posted November 8, 2006 Moderators Posted November 8, 2006 I would think this is more of a chat topic, as it's been asked before (by AutoIt King I believe). For the record (Since it will be moved if it doesn't belong here anyway), I seem to be using more and more of Snippet Holder by Gary (gafrost)... So I'd have to say that one. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
jvanegmond Posted November 8, 2006 Posted November 8, 2006 My simple calculator: You put your mouse in the top right corner, and a window slides down. You type your calculation (e.g Sin(90)^5) and press the button. Another window slides down with the answer, and after a few seconds both windows slide up again. expandcollapse popup#include <GUIConstants.au3> #NoTrayIcon Opt("GUICloseOnEsc", 0) Dim $x = @DesktopWidth-251, $y = 0 Dim $MainGuitOut = 0 Dim $AnswerGuiOut = 0 Dim $i = 0 $Parent = GUICreate("") $GUI = GUICreate("Simple Logic", 251, 23,$x,$y,$WS_POPUP,-1,$Parent) $Input = GUICtrlCreateInput("", 1, 0, 180, 22) $Button = GUICtrlCreateButton("Calculate", 181, 0, 70, 22, 0) WinSetOnTop($GUI,"", 1) $Answer = GUICreate("Answer",251,23,$x,$y+23,$WS_POPUP,-1,$GUI) $Label = GUICtrlCreateLabel("", 0,0,251,23) WinSetOnTop($Answer,"", 1) ConsoleWrite("Checking if mouse is in position.." & @CRLF) While 1 If $MainGuitOut = 0 Then $Pos = MouseGetPos() If Not @error Then For $xpos = $x to $x+371 If $xpos = $Pos[0] AND $y = $Pos[1] Then ConsoleWrite("Mouse in position, counting: " & $i & @CRLF) $i += 1 If $i = 6 Then $i = 0 ConsoleWrite("Sliding down.." & @CRLF) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $GUI, "int", 1000, "long", 0x00040004) GUISetState(@SW_SHOW,$GUI) MainLoop() ConsoleWrite("Checking if mouse is in position.." & @CRLF) EndIf ExitLoop EndIf Next EndIf Else $i = 0 EndIf Sleep(100) WEnd Func MainLoop() WinActivate($GUI) ConsoleWrite("Main loop starting" & @CRLF) While 1 $msg = GUIGetMsg() If $msg AND $msg <> -11 Then ConsoleWrite("GUIGetMsg() => " & $msg & @CRLF) If $msg = $Button Then ButtonPressed() ConsoleWrite("Main loop continues" & @CRLF) EndIf EndIf If ((Not WinActive($GUI)) AND (Not WinActive($Answer))) AND Not $AnswerGuiOut Then ConsoleWrite("Sliding main up.." & @CRLF) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $GUI, "int", 1000, "long", 0x00050008) GUICtrlSetData($Input,"") Return EndIf WEnd EndFunc Func ButtonPressed() ConsoleWrite("Button pressed called." & @CRLF) $Logic = GUICtrlRead($Input) GUICtrlSetData($Label," = " & @TAB & Execute($Logic)) ConsoleWrite("Sliding answer bar down.." & @CRLF) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Answer, "int", 1000, "long", 0x00040004) GUISetState() $AnswerGuiOut = 1 AdlibEnable("SlideUp", 3000) EndFunc Func SlideUp() AdlibDisable() ConsoleWrite("Sliding answer bar back up.." & @CRLF) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Answer, "int", 1000, "long", 0x00050008) $AnswerGuiOut = 0 EndFunc github.com/jvanegmond
MHz Posted November 8, 2006 Posted November 8, 2006 I would think this is more of a chat topic, as it's been asked before (by AutoIt King I believe).For the record (Since it will be moved if it doesn't belong here anyway), I seem to be using more and more of Snippet Holder by Gary (gafrost)... So I'd have to say that one.Dejavue, it was mentioned here also along with the forum code grabber.@fisofoDouble posting scraps seems totally useless. What is the point of this exercise?Is your code above a later version to the last posted version?
jvanegmond Posted November 8, 2006 Posted November 8, 2006 Dejavue, it was mentioned here also along with the forum code grabber.@fisofoDouble posting scraps seems totally useless. What is the point of this exercise?Is your code above a later version to the last posted version?Don't be so harsh on the guy, his avatar is cool. github.com/jvanegmond
fisofo Posted November 8, 2006 Author Posted November 8, 2006 Don't be so harsh on the guy, his avatar is cool. Thanks Vid Here. I didn't write it, but i think it's hilarious. And I dig your script, thanks!@MHzI really wasn't trying to double-post, I just figured since this is the Script/Scrap forum that it would be good to post a script. And it is a bit updated, but not much.@SmOke_NI suppose this should have been in chat... sorry 'bout that Feel free to move it mods, if necessary. How can i be sure the smart people hang out in chat though? J/K.Anyway... thanks for the responses... i like topics like this because i usually find some really useful stuff i didn't know about/hadn't thought of. The two posts so far have been useful already
JSThePatriot Posted November 8, 2006 Posted November 8, 2006 I have found that my _ComputerGetInfo() functions (found in my signature) have come in quite handy for me in many applications and duties. My most used set of code is my template for OnEventMode. expandcollapse popup;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Program Name: Template - OnEventMode ;Description: Template for OnEventMode GUI scripts ;Filename: Template - OnEventMode.au3 ;Used With: ;Created by: Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com) ;Created on: 06/20/2006 ;Modified on: ;Modified by: ;Version: 0.0.2 ;Copyright: Copyright (C) 2006 Vortex Revolutions. All Rights Reserved. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Declare Variables ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Window Variables Enum $ID_winHEIGHT, $ID_winWIDTH, $ID_winMAIN, $ID_winTITLE, $ID_winMAX Global $g_arrWin[$ID_winMAX] ;Control Variables Enum $ID_btnOPTIONS, $ID_btnHELP, $ID_btnEXIT, $ID_conMAX Global $g_arrCon[$ID_conMAX] ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Preprocessor ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ;Set GUI to ONEvent Mode. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** File Installations ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Registry Information ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Command Line Options ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #cs UNCOMMENT FOR COMMANDLINE! If $CmdLine[0] > 0 Then If StringRight($CmdLine[1], 4) = ".ext" Then _SomeFunc($CmdLine[1]) Else _ErrorMsg("Incorret file extension. Please try again.") _TerminateApp() EndIf EndIf #ce ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Define Variables ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $g_arrWin[$ID_winHEIGHT] = 300 $g_arrWin[$ID_winWIDTH] = 300 $g_arrWin[$ID_winTITLE] = "Template - OnEventMode" ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Creation ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Main GUI Creation $g_arrWin[$ID_winMAIN] = GUICreate($g_arrWin[$ID_winTITLE], $g_arrWin[$ID_winWIDTH], $g_arrWin[$ID_winHEIGHT]) ;Main Options $g_arrCon[$ID_btnOPTIONS] = GUICtrlCreateButton("Options", 5, ($g_arrWin[$ID_winHEIGHT] - 25), 94, 20) ;Main Help $g_arrCon[$ID_btnHELP] = GUICtrlCreateButton("Help", 103, ($g_arrWin[$ID_winHEIGHT] - 25), 94, 20) ;Main Exit $g_arrCon[$ID_btnEXIT] = GUICtrlCreateButton("Exit", 201, ($g_arrWin[$ID_winHEIGHT] - 25), 94, 20) ;Disable Options and Help until added GUICtrlSetState($g_arrCon[$ID_btnOPTIONS], $GUI_DISABLE) GUICtrlSetState($g_arrCon[$ID_btnHELP], $GUI_DISABLE) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Set Events ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;GUI Events Handled by _GUIEventHandler() GUICtrlSetOnEvent($g_arrCon[$ID_btnOPTIONS], "_GUIEventHandler") GUICtrlSetOnEvent($g_arrCon[$ID_btnEXIT], "_GUIEventHandler") GUICtrlSetOnEvent($g_arrCon[$ID_btnHELP], "_GUIEventHandler") ;System Events Handled by _SysEventHandler() GUISetOnEvent($GUI_EVENT_CLOSE, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_RESTORE, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_RESIZED, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetOnEvent($GUI_EVENT_DROPPED, "_SysEventHandler", $g_arrWin[$ID_winMAIN]) GUISetState(@SW_SHOW, $g_arrWin[$ID_winMAIN]) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Main Program Loop ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 Sleep(100) WEnd ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Event Functions ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func _GUIEventHandler() Switch @GUI_CtrlId Case $g_arrCon[$ID_btnEXIT] _TerminateApp() Case $g_arrCon[$ID_btnOPTIONS] Case $g_arrCon[$ID_btnHELP] EndSwitch EndFunc Func _SysEventHandler() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE If @GUI_WinHandle <> $g_arrWin[$ID_winMAIN] Then _TerminateGUI(@GUI_WinHandle) Else _TerminateApp() EndIf Case $GUI_EVENT_MINIMIZE Case $GUI_EVENT_RESTORE Case $GUI_EVENT_MAXIMIZE Case $GUI_EVENT_PRIMARYDOWN Case $GUI_EVENT_PRIMARYUP Case $GUI_EVENT_SECONDARYDOWN Case $GUI_EVENT_SECONDARYUP Case $GUI_EVENT_MOUSEMOVE Case $GUI_EVENT_RESIZED Case $GUI_EVENT_DROPPED EndSwitch EndFunc ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Define Functions ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #region --- Internal Functions ;Displays an error message to the user, and optionally times out. Func _ErrorMsg($message, $time = 0) MsgBox(48 + 262144, "Error!", $message, $time) EndFunc ;Function to be used to terminate the application. (Clean up Application) Func _TerminateApp() Exit EndFunc ;This function is to be used with programs that have multiple GUI's and ;will optionally terminate application if called incorrectly on the main ;GUI. Func _TerminateGUI($gui_hWnd, $gui_title = "") If $gui_title = "" Then $gui_title = $g_arrWin[$ID_winTITLE] If $gui_hWnd = $hSome3rdLayerGUI Then ;Do 3rd Layer GUI stuff (for example look at RAS-NEW.au3) GUIDelete($gui_hWnd) Else GUIDelete($gui_hWnd) If $gui_hWnd = $g_arrWin[$ID_winMAIN] Then _TerminateApp() Else WinActivate($gui_title) EndIf EndIf EndFunc #endregion Internal Functions I hope that helps you some... JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
fisofo Posted November 10, 2006 Author Posted November 10, 2006 I have found that my _ComputerGetInfo() functions (found in my signature) have come in quite handy for me in many applications and duties. My most used set of code is my template for OnEventMode. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Program Name: Template - OnEventMode ;Description: Template for OnEventMode GUI scripts ;Filename: Template - OnEventMode.au3 ;Used With: ;Created by: Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com) ;Created on: 06/20/2006 ;Modified on: ;Modified by: ;Version: 0.0.2 ;Copyright: Copyright (C) 2006 Vortex Revolutions. All Rights Reserved. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I didn't quite follow at first, but now i get it... very nice! I may have use for it on a project i'm just starting...
Achilles Posted November 12, 2006 Posted November 12, 2006 (edited) I use this all the time, it's even in my startup tray. It takes a while to get use to but I find it saves a lot of time after that... I got it from a script Paulie ( I think ) made, except that they had made a game or something with it and I just simplified it to this... #include <Misc.au3> Hotkeyset("!q", "Close") Global $aPos While 1 _MouseFree(1,1, @desktopwidth-3, @desktopheight-3) Sleep(10) WEnd Func Close() Exit Endfunc Func _MouseFree($iLeft, $iTop, $iWidth, $iHeight) Local $iRight, $iBottom $iRight = $iLeft + $iWidth $iBottom = $iTop + $iHeight If $iLeft < 0 Or $iTop < 0 Or $iRight > @DesktopWidth Or $iBottom > @DesktopHeight Then SetError (1) Return 0 EndIf $aPos = MouseGetPos() Select Case $aPos[0] > $iRight MouseMove($iLeft, $aPos[1], 0) Case $aPos[0] < $iLeft MouseMove($iRight, $aPos[1], 0) Case $aPos[1] > $iBottom MouseMove($aPos[0], $iTop, 0) Case $aPos[1] < $iTop MouseMove($aPos[0], $iBottom, 0) EndSelect EndFunc EDIT: Realized I had left an extra variable in... Edited November 12, 2006 by Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
fisofo Posted November 12, 2006 Author Posted November 12, 2006 I use this all the time, it's even in my startup tray. It takes a while to get use to but I find it saves a lot of time after that... I got it from a script Paulie ( I think ) made, except that they had made a game or something with it and I just simplified it to this...Yeah, I like that one... although I still need to figure out how to make it work with mutliple monitors that are in different positions (not lined up)... anyway, nice!
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