Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2018 in all areas

  1. Today I decided to fix my problem of yelling on my headset's mic. to the point of ... coding a solution As I change the headset, the mic. don't change ( and I forget to do it manually ), so I searched the form for code and came up with the solution to my need. #include <Debug.au3> ; for _DebugArrayDisplay() #include "SetMicForPlayback.bulk.au3" ;~ Global $g_aEnumerateAudioDevices = _EnumerateAudioDevices() ;~ Global $g_aEnumerateAudioDevicesWas = $g_aEnumerateAudioDevices ;~ _DebugArrayDisplay($g_aEnumerateAudioDevicesWas, "$g_aEnumerateAudioDevicesWas") ;~ Row |Col 0 |Col 1 |Col 2 |Col 3 |Col 4 ;~ Row 0 |Playback |{34d90035-0679-4b97-b868-ddba418b989b} |{0.0.0.00000000}.{34d90035-0679-4b97-b868-ddba418b989b}|Speakers (High Definition Audio Device) |1 ;~ Row 1 |Playback |{43d508ee-19c5-4513-bd52-e1b7ba57ee82} |{0.0.0.00000000}.{43d508ee-19c5-4513-bd52-e1b7ba57ee82}|Headset Earphone (2- Arctis Pro Wireless Chat) |0 ;~ Row 2 |Playback |{a6f69bc4-f708-4a0f-bf58-995fe9d5d221} |{0.0.0.00000000}.{a6f69bc4-f708-4a0f-bf58-995fe9d5d221}|Headset Earphone (Corsair VOID Wireless Gaming Dongle) |0 ;~ Row 3 |Microphone |{a025c7e9-3655-474f-9643-8f05f1e4d591} |{0.0.1.00000000}.{a025c7e9-3655-474f-9643-8f05f1e4d591}|Headset Microphone (2- Arctis Pro Wireless Chat) |0 ;~ Row 4 |Microphone |{f9a630d2-44e9-4db5-b115-9fe7503a2ec7} |{0.0.1.00000000}.{f9a630d2-44e9-4db5-b115-9fe7503a2ec7}|Headset Microphone (Corsair VOID Wireless Gaming Dongle) |1 ;~ _SwitchToDevice($g_aEnumerateAudioDevices[4][2]) ;~ + [1]"OnDefaultDeviceChanged", [2]"0", [3]"1", [4]"{0.0.0.00000000}.{43d508ee-19c5-4513-bd52-e1b7ba57ee82}" ;~ + [1]"OnDefaultDeviceChanged", [2]"0", [3]"1", [4]"{0.0.0.00000000}.{34d90035-0679-4b97-b868-ddba418b989b}" main() Func main() If WinExists(StringTrimRight(@ScriptName, 4) & "'s hidden window") Then Exit 0 AutoItWinSetTitle(StringTrimRight(@ScriptName, 4) & "'s hidden window") Local $n, $a, $s, $b, $i While Sleep(50) If $g_aAudioSwitched[0] And TimerDiff($g_aAudioSwitched[0]) > 500 Then ConsoleWrite('+ [1]"' & $g_aAudioSwitched[1] & '", [2]"' & $g_aAudioSwitched[2] & '", [3]"' & $g_aAudioSwitched[3] & '", [4]"' & $g_aAudioSwitched[4] & '"' & @CRLF) Switch $g_aAudioSwitched[1] Case "OnDefaultDeviceChanged" $s = "" $a = _EnumerateAudioDevices() For $n = 0 To UBound($a) - 1 If $a[$n][2] = $g_aAudioSwitched[4] Then $b = StringSplit($a[$n][3], "()", 0) If UBound($b) > 2 Then $s = $b[2] ConsoleWrite($s & @CRLF) ExitLoop EndIf Next If $s = "" Then ConsoleWrite(@TAB & $s & ' = not found ?, just 1 device ?, remote audio ?' & @CRLF) Else $i = 5 For $n = 0 To UBound($a) - 1 If $a[$n][0] = "Microphone" Then If StringInStr($a[$n][3], $s) Then ; ObjCreateInterface: "Warning: This feature is experimental." $i = ShellExecuteWait(@ScriptFullPath, "/ErrorStdOut " & $a[$n][2], @ScriptDir) Switch $i Case 3 ConsoleWrite(@TAB & $s & ": apply = True" & @CRLF) Case 4 ConsoleWrite(@TAB & $s & ": apply = False" & @CRLF) Case 1 ConsoleWrite(@TAB & $s & ": apply = Crashed" & @CRLF) Case Else ConsoleWrite(@TAB & $s & ": no clue !" & @CRLF) EndSwitch ExitLoop EndIf Else ContinueLoop EndIf Next EndIf If $i = 5 Then ConsoleWrite(@TAB & $s & ' = ..have to code a "default mic" if none associated. ( you do it, I don''t have one. )' & @CRLF) ;~ AdlibRegister("did_it_work") ; ...to have some feedback while in development, but the "Sound"("Recording" tab), shows the change on the fly. Case Else ConsoleWrite("! no code written for this event" & @CRLF) EndSwitch $g_aAudioSwitched[0] = 0 $g_aAudioSwitched[1] = "" EndIf WEnd EndFunc ;==>main Func did_it_work() AdlibUnRegister("did_it_work") Local $a = _EnumerateAudioDevices() _DebugArrayDisplay($a, "_EnumerateAudioDevices()") EndFunc ;==>did_it_work SetMicForPlayback.bulk.au3 The "bulk" file has the real code, ( not mine, references are in the code ) SetMicForPlayback.au3 this is the "main()" ( the code you can read above ). Works for me on Win10 v???.???.?? ( I'm not good with updates ). Hope it helps the next guy playing TF2 as an engineer, finding a headset close to you, to tell your team color to use the teleport that goes to the enemy base to get the intel., no one listens, you get aggravated, #%#$#@$ .... PS: ..the above code misbehaves a lot and is left for the adventurous. Use the current code in the downloads section for a functional script.
    2 points
  2. trancexx

    Time Control

    'quantum level' Time control is control (e.g. label) showing current time. Depending on your project theme it's sometimes good to have that control in your GUI. This is fairly simple task to build an maintain. Only thing that's not good is that you have either adlib it or add part of the code in script's main loop. Actually that's not bad thing . The bad thing is blocking effect of things that blocks, lol. Dialogs blocks. Other time consuming stuff blocks too. Solution could be to write main script in assembly and part that deals with time in plain AutoiIt. That way the main script could be pushed to some other thread and there would be no interference with our clock and the main script that would cause it to lag. That idea is totally and unbelievable stupid! Much smarter would be generate assembly on the fly to deal with clock/time and to push that to another thread. Like this maybe: Opt("MustDeclareVars", 1) Global $hGui = GUICreate("Time", 350, 270) Global $hLabel = GUICtrlCreateLabel("", 270, 250, 80, 20) GUICtrlSetColor(-1, 0x0000CC) GUICtrlSetFont(-1, 11.5, 600) Global $hButton = GUICtrlCreateButton("MsgBox", 125, 220, 100, 25) _ClockThisInAnotherThread($hLabel) GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit Case $hButton If MsgBox(4 + 32, "", "Is this blocking the clock?", 0, $hGui) = 6 Then MsgBox(0, Chr(0x4C) & Chr(105) & Chr(194 / 2) & Chr(0x72) & "...", BinaryToString(0x20756F79) & Chr(Sqrt(0x24C1)) & BinaryToString("0x72652E")) EndIf EndSwitch WEnd Func _ClockThisInAnotherThread($hControl) ; Get kernel32.dll handle Local $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", "wstr", "kernel32.dll") If @error Or Not $aCall[0] Then Return SetError(1, 0, 0) Local $hHandle = $aCall[0] ; Get addresses of functions from kernel32.dll. Sleep first: Local $aSleep = DllCall("kernel32.dll", "ptr", "GetProcAddress", _ "ptr", $hHandle, _ "str", "Sleep") If @error Or Not $aCall[0] Then Return SetError(2, 0, 0) Local $pSleep = $aSleep[0] ; GetTimeFormatW then: Local $aGetTimeFormatW = DllCall("kernel32.dll", "ptr", "GetProcAddress", _ "ptr", $hHandle, _ "str", "GetTimeFormatW") If @error Or Not $aCall[0] Then Return SetError(3, 0, 0) Local $pGetTimeFormatW = $aGetTimeFormatW[0] ; Get user32.dll handle $aCall = DllCall("kernel32.dll", "ptr", "GetModuleHandleW", "wstr", "user32.dll") If @error Or Not $aCall[0] Then Return SetError(4, 0, 0) $hHandle = $aCall[0] ; Get address of function from user32.dll, SendMessageW: Local $aSendMessageW = DllCall("kernel32.dll", "ptr", "GetProcAddress", _ "ptr", $hHandle, _ "str", "SendMessageW") If @error Or Not $aCall[0] Then Return SetError(5, 0, 0) Local $pSendMessageW = $aSendMessageW[0] ; Allocate enough memory with PAGE_EXECUTE_READWRITE for code to run $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", _ "ptr", 0, _ "dword", 36 + 256, _ ; 36 bytes for strings + 256 bytes for code "dword", 4096, _ ; MEM_COMMIT "dword", 64) ; PAGE_EXECUTE_READWRITE If @error Or Not $aCall[0] Then Return SetError(6, 0, 0) Local $pRemoteCode = $aCall[0] ; Make structure in reserved space Local $CodeBuffer = DllStructCreate("byte[256]", $pRemoteCode) ; Arrange strings in reserved space Local $tSpace = DllStructCreate("wchar Format[9];wchar Result[9]", $pRemoteCode + DllStructGetSize($CodeBuffer)) DllStructSetData($tSpace, "Format", "hh:mm:ss") If @AutoItX64 Then DllStructSetData($CodeBuffer, 1, _ "0x" & _ "4883EC" & SwapEndian(72, 1) & _ "C7442428" & SwapEndian(9, 4) & _ "48BF" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "48897C2420" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(4, 4) & _ "B9" & SwapEndian(0, 4) & _ "48B8" & SwapEndian($pGetTimeFormatW) & _ "FFD0" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(12, 4) & _ "48B9" & SwapEndian(GUICtrlGetHandle($hControl)) & _ "48B8" & SwapEndian($pSendMessageW) & _ "FFD0" & _ "B9" & SwapEndian(491, 4) & _ "48B8" & SwapEndian($pSleep) & _ "FFD0" & _ "4883C4" & SwapEndian(72, 1) & _ "E9" & SwapEndian(-136) & _ "C3" _ ) Else DllStructSetData($CodeBuffer, 1, _ "0x" & _ "68" & SwapEndian(9) & _ ; push output size "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to output container "68" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ ; push pointer to format string "68" & SwapEndian(0) & _ ; push NULL "68" & SwapEndian(4) & _ ; push TIME_FORCE24HOURFORMAT "68" & SwapEndian(0) & _ ; push Locale "B8" & SwapEndian($pGetTimeFormatW) & _ ; mov eax, [$pGetTimeFormatW] "FFD0" & _ ; call eax "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to the result "68" & SwapEndian(0) & _ ; push wParam "68" & SwapEndian(12) & _ ; push WM_SETTEXT "68" & SwapEndian(GUICtrlGetHandle($hControl)) & _ ; push HANDLE "B8" & SwapEndian($pSendMessageW) & _ ; mov eax, [$pSendMessageW] "FFD0" & _ ; call eax "68" & SwapEndian(491) & _ ; push Milliseconds "B8" & SwapEndian($pSleep) & _ ; mov eax, [$pSleep] "FFD0" & _ ; call eax "E9" & SwapEndian(-81) & _ ; jump back 81 bytes (start address) "C3" _ ; Ret ) EndIf ; Create new thread to execute code in $aCall = DllCall("kernel32.dll", "ptr", "CreateThread", _ "ptr", 0, _ "dword", 0, _ "ptr", $pRemoteCode, _ "ptr", 0, _ "dword", 0, _ "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(8, 0, 0) Local $hThread = $aCall[0] ; Return thread handle Return $hThread EndFunc Func SwapEndian($iValue, $iSize = @AutoItX64 ? 8 : 4) Return Hex(BinaryMid($iValue, 1, $iSize)) EndFunc This is obviously a variation on assembly/machine code/threads theme, but doesn't hurt to take advantage (or try to) of the ability a bit more.
    1 point
  3. After a lot of reading, it came down to the Z-Order being reset every time a topmost window is selected. So, I just needed to run the WinSetOnTop() function for my splashtext every time I update the text. ;Create the progress screen $aPOS = ControlGetPos("[CLASS:Shell_TrayWnd]", "", "[CLASS:MSTaskListWClass; INSTANCE:1]") if @error Then MsgBox(0, "Error", "Unable to find System Tray to build the progress screen") Exit EndIf $sMessage = "StatusBar - Starting..." SplashTextOn("SysTrayStatus", $sMessage, 340, 25, ($aPOS[0] + $aPOS[2]) - 350, @DesktopHeight - $aPOS[3] + Round(($aPOS[3] - 25) / 2, 2), 37, "Ariel", 8) WinSetOnTop("SysTrayStatus", "", 1) ;Set this as one of the Topmost windows ConsoleWrite("Initial State = " & WinGetState("SysTrayStatus", "") & @CRLF) ;initial is 3 ;Loop for 30 seconds, updating the text every 1 second For $i = 1 to 30 sleep(900) ControlSetText("SysTrayStatus", "", "Static1", "Running loop " & $i & " of 30") ConsoleWrite($i & " State = " & WinGetState("SysTrayStatus", "") & @CRLF) ;always = 3 WinSetOnTop("SysTrayStatus", "", 1) ;reset this to the top Z-Order of Topmost windows in case someone clicks the taskbar Next
    1 point
  4. I prettified the version I use at home, compiled it, and uploaded it to the downloads section of the forum. https://www.autoitscript.com/forum/files/file/476-setmicforplayback/
    1 point
  5. You could use _ArrayFindAll for example: #include <Array.au3> #include <File.au3> Global $sFilePath = @ScriptDir & "\Tracking.txt" If FileExists($sFilePath) = 0 Then Exit MsgBox(16, "Error", $sFilePath & " was not found") Global $sSearch = InputBox('What To Find', 'Type in below what to search for.' & @CRLF & _ 'Lines that match will be shown.', 'Text To Match', '', 200, 140) Global $sError = "" Switch @error Case 1 $sError = "The Cancel button was pushed." Case 2 $sError = "The Timeout time was reached." Case 3 $sError = "The InputBox failed to open. This is usually caused by bad arguments." Case 4 $sError = "The InputBox cannot be displayed on any monitor." Case 5 $sError = "Invalid parameters width without height or left without top." EndSwitch If $sSearch = "" Or $sError <> "" Then Exit MsgBox(48, "Error", "No Search Criteria") Global $aTracking _FileReadToArray($sFilePath, $aTracking) Switch @error Case 1 $sError = "Error opening specified file" Case 2 $sError = "Unable to split the file" Case 3 $sError = "File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set)" Case 4 $sError = "No delimiters found (only if $FRTA_INTARRAYS flag not set)" EndSwitch If $sError <> "" Then Exit MsgBox(48, "Error", $sError) Global $aSearch = _ArrayFindAll($aTracking, $sSearch, 0, 0, 0, 1) Switch @error Case 1 $sError = "$aArray is not an array" Case 2 $sError = "$aArray is not a 1D or 2D array" Case 3 $sError = "$aArray is empty" Case 4 $sError = "$iStart is greater than $iEnd" Case 5 $sError = "Array not 2D and $bRow set True" Case 6 $sError = "$vValue was not found in array" EndSwitch If $sError <> "" Then Exit MsgBox(48, "Error", $sError) _ArrayColInsert($aSearch, 1) For $i = 0 To UBound($aSearch) - 1 $aSearch[$i][1] = $aTracking[$aSearch[$i][0]] Next _ArrayDisplay($aSearch) MsgBox(64, 'Done', 'Total lines found = ' & UBound($aSearch) - 1 & @CRLF & _ 'Searched Line(s)= ' & @CRLF & _ArrayToString($aSearch, @CRLF, -1, -1, @CRLF, 1, 1))
    1 point
  6. Here is a working example for both _ArraySearch and _ArrayFindAll, just uncomment/comment one or the other, I find that you need to keep your array in sync with your spreadsheet when searching, _ArraySearch will search one by one, whereas _ArrayFindAll will find all instances and delete all but the first item found. Hope that makes sense. #include <Array.au3> #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\DuplicateDates.xlsx") CheckForDups() Func CheckForDups() Local $aSearch, $iFirstColumn Local $iDateandTimeRow = "2" Local $sFirstColumn = "B" Local $iFirstColumn = _Excel_ColumnToNumber($sFirstColumn) Local $sLastColumn = "L" local $rangetoread = $sFirstColumn & $iDateandTimeRow & ":" & $sLastColumn & $iDateandTimeRow ConsoleWrite("TheRangeWereLooking at dates and times are: " & $rangetoread & @CRLF) local $aDateArray = _Excel_RangeRead($oWorkbook, "Edit Here", $rangetoread) _ArrayDisplay($aDateArray) For $i = 0 To UBound($aDateArray, 2) - 1 $iSearch = _ArraySearch($aDateArray, $aDateArray[0][$i], $i + 1, 0, 0, 0, 1, -1, True) If $iSearch = -1 Then ContinueLoop ConsoleWrite($aDateArray[0][$i] & " - " & $iSearch & " : " & _Excel_ColumnToLetter($iSearch + $iFirstColumn) & ":" & _Excel_ColumnToLetter($iSearch + $iFirstColumn) & @CRLF) _Excel_RangeDelete($oWorkbook.ActiveSheet, _Excel_ColumnToLetter($iSearch + $iFirstColumn) & ":" & _Excel_ColumnToLetter($iSearch + $iFirstColumn), Default, 2) _ArrayColDelete($aDateArray, $iSearch) $i -= 1 Next ;~ For $i = UBound($aDateArray, 2) - 1 To 0 Step - 1 ;~ $aSearch = _ArrayFindAll($aDateArray, $aDateArray[0][$i], 0, 0, 0, 0, 0, True) ;~ If UBound($aSearch) - 1 = 0 Then ContinueLoop ;~ For $j = UBound($aSearch) - 1 To 1 Step - 1 ;~ _ArrayColDelete($aDateArray, $aSearch[$j]) ;~ $iFirstColumn = _Excel_ColumnToNumber($sFirstColumn) ;~ _Excel_RangeDelete($oWorkbook.ActiveSheet, _Excel_ColumnToLetter($aSearch[$j] + $iFirstColumn) & ":" & _Excel_ColumnToLetter($aSearch[$j] + $iFirstColumn), Default, 2) ;~ $i -= 1 ;~ Next ;~ Next _ArrayDisplay($aDateArray) EndFunc
    1 point
  7. Subz

    INI to List

    You mean something like: #include <Array.au3> #Include <File.au3> #Include <GUIConstants.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> Local $hGui = GUICreate("AForm1", 633, 447, 193, 115) ;~ Sorted List GUICtrlCreateLabel("Sorted List", 40, 15, 170, 20) GUICtrlSetFont(-1, 14, 400) Local $idList1 = GUICtrlCreateList("", 40, 40, 170, 357) ;~ Unsorted List GUICtrlCreateLabel("Unsorted List", 220, 15, 170, 20) GUICtrlSetFont(-1, 14, 400) Local $idList2 = GUICtrlCreateList("", 220, 40, 169, 357, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER)) GUICtrlSetFont(-1, 12, 400) GUICtrlSetColor(-1, 0xFF3300) GUISetState() Local $aFileList _FileReadToArray("Test.txt", $aFileList) For $i = 1 To $aFileList[0] _GUICtrlListBox_AddString($idList1,$aFileList[$i]) _GUICtrlListBox_AddString($idList2,$aFileList[$i]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
    1 point
  8. Bagel, Your previous code should return windows matching both conditions, as the semicolon in there means and (not or ) as clearly specified in the helpfile
    1 point
  9. Danyfirex

    dll call failed

    @caramen You should do a forum search here is a Tutorial You can check AutoIt include UDFs compare with MSDN API calls etc. Tips: Learn Dllcall correct declaration, Make sure to do correct data conversion from API to AutoIt Dllcall, Learn About Pointers. Saludos
    1 point
  10. @djfire Use AutoItWindowInfoTool and see if you can control your application with Control* functions instead of using Send() and/or Mouse* functions
    1 point
  11. a think yes , you can do with autoit , for run script program like admin you must run a script like admin for do that after include in top of script you must use #RequireAdmin look also in help for better
    1 point
  12. caramen

    AutoIt Snippets

    To know if a control is checked or not. Func _IsChecked($idControlID)     Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc
    1 point
  13. Under the GUICtrlSetStyle is the information you want . And an example to use it #include <GUIConstants.au3> Global $hGUI = GUICreate("Drag and Drop", 400, 400, -1, -1, -1, $WS_EX_ACCEPTFILES) Local $edtDrop = GUICtrlCreateEdit("", 10, 10, 380, 180) GUICtrlSetState(-1, $GUI_DROPACCEPTED) Local $lvListView = GUICtrlCreateListView("Column 1", 10, 200, 380, 180) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateListViewItem("Some example text", $lvListView) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateListViewItem("More example text", $lvListView) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlCreateListViewItem("Even more example text!", $lvListView) GUICtrlSetState(-1, $GUI_DROPACCEPTED) FileWrite(@ScriptDir & "\File.txt", "This is some example text") GUISetState(@SW_SHOW, $hGUI) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE GUIDelete($hGUI) FileDelete(@ScriptDir & "\File.txt") Exit 0 Case $GUI_EVENT_DROPPED If (@GUI_DragId = -1) Then ConsoleWrite("Dragging from a file" & @CRLF) GUICtrlSetData(@GUI_DropId, FileRead(@GUI_DragFile)) Else ConsoleWrite("Dragging from a Listview item"& @CRLF) GUICtrlSetData(@GUI_DropId, StringTrimRight(GUICtrlRead(GUICtrlRead(@GUI_DragId)), 1)) EndIf ConsoleWrite(@GUI_DragId & " | " & @GUI_DropId & " | " & @GUI_DragFile & @CRLF) EndSwitch WEnd
    1 point
  14. careca

    Time4Shutdown

    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Resources\Clock.ico #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Icon_Add=Resources\Clock.ico #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Opt("TrayAutoPause", 0) Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Time4Shutdown", 395, 32, 250, 475, -1, $WS_EX_DLGMODALFRAME) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $settime = GUICtrlCreateInput("", 168, 5, 49, 21) $Label1 = GUICtrlCreateLabel("Set time for shutdown in minutes", 8, 8, 156, 17) $Button1 = GUICtrlCreateButton("Start", 234, 3, 75, 25) GUICtrlSetOnEvent($Button1, "Start") $Button2 = GUICtrlCreateButton("Reboot", 314, 3, 75, 25) GUICtrlSetOnEvent($Button2, "Reboot") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func Start() GUISetState(@SW_HIDE) $time = GUICtrlRead($settime, 1) $timetosleep = $time * 60 Do ToolTip($timetosleep & ' Seconds Remanining', 300, 0) Sleep(995) $timetosleep -= 1 Until $timetosleep <= 0 ToolTip("") Shutdown(13) Exit EndFunc ;==>Start Func Reboot() Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4164, "Notice", "Do you really want to reboot?") Select Case $iMsgBoxAnswer = 6 ;Yes Case $iMsgBoxAnswer = 7 ;No EndSelect If $iMsgBoxAnswer = 6 Then MsgBox(4096, "Notice", "Clicked Yes! Going to reboot") Shutdown(6) ElseIf $iMsgBoxAnswer = 7 Then MsgBox(4096, "Notice", "Clicked No! Aborting reboot") EndIf EndFunc ;==>Reboot Func Close() Exit EndFunc ;==>Close Do Sleep(100) Until $Form1 = $GUI_EVENT_CLOSE
    1 point
  15. If every parameter consists of a name (like "/name") and the value (like "asd") you could parse the parameters like this: #AutoIt3Wrapper_Change2CUI=y $sTitle = "Test Script" If Mod($CmdLine[0], 2) <> 0 Then Exit MsgBox(16, $sTitle, "Invalid number of parameters! has to be a multiple of 2!") If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!") For $i = 1 To $CmdLine[0] Step 2 If $CmdLine[$i] = "/name" Then MsgBox(64, "Passed Parameters", "/name is " & $CmdLine[$i+1]) Next ConsoleWrite("Finished!") Open a cmd window and enter "test.exe /name asdf". You will get a MsgBox and the text "Finished!" on the console.
    1 point
  16. czmaster, Because Autoit variables are not "typed" (that is forced to be something specific like an integer, string, float, etc) you sometimes get the "best guess" of the interpreter as to what a type particular variable is supposed to be. If you open a file in binary mode, Autoit presumes you want the contents as a hex string - and that is what you get: the hex bytes preceded by "0x" to indicate it is hex. Look at this example: $sFilename = "Your_File_Path" Global $hFileHandle = FileOpen($sFilename, 16) $bFileContents = FileRead($hFileHandle) $bFirstBytes = StringLeft($bFileContents, 16) $bFirstHex = StringMid($bFileContents, 3, 14) MsgBox(0, "", $bFirstBytes & @CRLF & " " & $bFirstHex) You can see that the "normal" return has the "0x" at the beginning - it is up to you to remove it if you want to manipulate the bytes themselves. I know it sounds a pain, but it is the price to pay for having un-typed variables - one that I am very happy to pay given the flexibility that it offers. There are a number of commands which force variables into a specifiic type: Dec, Hex, Number, Binary, String, etc - these can be used if you want to change the type. For example, InputBox returns a string - so if you want to compare the result to a number, you need to reset the type first: $sResult = InputBox(..... If Number($sResult) > 5 Then ; .....I hope that answers your question. If not, post your code so we can see what is going on and offer more advice. M23
    1 point
×
×
  • Create New...