Jump to content

Recommended Posts

Note: This is completely unrelated to the program offered on TuCows and CNET, I named it without ever checking the title, and I may decide to change it at will.

Posted Image

Posted Image

What Does it do?

This program allows you to require a specific drive (USB preferably) to be connected to the computer to gain access while the program is running.

Downloads:

USBLock.zip (Includes Source code, Compiled version, and English .LANG file)

UPDATES: (click "see post" to see notes on changes)

Version 6: see post

Version 5: see post

Version 4: see post

Version 3: see post

Version 2: see post

-----------------------------------

-How does it do it?

1a. On a normal run, the program will ask you for a drive letter to assign as a "Key Drive".

1b. A drive letter is assigned by command-line parameter.

1c. The "auto" parameter is used, and we skip to Step 4.

2. The Program will then generate a random keyfile, save a hash of the keyfile locally and save the actual keyfile on the root of the chosen/validated drive.

3. Waits until the keydrive is removed.

4. BlockInput is called

5. Then the program then checks repeatedly for the existence of the keyfile on all drives

6. The keyfile is validated, if it is valid, BlockInput is released and we return tp Step 2.

7. Assuming the keyfile is invalid, it is deleted and we return to step 5.

Note: There is a special keyfile that can be saved on a drive that will shut down the program to allow emergency access.

(if you edit the emergency text in the script, you will need to edit your own emergency keyfile)

USBLock_Emergency_Keyfile.zip

Requirements:

WindowsConstants.au3

GUIConstants.au3

StaticConstants.au3

String.au3

Misc.au3

myToast.au3 - by me (given)

MD5.au3 - which is either by:

- Ward (Using CallWindowProc; I suggest this one.)

- Frez Systems Ltd and SvenP (all AutoIt)

- Other

Credits:

Monitor On/Off Example - MrCreatoR

MD5 - SvenP or Ward

... let me know if you were missed for credit.

EDIT: fixed the "steps" explanation

5-5-13 Edit: Re-added images to post

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

I tried this, But when I remove my drive it says it locks my computer but then those nothing..

It doesn't lock my computer.

And why don't you use something like this: ?

#include <File.au3>
While 1
$flash   = DriveGetDrive("removable")
if @Error then
Else
    if FindKey($flash[1]) Then
        msgbox ( 32+0, 'correct', 'this is the correct drive' )
    EndIf
    
EndIf
WEnd






Func FindKey($sDrive, $sD = 0, $sFile = 'key.opal', $sCreate = 0)
    if $sD = 1 then 
        if FileExists($sDrive&$sFile) Then
            FileDelete($sDrive&$sFile)
            if @error then
                return SetError(1, 1)
            Else
                return SetError(-1, -1)
            EndIf
        Else
            return -1
        EndIf
    EndIf
    If FileExists($sDrive&$sFile ) Then
        return 1
    Else
        if $sCreate = 1 then _FileCreate($sDrive&$sFile )
        return 0
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

Sorry, redownload the ZIP - I had the script stuck with the "DebugMode" parameter enabled (Runs normally, but does not lock)

and to answer your second question; I do, essentially, do that - create a file and check for existence, but having wrote this myself I did it in the way I saw most efficient.


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

ok, I went on with my script.

And now I have about the same thing but then a lot smaller:

#include <File.au3>
#NoTrayIcon
$check = DriveGetDrive('removable')
if @error then 
    msgbox ( 16, 'Error', 'Please insert a drive before running this program' )
    Exit
EndIf

$times = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\UsbLocker", "times" )
if $times = '' Then
    msgbox ( 32, 'Welcome', 'This program will now write a key to your drive: '&$check[1]&@CRLF&'Enjoy this program, created by ludocus :)' )
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\UsbLocker", "times", 'REG_SZ', 38383 )
    FindKey($check[1], default, default, 1 )
EndIf

While 1
sleep ( 100 )
$flash   = DriveGetDrive("removable")
if @Error then
    LockOut('on')
Else
    if FindKey($flash[1]) Then
        LockOut('off')
    Else
        LockOut('on')
    EndIf
EndIf
WEnd

Func LockOut($sType)
    if $sType = 'off' Then
        if not ProcessExists('explorer.exe') then
            WinMinimizeAllUndo()
            run ('explorer.exe')
        EndIf
        
    Else
        WinMinimizeAll()
        If ProcessExists('explorer.exe') then ProcessClose('explorer.exe')
        if ProcessExists('taskmgr.exe') then ProcessClose('taskmgr.exe')
        if ProcessExists('cmd.exe') then ProcessClose('cmd.exe')
    EndIf
EndFunc





Func FindKey($sDrive, $sD = 0, $sFile = 'key.opal', $sCreate = 0)
    if $sD = 1 then 
        if FileExists($sDrive&$sFile) Then
            FileDelete($sDrive&$sFile)
            if @error then
                return SetError(1, 1)
            Else
                return SetError(-1, -1)
            EndIf
        Else
            return -1
        EndIf
    EndIf
    If FileExists($sDrive&$sFile ) Then
        return 1
    Else
        if $sCreate = 1 then _FileCreate($sDrive&$sFile )
        return 0
    EndIf
EndFunc

Maybe usefull?

Share this post


Link to post
Share on other sites

now I have about the same thing

Not really.

Don't be offended if I decide not to use your script.

I don't see the need to close Explorer or Cmd if I'm already locking out user input - And I'd rather not restrict the drive to removable drives.

(The only reason I don't check A, B and C is because A B and C are, usually, always mounted drives.)

I also don't agree with writing to the registry unnecessarily.

Feel free to continue your application in another thread :)

Edit: I also see that you repeatedly minimize all windows, not blocking input?

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

My application works fine for now, thanks :)

Just as long as I make sure to turn off the occasional debug parameter.


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

I get a error, once compiled using beta, I get the following

Line -1:

Error: Variable Used without being declared

I use windows vista x86 with sp1

Edited by Ev0lving

Share this post


Link to post
Share on other sites

Pretty cool. If I had my druthers, I'd use a hardware_id instead of a key. Also If you want to prevent Ctrl+Alt+Del take a look at the code in this thread.

Edited by spudw2k

Share this post


Link to post
Share on other sites

Pretty cool. If I had my druthers, I'd use a hardware_id instead of a key. Also If you want to prevent Ctrl+Alt+Del take a look at the code in this thread.

Isn't it just easier to get the serial of the device? That's also unique, and just one line of code :P

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

UPDATE: Version 2

Updated includes files for newer AutoIt versions. (3.2.12.1 tested)

Supports two different styles of MD5.au3 (see first post for suggestions)

Pretty cool. If I had my druthers, I'd use a hardware_id instead of a key. Also If you want to prevent Ctrl+Alt+Del take a look at the code in this thread.

I would rather not marry the security of my computer to a specific drive without some sort of session-specific key.

Think of what might happen if you lock your PC and then lose your USB drive - someone could steal it and unlock your PC repeatedly.

However, the key I'm using is random and created on the keydrive (only the hash is saved on the locked system). This key is also renewed each time the drive unlocks the system.

So, even if someone copies the keyfile from your keydrive - if you unlock your system or quit USBLock, their key becomes invalid.

(However, the emergency key is an issue if they're aware of this software.; but you can always modify the emergency key text - edit the string starting with "~X@CD_USBLock")

Secondly, I'd rather not mess with system key combinations (like CTRL+ALT+DEL) that you're not supposed to block anyway.

- I COULD (although I'm not sure if I could do it in a simple method that would work for everyone) later use the serial or hardware id as part (but not all) of the identification for the keydrive.

NOTE: if you want to change how the "key" is determined just change what _GetNewKey() outputs.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Version 2.0

Very nice additions and very nice script, I am still able to input keystrokes and mousemovements in vista, the toast box comes up and tell me that my system is lock but I can still access it fully, I can help with getting it to work on Vista if you want.

Share this post


Link to post
Share on other sites

I'm guessing BlockInput fails if you do not run the program as admin [in Vista].

Failure: Already Enabled or #RequireAdmin not used.

I'll add #RequireAdmin to the script to fix this. Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Version 2.0

Very nice additions and very nice script, I am still able to input keystrokes and mousemovements in vista, the toast box comes up and tell me that my system is lock but I can still access it fully, I can help with getting it to work on Vista if you want.

I Just updated the script to have #RequireAdmin as suggested by the help file.

Try the new version of it. (2.1+)

Thanks.


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Just updated again (3.0)

This time I added:

  • A GUI to list possible drive selections for your keydrive. (no fixed drives, no floppy drives, no CD-ROM's)
  • Tray Option to set a new keydrive while unlocked. (Remember - you can have only one valid keydrive set.)
  • Changes to Locked mode to secure your computer more immediately.
  • Changes to update the keyfiles more immediately.
  • Added some parameter settings. (see below)

Parameters:

  • "auto" - use a previously saved key hash, lock immediately without keydrive selection . (Good for Windows Startup if you already set a keydrive; example: "USBLock.exe auto")
  • Anything Else - the first character is used to specify a keydrive to silently set before Locked/Unlocked modes. (silent alternative to the selection GUI; example: "USBLock.exe D" for D:\)

Posted Image

Notes:

The GUI has (currently) a fixed width of 300 and will start another row if the number of drives goes beyond 300px wide.

(I would start smaller than 300 except the titlebar text becomes hidden)

Tell me if the GUI is displayed correctly in dimensions, etc.

Tell me also if the drive icons are incorrect for your operating system, as I can add conditions to modify the DriveIcons array.

(I only had a WinXP box to test the icons with.)

etc.

Included from first post to catalog/save space:

  • UI: Standard running mode now features a visual listing of valid drives to set as your keydrive.

    Close this window to Exit USBLock

    (If the drive icons are wrong for your OS, we can update!)

  • Security: The BlockInput and security checks are now done immediately upon 'lock' and all during the "secured" Toast display.
  • Options:

    The KeyDrive can now be changed to a new drive while in 'Unlocked' mode. (See Tray menu)

  • Parameters: Normally USBLock is ran without parameters.

    If you use the parameter 'auto' the computer is immediately locked with a previously saved key. (Windows Startup? :P )

    Otherwise, parameter text is used to silently select a new keydrive. ("ijk" sets drive I:\)

  • Other: The Tray Icon and Tooltip have been changed to show correctly in script mode.
  • Other: Keys are now updated immediately instead of after Toast notifications.
Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

Parameters:

  • "auto" - use a previously saved key hash, lock immediately without keydrive selection . (Good for Windows Startup if you already set a keydrive; example: "USBLock.exe auto")
  • Anything Else - the first character is used to specify a keydrive to silently set before Locked/Unlocked modes. (silent alternative to the selection GUI; example: "USBLock.exe D" for D:\)

Great additions to the script, I have one problem.. I am trying to use the auto Parameters with no luck, it just runs the program in vista and asks me to select a drive but there is no drive in the systema nd I want it to lock so the script exits and the system is un secure again. same as when I log off and log on again.

Edited by Ev0lving

Share this post


Link to post
Share on other sites

Great additions to the script, I have one problem.. I am trying to use the auto Parameters with no luck, it just runs the program in vista and asks me to select a drive but there is no drive in the systema nd I want it to lock so the script exits and the system is un secure again. same as when I log off and log on again.

Sorry, for the delayed response.

For not seeing your drives listed:

The following drives cannot be written to as a keydrive:

Drives with the letters A or B; Fixed drives; and CDROM/Optical drives.

However, everything but the floppy drives will be CHECKED for a valid keyfile - this allows you to make an emergency HDD, CD, etc. if your USB ports die.

To make this short:

Please insert a removable device that shows up in My Computer as a drive letter higher than C.

THEN start USBLock in normal mode and select it from the GUI.

(NOTE: USBLock cannot check for special USB devices that do not have drive letters, such as some cameras, MP3 players, etc.)

For problems using the "auto" mode:

To use "auto" mode, it would be in your best interest to satisfy two conditions first:

1. run USBLock in normal mode and select a removable drive as your keydrive

2. make sure USBLock is compiled so that you can use auto mode

- - - the command-line will look like "USBLock.exe auto" without the quotes.

Condition number 1 is important otherwise USBLock will be trying to automatically match a nonexistant keyfile. If a keyfile is NOT existant in auto mode, you may encounter very annoying results.

If you're seeing a drive-selection window when using a parameter, then that parameter is not being passed to the program

- "auto" and the drive selection parameters force USBLock to skip initial drive selection.

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Aelc
      Hey there!
      I'm gonna try to get access to an RichEdit Control in PSPad with Autoit which is scripted with Delphi. I wrote the commands out ouf the RichEdit.au3 UDF to can change them, because it always fails or crashs, when i call it. I Just want to set the Textcolor for the RichEdit.
      It seems to be a Problem with $EM_SETCHARFORMAT... (maybe protected?) I can use e.g. $EM_SETBKGNDCOLOR or other messages with no error. Sadly it doesn't exist a message constant to just set the textcolor... This is what i already tried:
      use $EM_GETCHARFORMAT but it crashs/doesn't work too. I saw the riched20.dll is linked to GDI+ but i couldn't make something work with it... (GetDc and so on but maybe there is another way?) Tried to set some other style on it (setWindowLong) I read the MSDN about $EM_SETCHARFORMAT up and down, but i can't find any other solution.
      The RichEdit should be version 2 ( error message point to riched20.dll )
       
      Here is the PSPad that will be required for testing:
      https://autoit.de/wcf/attachment/87712-pspad4autoit3-v1-0-0-beta-without-setup-zip/
      You need to start PSPad.exe first!
      ; = Info =========================================================================================== ; Title : RichEdit_Test ; -------------------------------------------------------------------------------------------------- ; ; Version (vnots) : 0.0.1 ; Date : 2020-05-13 ; Author(s) : Aelc ; ; ================================================================================================== #include <File.au3> #include <Misc.au3> #include <Date.au3> #include <String.au3> #include <GuiListBox.au3> #include <WinAPI.au3> #include <MsgBoxConstants.au3> #include <Color.au3> #include <GuiRichEdit.au3> #include <EditConstants.au3> AutoItSetOption("MustDeclareVars", 1) RichEdit_Test_Main() Func RichEdit_Test_Main() Local $hPSPad = Null Local $tLogCtrls Local $hLB_hwnd Local $hLB_ID $hPSPad = _WinAPI_GetForegroundWindow() If Not WinExists("[CLASS:TfPSPad]") Then MsgBox ( 48,"","PSPad not found." ) Exit EndIf Sleep(1000) $hPSPad = WinGetHandle("[CLASS:TfPSPad]") ;~ If $hPSPad = Null Then ;~ MsgBox($MB_SYSTEMMODAL + $MB_ICONWARNING, 'AutoIt3_CompilerRunner: - Error -', 'No handle found for PSPad!') ;~ Exit (2) ; 2 = PSPad-hwnd not found ;~ EndIf If _WinAPI_IsClassName($hPSPad, "TfPSPad") Then ; -------------------------------------------------------------------------- If _Singleton("PSPad->RichEdit_Test " & String($hPSPad), 1) = 0 Then MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "RichEdit_Test: - Error -", _ '"RichEdit_Test" is already running') Exit EndIf ; -------------------------------------------------------------------------- $tLogCtrls = PSPad_GetLogControls($hPSPad, 'Log') $hLB_hwnd = $tLogCtrls.hWnd_ListBox $hLB_ID = $tLogCtrls.ID_ListBox If $hLB_hwnd > 0 Then _SendMessage($hLB_hwnd, 0xCF,False) ;Set $READONLY to False Local $tagCHARFORMAT_changeable = "struct;uint cbSize;long dwMask;long dwEffects;long yHeight;long yOffset;INT crTextColor;" & _ "byte bCharSet;byte bPitchAndFamily;wchar szFaceName[32];endstruct" Local $aColor[3] = [0xFF, 0x00, 0xFF] Local $nColor = _ColorSetCOLORREF($aColor) Local $tCharFormat = DllStructCreate($tagCHARFORMAT_changeable) DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat)) DllStructSetData($tCharFormat, 2, $CFM_COLOR) DllStructSetData($tCharFormat, 6, $nColor) MsgBox ( 64,"",_SendMessage($hLB_hwnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*")) Else ; Log-Fenster konnte nicht gefunden werden. MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "AutoIt3_CompilerRunner: - Error -", _ "The log window of PSPad could not be found.") Exit EndIf Else EndIf EndFunc ;==>RichEdit_Test_Main ;~ Func _RichEditGetTextLength($hWnd) ;~ If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0) ;~ Local $bChars = True ;~ Local $bExact = True ;~ Local $tGetTextLen = DllStructCreate($tagGETTEXTLENGTHEX) ;~ Local $iFlags = BitOR($GTL_USECRLF, ($bExact ? $GTL_PRECISE : $GTL_CLOSE)) ;~ $iFlags = BitOR($iFlags, ($bChars ? $GTL_DEFAULT : $GTL_NUMBYTES)) ;~ DllStructSetData($tGetTextLen, 1, $iFlags) ;~ DllStructSetData($tGetTextLen, 2, ($bChars ? $CP_ACP : $CP_UNICODE)) ;~ Local $iRet = _SendMessage($hWnd, $EM_GETTEXTLENGTHEX, $tGetTextLen, 0, 0, "struct*") ;~ Return $iRet ;~ EndFunc ;==>_RichEditGetTextLength ;~ Func _RichEditGetBKColor($hWnd) ;~ If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0) ;~ Local $iBkColor = _SendMessage($hWnd, $EM_SETBKGNDCOLOR, False, 0) ;~ _SendMessage($hWnd, $EM_SETBKGNDCOLOR, False, $iBkColor) ;~ Return $iBkColor ;~ EndFunc ;==>_RichEditGetBKColor ;~ Func _RichEditSetBKColor($hWnd, $iBkColor) ;~ If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0) ;~ _SendMessage($hWnd, $EM_SETBKGNDCOLOR, False, $iBkColor) ;~ Return $iBkColor ;~ EndFunc ;==>_RichEditSetBKColor Func PSPad_GetLogControls($_hPSPad, $_sSheetText = 'Log') Local $sStruct_LogCtrls = _ 'hwnd hWnd_PageControl;' & _ ; TPageControl 'int ID_PageControl;' & _ 'hwnd hWnd_TabSheet;' & _ ; TTabSheet 'int ID_TabSheet;' & _ 'hwnd hWnd_ListBox;' & _ ; TListBox 'int ID_ListBox;' Local $tResult = DllStructCreate($sStruct_LogCtrls) Local $aEnum Local $sSheet Local $i, $x $aEnum = _WinAPI_EnumChildWindows($_hPSPad, False) If IsArray($aEnum) Then For $i = 1 To $aEnum[0][0] If $aEnum[$i][1] = "TTabSheet" Then $sSheet = ControlGetText($_hPSPad, '', _WinAPI_GetDlgCtrlID($aEnum[$i][0])) If $sSheet = $_sSheetText Then ; TabSheet gefunden. $tResult.hWnd_TabSheet = $aEnum[$i][0] $tResult.ID_TabSheet = _WinAPI_GetDlgCtrlID($tResult.hWnd_TabSheet) $tResult.hWnd_PageControl = _WinAPI_GetParent($tResult.hWnd_TabSheet) $tResult.ID_PageControl = _WinAPI_GetDlgCtrlID($tResult.hWnd_PageControl) For $x = $i + 1 To $aEnum[0][0] If $aEnum[$x][1] = "TRichEdit" Then $tResult.hWnd_ListBox = $aEnum[$x][0] $tResult.ID_ListBox = _WinAPI_GetDlgCtrlID($tResult.hWnd_ListBox) Return $tResult ; Wenn gefunden, dann raus aus der Funktion. EndIf Next EndIf EndIf Next EndIf Return $tResult EndFunc ;==>PSPad_GetLogControls I don't have any ideas anymore  But maybe someone else has?
      I would be happy for every idea  
       
      Thanks in advance
    • By Luigi
      Greetings,
       
      Someone can help-me to translate this Python's code to AutoIt?
       
      Python (source: https://repl.it/repls/InstructiveDarkslategreyJackrabbit)
      str = 'age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!"' key = "" val = "" dict = {} parse_string = False parse_key = True # parse_val = False for c in str: print(c) if c == '"' and not parse_string: parse_string = True continue elif c == '"' and parse_string: parse_string = False continue if parse_string: val += c continue if c == ',': # terminate entry dict[key] = val #add to dict key = "" val = "" parse_key = True continue elif c == '=' and parse_key: parse_key = False elif parse_key: key += c else: val+=c dict[key] = val print(dict.items()) Python's output:
      [('phrase', "I'm cool!"), ('age', '12'), ('name', 'bob'), ('hobbies', 'games,reading')] AutoIt
      #include-once #include <Array.au3> #include <StringConstants.au3> Global $opt $opt = "estado = """" , cep = """", idade=32, nome = ""Luismar"", campo=""campo = campo""" $opt = "age=12,name=bob,hobbies=""games,reading"",phrase=""I\'m cool!""" ConsoleWrite($opt & @LF) Local $arr = StringSplit($opt, "", $STR_CHRSPLIT) Local $key = "" Local $val = "" Local $dict = ObjCreate("Scripting.Dictionary") Local $parse_string = False Local $parse_key = True Local $c For $ii = 1 To $arr[0] $c = $arr[$ii] If $c == '"' And Not $parse_string Then $parse_string = True ContinueLoop ElseIf $c == """" And $parse_string Then $parse_string = False ContinueLoop EndIf If $parse_string Then $val &= $c ContinueLoop EndIf If $c = "," Then $dict.Add($key, $val) $key = "" $val = "" $parse_key = True ContinueLoop ElseIf $c == "=" And $parse_key Then $parse_key = False ElseIf $parse_key Then $key &= $c Else $val &= $c EndIf Next $dict.Add($key, $val) ; missing this line... For $each In $dict ConsoleWrite($each & " = " & $dict.Item($each) & @LF) Next AutoIt's output
      age=12,name=bob,hobbies="games,reading",phrase="I\'m cool!" age = 12 name = bob hobbies = games,reading  
      Best regards.
       
    • By joseLB
      Hi
      I normally use HASP/sentinel dongles in executables generated in VB. It consists into "pack" the .exe and then the program only will run if the usb dongle is at the PC.
      So I packed  the AU3 .exe same way.  The image shows the message.when ran at the correct folder where the auxiliary files exists.

      But If I run it at a folder where there is no auxiliary folders, the messages shows that these files does not exists. That means that the program started ok, did a lot of things, but probably when needed floating point it was not able to load the runtime. Just remembering, VB .exe Works ok.

      Any clue?
      *PS: this "packing" was done at a Win XP virtual machine, as I do not have the program to pack it at Win7. Could that be the reason, as AU3 does not work at XP and VB Works?
      But at other hand, running at this XP machine I received the message that there is not auxiliary files at the folder... So it ran at XP...
       
      Regards
      Jose

    • By Skeletor
      Hi Virtual People, 
      I'm trying to lock my screen in Windows 10 but to no avail. 
      Has Windows 10 forbidden this feature? 
      Send("#l") Above code does not work. Even sending Ctrl Alt Del does not work nor as an Admin. 
      Note: I want to lock my screen, not log off. Thanks for been kind.
       
    • By BigMac121263
      I know that this theme was discussed several times but I read all These threats with no helping result.
      I have two pieces of TEMPer1F USB Thermometer.
      It is a Standard Windows HID device with no add. Driver needed.
      With the device I got an App reading from it and showing Graphs and much more and which can handle several devices.
      With the Software came also a RDingUSB.dll file handling the communication with the device.
      I can call the dll without any error. But the Problem is how to Access the device using the DLL and Access more than one of same VID/PID
      by Serial or anything else useful.
      I have also sources in c# doing the Job, but no experience in C# to successfuly port it to AutoIT.
       
      So my question: Can anyone help me to realize the simple pull of the temperature value from the devices based on C# source?
      The rest to write it to MySQL DB and repeat it etc. is no Problem for me.
      ***************************************
      The C# part with the DLL functions class:
      ***************************************
      using System;
      using System.Runtime.InteropServices;
      namespace TEMPer
      {
        internal class RDing
        {
          [DllImport("RDingUSB.dll")]
          public static extern IntPtr OpenUSBDevice(int VID, int PID);
          [DllImport("RDingUSB.dll")]
          public static extern IntPtr CloseUSBDevice(IntPtr hDevice);
          [DllImport("RDingUSB.dll")]
          public static extern bool WriteUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToWrite, ref ulong lpNumberOfBytesWritten);
          [DllImport("RDingUSB.dll")]
          public static extern bool ReadUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToRead, ref ulong lpNumberOfBytesRead);
          [DllImport("RDingUSB.dll")]
          public static extern ushort GetInputLength(IntPtr hDevice);
          [DllImport("RDingUSB.dll")]
          public static extern ushort GetOutputLength(IntPtr hDevice);
          [DllImport("RDingUSB.dll")]
          public static extern uint GetErrorMsg(ref string[] lpErrorMsg, uint dwErrorMsgSize);
        }
      }
      *********************************
      The C# code snippet working with the functions of the class above is in the attachment
      this is the interesting part where the data is sent and pulled which I
      do not understand to transcode to AutoIT
      Important my devices are the type2 (TEMPer1F) :
      *********************************
      So in the end I Need: Call DLL, read all devices in array
      Loop the Array until ubound(Array) and for each device in Array read the temperature value and prepare the data to
      decimal 6,1 (SQL Format) and °C
      So how to pull the value from the devices?
      Maybe somwbody finds the important part in the C#  (the code above is for different models, mine is TEMPer1F
      Or maybe someone has solved this and has maybe a uDF for this
       
       
      MainForm.cs
×
×
  • Create New...