Valuater Posted February 24, 2006 Author Share Posted February 24, 2006 expandcollapse popup; return min or max number from 1 or 2 arrays ; Author - gafrost #include <Array.au3> Func _MinMaxa($a_nums01, $MaxFlag = 0, $a_nums02 = 0) If Not IsArray($a_nums01) Then SetError(1) Return (0) EndIf If @NumParams = 3 Then If Not IsArray($a_nums02) Then SetError(3) Return (0) EndIf EndIf ; Local $idx ; For $idx = 0 To UBound($a_nums01) - 1 If StringIsFloat($a_nums01[$idx]) Or StringIsInt($a_nums01[$idx]) Then $a_nums01[$idx] = Number($a_nums01[$idx]) Else SetError(2) Return (0) EndIf Next _ArraySort($a_nums01, $MaxFlag) If @NumParams = 3 Then For $idx = 0 To UBound($a_nums02) - 1 If StringIsFloat($a_nums02[$idx]) Or StringIsInt($a_nums02[$idx]) Then $a_nums02[$idx] = Number($a_nums02[$idx]) Else SetError(4) Return (0) EndIf Next _ArraySort($a_nums02, $MaxFlag) If $MaxFlag Then If Number($a_nums01[0]) > Number($a_nums02[0]) Then Return $a_nums01[0] Else Return $a_nums02[0] EndIf Else If Number($a_nums01[0]) < Number($a_nums02[0]) Then Return $a_nums01[0] Else Return $a_nums02[0] EndIf EndIf EndIf Return $a_nums01[0] EndFunc ;==>_MinMaxaExample:http://www.autoitscript.com/forum/index.php?showtopic=21453#8) Link to comment Share on other sites More sharing options...
Valuater Posted February 25, 2006 Author Share Posted February 25, 2006 (edited) ; get Active Window (Title)(Text) ; Author - SmOke_N & Valuater $MyText = WinGetText(FindActiveWindow()) $MyTitle = WinGetTitle(FindActiveWindow()) MsgBox(0, $MyTitle, $MyText) Func FindActiveWindow() Local $HidOpt = Opt("WinDetectHiddenText", 1);0=don't detect, 1=do detect Local $w_WinList = WinList() For $i = 1 to $w_WinList[0][0] If $w_WinList[$i][0] <> "" AND BitAnd(WinGetState($w_WinList[$i][1]), 2) _ And BitAnd(WinGetState($w_WinList[$i][1]), 8) Then Return $w_WinList[$i][0] Next Opt("WinDetectHiddenText", $HidOpt);0=don't detect, 1=do detect EndFunc 8) Edited February 26, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted March 4, 2006 Author Share Posted March 4, 2006 (edited) ; Move Message Box ; Author - herewasplato _MoveMsgBox(0, "testTitle", "testText", 0, 10) Func _MoveMsgBox($MBFlag, $MBTitle, $MBText, $x, $y) Local $file = FileOpen(EnvGet("temp") & "\MoveMB.au3", 2) If $file = -1 Then Return;if error, give up on the move Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')' Local $line2 = 'WinWait("' & $MBTitle & '", "' & $MBText & '")' Local $line3 = 'WinMove("' & $MBTitle & '", "' & $MBText & '"' & ', ' & $x & ', ' & $y & ')' FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3) FileClose($file) Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3") MsgBox($MBFlag, $MBTitle, $MBText) FileDelete(EnvGet("temp") & "\MoveMB.au3") EndFunc;==>_MoveMsgBoxBetaexpandcollapse popup; InputBox OnTop ; Author - herewasplato $ans = _InputBoxOnTop("Title", "Prompt") If @error = 0 Then MsgBox(0, "Returned", $ans) If @error = 1 Then MsgBox(0, "", "The Cancel button was pushed.") If @error = 2 Then MsgBox(0, "", "The Timeout time was reached.") If @error = 3 Then MsgBox(0, "", "The InputBox failed to open.") Func _InputBoxOnTop($IBTitle, $IBPrompt, $IBDefault = "", _ $IBpassword_char = "", $IBWidth = -1, $IBHeight = -1, _ $IBLeft = Default, $IBTop = Default, $IBTimeOut = "") Local $file = FileOpen(EnvGet("temp") & "\InputBoxOT.au3", 2) If $file = -1 Then Return;if error, give up Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')' Local $line2 = 'WinWait("' & $IBTitle & '", "' & $IBPrompt & '")' Local $line3 = 'WinSetOnTop("' & $IBTitle & '", "' & $IBPrompt & '" ,1)' FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3) FileClose($file) Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\InputBoxOT.au3") Local $ans = InputBox($IBTitle, $IBPrompt, $IBDefault, _ $IBpassword_char, $IBWidth, $IBHeight, _ $IBLeft, $IBTop, $IBTimeOut) If @error Then $ans = @error While Not FileDelete(EnvGet("temp") & "\InputBoxOT.au3") Sleep(10) WEnd SetError($ans) $ans = "" Return $ans EndIf While Not FileDelete(EnvGet("temp") & "\InputBoxOT.au3") Sleep(10) WEnd Return ($ans) EndFunc;==>_InputBoxOnTopSEE- Variations in next post Below *** NEW ADDITION ***_Msgbox UDFhttp://www.autoitscript.com/forum/index.ph...=28477&hl=#8) Edited July 1, 2006 by Valuater Link to comment Share on other sites More sharing options...
herewasplato Posted March 4, 2006 Share Posted March 4, 2006 ; Move Message Box ; Author - herewasplato ......... Beta 8)Variations on a theme: http://www.autoitscript.com/forum/index.ph...ndpost&p=156493 Spirals anyone? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Valuater Posted March 5, 2006 Author Share Posted March 5, 2006 expandcollapse popup; Set Mouse Cursor Style ; Author - gafrost Global Const $OCR_APPSTARTING = 32650 Global Const $OCR_NORMAL = 32512 Global Const $OCR_CROSS = 32515 Global Const $OCR_HAND = 32649 Global Const $OCR_IBEAM = 32513 Global Const $OCR_NO = 32648 Global Const $OCR_SIZEALL = 32646 Global Const $OCR_SIZENESW = 32643 Global Const $OCR_SIZENS = 32645 Global Const $OCR_SIZENWSE = 32642 Global Const $OCR_SIZEWE = 32644 Global Const $OCR_UP = 32516 Global Const $OCR_WAIT = 32514 ;~ _SetCursor(@WindowsDir & "\cursors\3dgarro.cur", $OCR_NORMAL) ;~ _SetCursor(@WindowsDir & "\cursors\3dwarro.cur", $OCR_NORMAL) _SetCursor(@WindowsDir & "\cursors\banana.ani", $OCR_NORMAL) ;================================================================== ; $s_file - file to load cursor from ; $i_cursor - system cursor to change ;================================================================== Func _SetCursor($s_file, $i_cursor) Local $newhcurs, $lResult $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file) If Not @error Then $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor) If Not @error Then $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0]) Else MsgBox(0, "Error", "Failed SetSystemCursor") EndIf Else MsgBox(0, "Error", "Failed LoadCursorFromFile") EndIf EndFunc ;==>_SetCursor 8) Link to comment Share on other sites More sharing options...
Valuater Posted March 11, 2006 Author Share Posted March 11, 2006 (edited) ; Allow only one Window ; Author - SmOke_N Dim $WinNotToRepeat = WinGetHandle('Name - Microsoft Internet Explorer') While 1 _ThereCanBeOnlyOne($WinNotToRepeat) Sleep(100) WEnd Func _ThereCanBeOnlyOne($w_High_Lander, $w_Kill_Close = 0, $i_IsVisible = 0); $w_Kill_Close = 0 it will use WinKill if will use WinClose If $w_High_Lander <> '' Then $w_Winlist = WinList() For $i = 1 To $w_Winlist[0][0] If $i_IsVisible = 0 Then If $w_Winlist[$i][0] == WinGetTitle($w_High_Lander) And $w_Winlist[$i][1] <> $w_High_Lander And BitAnd(WinGetState($w_Winlist[$i][1]), 2) Then If $w_Kill_Close = 0 Then WinKill($w_Winlist[$i][1]) Else WinClose($w_Winlist[$i][1]) EndIf EndIf Else If $w_Winlist[$i][0] == WinGetTitle($w_High_Lander) And $w_Winlist[$i][1] <> $w_High_Lander Then If $w_Kill_Close = 0 Then WinKill($w_Winlist[$i][1]) Else WinClose($w_Winlist[$i][1]) EndIf EndIf EndIf Next EndIf EndFunc 8) Edited March 12, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted March 20, 2006 Author Share Posted March 20, 2006 expandcollapse popup; User/System idle time ; Author gafrost #include <Date.au3> HotKeySet("{Esc}", "_Terminate") Local $last_active = 0, $iHours, $iMins, $iSecs $not_idle = _CheckIdle($last_active, 1) while (1) Sleep(200) $not_idle = _CheckIdle($last_active) _TicksToTime($not_idle, $iHours, $iMins, $iSecs) If $iHours Or $iMins Or $iSecs Then ConsoleWrite("Was Idle for: Hours: " & $iHours & " Minutes: " & $iMins & " Seconds: " & $iSecs & @LF) EndIf WEnd Func _CheckIdle(ByRef $last_active, $start = 0) $struct = DllStructCreate("uint;dword"); DllStructSetData($struct, 1, DllStructGetSize($struct)); If $start Then DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct)) $last_active = DllStructGetData($struct, 2) Return $last_active Else DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct)) If $last_active <> DllStructGetData($struct, 2) Then Local $save = $last_active $last_active = DllStructGetData($struct, 2) Return $last_active - $save EndIf EndIf EndFunc ;==>_CheckIdle Func _Terminate() Exit EndFunc ;==>_Terminate 8) Link to comment Share on other sites More sharing options...
PezoFaSho Posted March 20, 2006 Share Posted March 20, 2006 thats some cool stuff. and thx for taking the time to post all of this info Valuater. I definately have uses for some of these things. 50% of the time, it works all the time Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 24, 2006 Share Posted March 24, 2006 (edited) wow! some really neat stuff can be done with autoit3!!!!!! thanks for sharing val, keep it up!!! Edited March 24, 2006 by slightly_abnormal Link to comment Share on other sites More sharing options...
NegativeNrG Posted March 24, 2006 Share Posted March 24, 2006 (edited) ;Check(when Exit), if Text is not equal to $e_to Then, prompt the user to save or not save. ;Author - NegativeNrG(Although its simple, it just saves time!). ;_ExitCheckText Change $Edit Handle, $title of messagebox, $message of messagebox, $equal to(default = NULL). Func _ExitCheckTextChange($E_hnd,$title,$message,$e_to = '') $buffer = GUIctrlread($E_hnd) if $buffer <> $e_to Then $choice = Msgbox(4,$title,$message) if $choice = 6 Then $filetosave = FileSaveDialog('Choose File',@scriptdir,'(*.au3)') $handle1 = FileOpen($filetosave,2) FileWrite($handle1,$buffer) Exit Elseif $choice <> 6 Then Exit EndIf Else Exit EndIf EndFunc Edited March 24, 2006 by NegativeNrG [size=20]My File Upload[/size]Register at my site and upload. Link to comment Share on other sites More sharing options...
Valuater Posted April 5, 2006 Author Share Posted April 5, 2006 ; Toggle Internet Images On/Off ; Author big_daddy #include <IE.au3> Opt("WinTitleMatchMode", 2) Toggle_Images(1) $oIE = _IECreate () _IENavigate ($oIE, "http:\\www.google.com") While WinExists("Internet Explorer") Sleep(250) WEnd Toggle_Images() Func Toggle_Images($On_Off=0) If $On_Off == 0 Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") Else RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") EndIf EndFunc ;==>Toggle_Images 8) guestscripter 1 Link to comment Share on other sites More sharing options...
RazerM Posted April 5, 2006 Share Posted April 5, 2006 a lot of useful scripts here! My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Valuater Posted April 6, 2006 Author Share Posted April 6, 2006 thanks everyone! ; Run any au3 file from your program ; Author Valuater $file_loc = @ScriptDir & "\Test.au3" If @Compiled = 1 Then $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"') Run($file_exe) Else $file_au3 = FileGetShortName($file_loc) Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE) EndIf 8) Link to comment Share on other sites More sharing options...
Valuater Posted April 10, 2006 Author Share Posted April 10, 2006 expandcollapse popup; Draw a line on any Screen/Program ; Author JdeB, Co-Author Valuater Dim $Mpos_1 = "", $Mpos_1A = "", $Mpos_2 = "", $Mpos_2A = "", $line = "" $LineColor = 0x0000ff; color BGR $LineWidth = 10 HotKeySet( "{ESC}", "Get_Exit") HotKeySet("{F1}", "Get_pos_one") HotKeySet("{F2}", "Get_pos_two") HotKeySet( "{F3}", "Get_drawing") MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line") While 1 Sleep(100) WEnd Func Get_pos_one() GUICtrlDelete($line) $Ms_In = MouseGetPos() $Mpos_1 = $Ms_In[0] $Mpos_2 = $Ms_In[1] EndFunc ;==>Get_pos_one Func Get_pos_two() GUICtrlDelete($line) $Ms_In2 = MouseGetPos() $Mpos_1A = $Ms_In2[0] $Mpos_2A = $Ms_In2[1] EndFunc ;==>Get_pos_two Func Get_drawing() If $Mpos_1 = "" Or $Mpos_1A = "" Then MsgBox(0, "Draw Error", " Two points of reference are required") MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line") Return EndIf $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor) DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $Mpos_1, "int", $Mpos_2, "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Mpos_1A, "int", $Mpos_2A) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0]) EndFunc ;==>Get_drawing Func Get_Exit() Exit EndFunc ;==>Get_Exit 8) guestscripter 1 Link to comment Share on other sites More sharing options...
Adam1213 Posted April 11, 2006 Share Posted April 11, 2006 (edited) Good but it could be better... (now you can click at the first position, the second and it draws the line! expandcollapse popup; Draw a line on any Screen/Program ; Author JdeB, Co-Authors Valuater and Adam1213 Dim $Mpos_1 = "", $Mpos_1A = "", $Mpos_2 = "", $Mpos_2A = "", $line = "" $LineColor = 0x0000ff; color BGR $LineWidth = 10 HotKeySet( "{ESC}", "Get_Exit") ;HotKeySet("{F1}", "Get_pos_one") ;HotKeySet("{F2}", "Get_pos_two") ;HotKeySet( "{F3}", "Get_drawing") ;MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line") #include <GUIConstants.au3> GUICreate(1, 1) While 1 MouseClick2() Get_pos_one() MouseClick2() Get_pos_two() Get_drawing() WEnd Func MouseClick2() Do $a = GUIGetCursorInfo() Sleep(100) Until $a[2] EndFunc ;==>mouseclick2 Func Get_pos_one() GUICtrlDelete($line) $Ms_In = MouseGetPos() $Mpos_1 = $Ms_In[0] $Mpos_2 = $Ms_In[1] EndFunc ;==>Get_pos_one Func Get_pos_two() GUICtrlDelete($line) $Ms_In2 = MouseGetPos() $Mpos_1A = $Ms_In2[0] $Mpos_2A = $Ms_In2[1] EndFunc ;==>Get_pos_two Func Get_drawing() If $Mpos_1 = "" Or $Mpos_1A = "" Then MsgBox(0, "Draw Error", " Two points of reference are required") MsgBox(0, "User Info", "Press *ESC* to exit" & @CRLF & "Press *F1* to set First position" & @CRLF & "Press *F2* to set Second position" & @CRLF & "Press *F3* to Draw the Line") Return EndIf $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor) DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $Mpos_1, "int", $Mpos_2, "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Mpos_1A, "int", $Mpos_2A) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0]) EndFunc ;==>Get_drawing Func Get_Exit() Exit EndFunc ;==>Get_Exit Edited April 11, 2006 by Adam1213 IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
Valuater Posted April 11, 2006 Author Share Posted April 11, 2006 this While 1 MouseClick2() Get_pos_one() MouseClick2() Get_pos_two() Get_drawing() WEnd doesnt always work correctly 8) Link to comment Share on other sites More sharing options...
rakudave Posted April 12, 2006 Share Posted April 12, 2006 another question: is there an other way to get rid of the lines than using F5? Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table Link to comment Share on other sites More sharing options...
Adam1213 Posted April 13, 2006 Share Posted April 13, 2006 another question: is there an other way to get rid of the lines than using F5?Put a window in front of the current one and mininise it.Or (windows key + d)*2 IRC Client - 75 pages 3728 lines. Blob crumbler (game)Backup (drag to backup + cmd line)RS232 Link to comment Share on other sites More sharing options...
Valuater Posted April 17, 2006 Author Share Posted April 17, 2006 ; toggle monitor On/Off ; Author greenmachine MonitorToggle(1) Sleep (20000) MonitorToggle(0) Func MonitorToggle($Off = 1) $opt = Opt("WinTitleMatchMode", 4) $WM_SYSCommand = 274 $SC_MonitorPower = 61808 $Power_Off = 2 $Power_On = -1 $HWND = WinGetHandle("classname=Progman") If $Off Then DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ "int", $SC_MonitorPower, "int", $Power_Off) Else DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, _ "int", $SC_MonitorPower, "int", $Power_On) EndIf Opt ("WinTitleMatchMode", $opt) EndFunc 8) Link to comment Share on other sites More sharing options...
pacman1176 Posted April 18, 2006 Share Posted April 18, 2006 monitor toggle, that's awesome :-D Link to comment Share on other sites More sharing options...
Recommended Posts