Jump to content

Terenz

Active Members
  • Posts

    568
  • Joined

  • Last visited

  • Days Won

    1

Terenz last won the day on October 7 2013

Terenz had the most liked content!

About Terenz

  • Birthday 04/28/1984

Profile Information

  • Location
    Noware

Recent Profile Visitors

655 profile views

Terenz's Achievements

  1. Work fine! Thanks, i'll study it (and i don't have find on Google _WinAPI_DeviceIoControl lol, didn't know it already exist). Thanks again!
  2. On external disk not work in my case, so i have see a different approach on stackoverflow and i want to try it out. But with DllCall i have some difficuties 😅
  3. MsgBox(64, "DriveIsSDD Test", "Is SSD: " & DriveIsSDD("C:")) Func DriveIsSDD($vDrive) Local $hDev, $vSizeQ, $vSizeD, $vBytesRet, $STORAGE_PROPERTY_QUERY, $DEVICE_SEEK_PENALTY_DESCRIPTOR If StringInStr($vDrive, ":\") Then $vDrive = StringRegExpReplace($vDrive, "(.*):.*", "$1") ElseIf StringLen($vDrive) = 1 Then $vDrive &= ":" EndIf ; FILE_SHARE_DELETE := 0x4 ; FILE_SHARE_WRITE := 0x2 ; FILE_SHARE_READ := 0x1 ; OPEN_EXISTING := 3 $hDev = DllCall("kernel32.dll", "dword", "CreateFileW", "wstr", "\\.\\" & $vDrive, "uint", 0, "uint", 0x7, "ptr", 0, "uint", 3, "uint", 0, "ptr", 0, "ptr", 0) If Not IsArray($hDev) Or $hDev[0] = -1 Or @error Then Return EndIf ; StorageDeviceSeekPenaltyProperty := 7 ; PropertyStandardQuery := 0 $vSizeQ = 12 $STORAGE_PROPERTY_QUERY = DllStructCreate("int PropertyId;int QueryType;byte AdditionalParameters[1]") DllStructSetData($STORAGE_PROPERTY_QUERY, "PropertyId", 7) DllStructSetData($STORAGE_PROPERTY_QUERY, "QueryType", 0) $vSizeD = 12 $DEVICE_SEEK_PENALTY_DESCRIPTOR = DllStructCreate("int Version;int Size;byte IncursSeekPenalty") $vBytesRet = 0 ; IOCTL_STORAGE_QUERY_PROPERTY := 0x002D1400 If DllCall("kernel32.dll","bool","DeviceIoControl", "ptr", $hDev[0], "uint", 0x002D1400, "ptr", DllStructGetPtr($STORAGE_PROPERTY_QUERY), "uint", $vSizeQ, "ptr", DllStructGetPtr($DEVICE_SEEK_PENALTY_DESCRIPTOR), "uint", $vSizeD, "uint*", $vBytesRet, "ptr", 0) Then DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hDev[0]) Return Not DllStructGetData($DEVICE_SEEK_PENALTY_DESCRIPTOR, "IncursSeekPenalty") EndIf ; IOCTL_ATA_PASS_THROUGH := 0x0004D02C ; ATA_PASS_THROUGH_EX ; IDENTIFY_DEVICE_DATA - NominalMediaRotationRate ; Sending ATA commands directly to device in Windows? - Stack Overflow ; https://stackoverflow.com/questions/5070987/sending-ata-commands-directly-to-device-in-windows DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hDev[0]) Return 0 EndFunc Probably there are many mistakes. Someone want to check it out? Thanks! 😀
  4. #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <Misc.au3> #NoTrayIcon If _Singleton("ContextMenu", 1) = 0 Then Exit Global $hMouseHook, $fShow = False, $MenuID = False While 1 If _IsPressed("04") Then If Not $fShow Then $ContextMenu = GUICreate("", 0, 0) $hMod = _WinAPI_GetModuleHandle(0) $Callback = DllCallbackRegister("WH_MOUSE_LL", "int", "int;ptr;ptr") $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($Callback), $hMod, 0) $MainContextMenu = GUICtrlCreateContextMenu() GUICtrlCreateMenuItem("Normal", $MainContextMenu) GUICtrlCreateMenuItem("lowercase", $MainContextMenu) GUICtrlCreateMenuItem("UPPERCASE", $MainContextMenu) GUICtrlCreateMenuItem("Capitalize Words", $MainContextMenu) GUICtrlCreateMenuItem("iNVERT cASE", $MainContextMenu) GUICtrlCreateMenuItem("", $MainContextMenu) GUICtrlCreateMenuItem("Exit", $MainContextMenu) GUIRegisterMsg($WM_MENUSELECT, "WM_MENUSELECT") ControlClick($ContextMenu, "", $ContextMenu, "Right", 1) $fShow = True Else GUIDelete($ContextMenu) $fShow = False EndIf EndIf Sleep(10) WEnd Func WH_MOUSE_LL($nCode, $wParam, $lParam) #forceref $nCode, $wParam, $lParam If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) EndIf Switch $wParam Case $WM_LBUTTONUP Local $tMOUSE = DllStructCreate("uint x;uint y", $lParam) If Not (_WinAPI_GetClassName(_WinAPI_WindowFromPoint($tMOUSE)) = "#32768") Then $MenuID = False GUIDelete($ContextMenu) EndIf EndSwitch Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) EndFunc ;==>WH_MOUSE_LL Func WM_MENUSELECT($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam If Not $lParam Then Switch $MenuID Case 4 SentenceCaseFunction() Case 5 LowerCaseFunction() Case 6 UppercaseFunction() Case 7 CapitalizeFunction() Case 8 InvertCaseFunction() Case 10 ExitFunction() EndSwitch GUIDelete($ContextMenu) Else $wParam = BitAND($wParam, 0xFFFF) $MenuID = _GUICtrlMenu_GetItemID($lParam, $wParam, False) EndIf EndFunc ;==>WM_MENUSELECT Func SentenceCaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(SentenceCase(ClipGet())) Send("^v") EndFunc ;==>SentenceCaseFunction Func LowerCaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(StringLower(ClipGet())) Send("^v") EndFunc ;==>LowerCaseFunction Func UppercaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(StringUpper(ClipGet())) Send("^v") EndFunc ;==>UppercaseFunction Func CapitalizeFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(CapitalizeWords(ClipGet())) Send("^v") EndFunc ;==>CapitalizeFunction Func InvertCaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(InvertCase(ClipGet())) Send("^v") EndFunc ;==>InvertCaseFunction Func ExitFunction() GUIDelete($ContextMenu) Exit EndFunc ;==>ExitFunction Func CapitalizeWords($sInput) Local $aWords = StringSplit($sInput, " ") Local $sResult = "" For $i = 1 To $aWords[0] $sResult &= StringUpper(StringLeft($aWords[$i], 1)) & StringLower(StringTrimLeft($aWords[$i], 1)) & " " Next Return StringTrimRight($sResult, 1) EndFunc ;==>CapitalizeWords Func InvertCase($sInput) Local $sResult = "" For $i = 1 To StringLen($sInput) Local $sChar = StringMid($sInput, $i, 1) If StringIsLower($sChar) Then $sResult &= StringUpper($sChar) ElseIf StringIsUpper($sChar) Then $sResult &= StringLower($sChar) Else $sResult &= $sChar EndIf Next Return $sResult EndFunc ;==>InvertCase Func SentenceCase($sInput) Local $OutputString = "" Local $CapitalizeNext = True For $i = 1 To StringLen($sInput) Local $char = StringMid($sInput, $i, 1) If $char == "." Or $char == "?" Or $char == "!" Then $OutputString &= $char $CapitalizeNext = True ElseIf $CapitalizeNext And StringIsAlpha($char) Then $OutputString &= StringUpper($char) $CapitalizeNext = False Else $OutputString &= StringLower($char) EndIf Next Return $OutputString EndFunc ;==>SentenceCase
  5. Lol @ioa747 you are so funny, you don't have any idea of what i have write (probably my english isn't prefect, but your understanding of the language is worse than mine). I'm part of this forum from 2013, not the first guy passed here with one post asking for game automation. I'll write my solution with ALL the problems resolved.
  6. Entire logic lol, is just a popup menu. I have explained: For work i need a tool for change case of the selected text (Uppercase, lowercase etc) I need to explain more? Okay. 1) Take your mouse 2) Select a text with the left mouse click (example inside notepad or whatever ide) and this text contain the phrase "i like autoit" 3) SHIFT + right click of the mouse will open a menu 4) Select the option menu "UPPERCASE" 5) The selected text will become "I LIKE AUTOIT" 6) Profit Now the code of third post work: Still have two problems: 1) If i click outside the menu, the menu will not disappear. If i add GUISetState and the WS_POPUP the "logic" of the software will not work anymore, so i can't change the case of the text. 2) Click again SHIFT + right click of the mouse (if the menu is already open) will not open a new menu in a new position, since seems TrackPopupMenu is a blocking function so stop the loop and i can't destroy it If isn't clear tell me, remember that english isn't my mother language
  7. Did you try it? In this case not work anymore (the menu part, i mean the UPPERCASE etc)
  8. @Andreik i think you don't have understand. This is a complete example: #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <Misc.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo, $e_idUppercase, $e_idLowercase, $e_idCapitalize, $e_idinvertCase, $e_idExit Global $hMenu, $hGUI, $iContextMenuItem, $GetCursorInfo While 1 If _IsPressed("10") And _IsPressed("04") Then ContextMenu() EndIf Sleep(10) WEnd Func ContextMenu() $hGUI = GUICreate("", 0, 0) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "UPPERCASE", $e_idUppercase) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "lowercase", $e_idLowercase) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "Capitalize Function", $e_idCapitalize) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "iNVERT cASE", $e_idinvertCase) _GUICtrlMenu_InsertMenuItem($hMenu, 4, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 5, "Undo", $e_idExit) Local $iMouseX = MouseGetPos(0), $iMouseY = MouseGetPos(1) $iContextMenuItem = _GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI, $iMouseX, $iMouseY, 0, 0, 2) Switch $iContextMenuItem Case $e_idUppercase UppercaseFunction() Case $e_idLowercase LowerCaseFunction() Case $e_idCapitalize CapitalizeFunction() Case $e_idinvertCase InvertCaseFunction() Case $e_idExit ExitFunction() EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) GUIDelete($hGUI) EndFunc ;==>ContextMenu Func ExitFunction() _GUICtrlMenu_DestroyMenu($hMenu) GUIDelete($hGUI) EndFunc ;==>CloseMenu Func UppercaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(StringUpper(ClipGet())) Send("^v") EndFunc ;==>UppercaseFunction Func LowerCaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(StringLower(ClipGet())) Send("^v") EndFunc ;==>UppercaseFunction Func CapitalizeFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(CapitalizeWords(ClipGet())) Send("^v") EndFunc ;==>CapitalizeFunction Func InvertCaseFunction() ClipPut("") Send("^c") Sleep(100) ClipPut(InvertCase(ClipGet())) Send("^v") EndFunc ;==>CapitalizeFunction Func CapitalizeWords($sInput) Local $aWords = StringSplit($sInput, " ") Local $sResult = "" For $i = 1 To $aWords[0] $sResult &= StringUpper(StringLeft($aWords[$i], 1)) & StringLower(StringTrimLeft($aWords[$i], 1)) & " " Next Return StringTrimRight($sResult, 1) EndFunc Func InvertCase($sInput) Local $sResult = "" For $i = 1 To StringLen($sInput) Local $sChar = StringMid($sInput, $i, 1) If StringIsLower($sChar) Then $sResult &= StringUpper($sChar) ElseIf StringIsUpper($sChar) Then $sResult &= StringLower($sChar) Else $sResult &= $sChar EndIf Next Return $sResult EndFunc Still missing the possibility to destroy the context menu if i click outside from the context menu. The combination is SHIFT + Middle Mouse Click for the menu. The selected text will be converted to one of the possibility Still open to improve
  9. #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <Misc.au3> Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo Global $hMenu, $hGUI, $iContextMenuItem While 1 If _IsPressed("10") And _IsPressed("2") Then ContextMenu() EndIf Sleep(100) WEnd Func ContextMenu() $hGUI = GUICreate("", 0, 0) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo) Local $iMouseX = MouseGetPos(0), $iMouseY = MouseGetPos(1) $iContextMenuItem = _GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI, $iMouseX, $iMouseY, 0, 0, 2) MsgBox(0, "Selected Context Menu Item Selected", $iContextMenuItem) _GUICtrlMenu_DestroyMenu($hMenu) EndFunc ;==>ContextMenu Hi, For work i need a tool for change case of the selected text (Uppercase, lowercase etc) when i SHIFT + Left click with the mouse. Two questions: 1) How to destroy the context menu if i click outside from the context menu? 2) How to get the selected text and change for example to UPPERCASE? Thanks!
  10. Hello, I'll explain. I'm donwloading a very big CSV, not in size (is less than 500kb) but has many lines (5000+) I'll take this CSV and convert to a multidimensional array, and this operation require some time. Pratically the link is static, so thay never change, and this CSV is updated often. The value are in order, so the last added are from line 1 (line 0 is the column) Since i don't what to re-create the array from zero every time, how i can get only the difference from the CSV/Array in memory and the "new" CSV", and the put the difference inside the array? Thanks
  11. Hi ahmet. Thanks for your help I need to get the month and the date from the file [0]=03 [1]=2020 I have try to change the RegEx flag to 3 but not work, return all the string
  12. Hello, I need to match in regex if a filename have month and year. Example my_business_03_2020 03 my business 2020 And so on. So i need to match if there are two digit consecutive and four digit consecutive and extract from the file name. I need both, if exist one of the two is considerated "error" for me Thanks
  13. @Jos can you please check it out my previous post? Your script work on change the icon but corrupt in some way the EXE, with or without UPX. It doesn' start anymore. I don't have any AV on the machine. Thanks P.S. I don't have understand the "attitude", english isn't my motehr language
×
×
  • Create New...