Jump to content

Loduwijk

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Loduwijk

  1. Thank you, and sorry I cluttered the forum with something that was answered in a FAQ.
  2. I would have thought others would have asked about something similar before, but I can't seem to find anything about making an AutoIt exe delete itself after execution (then again, my searching skills are far under average). At the computers where I work, we use an ugly program called CleanSlate to reset the state of the computer after users are done with them so that they can not make any undesirable changes to them. Obviously, this means it gets in the way when we actually want to change things; so we have to turn CleanSlate off first, reboot after changes, then turn it back on. And that is what part of the scripts in question are supposed to do. I wanted the main script to copy "cson.exe" (stands for "clean slate on") to the all-users startup folder, then simulate a windows key then "u" so I just have to walk around the room and select "reboot" on each computer after everything is done. Then, when cson.exe runs, since it is in startup, I want it to turn CleanSlate back on then delete itself. When testing cson.exe, it wouldn't delete itself, which makes sense since the account it's run under doesn't have permission to modify the all-users folders. To get around the permissions, I tried using RunAsSet to make it use my account. ... RunAsSet("myUserName", "theDomain", "myPassword", 2) Run(@ComSpec & " /c " & 'del "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\cson.exe"', "", @SW_HIDE) I also tried that with the last argument to RunAsSet being 1. In both instances, it failed to delete cson.exe. I haven't added the part to the main script which copies cson.exe to the startup folder yet; for now I'm just manually placing it there. I assume, however, that getting it to place the file there should fail the same as deleting it, so this will also help me solve that problem when I get there. Thanks in advance for any insight.
  3. I decided to just go ahead and make a function to convert a keycode into an appropriate text string for use with Send. I thought I'd post it here in case anyone else searches the forum for posts on the same topic like I did before I posted. I might as well save them some time. This is Visual Basic code to convert a keyboard keycode into a text string representative of AutoIt's Send function's required text string. I left shift, alt and ctrl out on purpose because I handle them seperately in my program, but you can easily add them in too. The key codes for shift, ctrl and alt, respectively, are 16, 17 and 18. (There, I just editted that code to use a case structure instead. 'Twas silly of me to just use a huge tree of if statements.) Private Function KeyCode2Char(KeyCode As Integer) As String Select Case KeyCode Case 8 KeyCode2Char = "{backspace}" Case 9 KeyCode2Char = "{tab}" Case 13 KeyCode2Char = "{enter}" Case 20 KeyCode2Char = "{capslock toggle}" Case 32 KeyCode2Char = "{space}" Case 33 KeyCode2Char = "{pgup}" Case 34 KeyCode2Char = "{pgdn}" Case 35 KeyCode2Char = "{end}" Case 36 KeyCode2Char = "{home}" Case 37 KeyCode2Char = "{left}" Case 38 KeyCode2Char = "{up}" Case 39 KeyCode2Char = "{right}" Case 40 KeyCode2Char = "{down}" Case 45 KeyCode2Char = "{ins}" Case 46 KeyCode2Char = "{del}" Case 106 KeyCode2Char = "{numpadmult}" Case 107 KeyCode2Char = "{numpadadd}" Case 109 KeyCode2Char = "{numpadsub}" Case 110 KeyCode2Char = "{numpaddot}" Case 111 KeyCode2Char = "{numpaddiv}" Case 144 KeyCode2Char = "{numlock toggle}" Case 145 KeyCode2Char = "{scrolllock toggle}" Case 186 KeyCode2Char = ";" Case 187 KeyCode2Char = "=" Case 188 KeyCode2Char = "," Case 189 KeyCode2Char = "-" Case 190 KeyCode2Char = "." Case 191 KeyCode2Char = "/" Case 192 KeyCode2Char = "`" Case 219 KeyCode2Char = "{" Case 220 KeyCode2Char = "\" Case 221 KeyCode2Char = "}" Case 222 KeyCode2Char = "'" Case Else If KeyCode >= 48 And KeyCode <= 57 Then KeyCode2Char = KeyCode - 48 If KeyCode >= 65 And KeyCode <= 90 Then KeyCode2Char = Chr(KeyCode + 32) If KeyCode >= 96 And KeyCode <= 105 Then KeyCode2Char = "{numpad" & KeyCode - 96 & "}" If KeyCode >= 112 And KeyCode <= 123 Then KeyCode2Char = "{F" & KeyCode - 111 & "}" End Select End Function
  4. Thank you, but I am looking to use key codes, not ascii codes. I said that, but perhaps the way I said so wasn't clear enough. Where an ASCII code is the way a character is represented in memory on on disk, a key code is the representation of the key you press to perform a certain action. For example, the ASCII code for "a" is 97, but the key code 97 is for the "1" on the numpad. Every key on the keyboard has assigned its own keycode, even the keys which have nothing to do with ASCII, such as the arrow keys (Left, up, right, down being key codes 37, 38, 39 and 40, respectively, whereas those ASCII numbers are for &, ', ( and )). I hope that clears it up, though I am doubting now that AutoIt supports key codes, which would be odd since key codes have more to do with sending window messages than ASCII does.
  5. I am wondering if there is any way to tell the Send function to send a keystroke for the key specified by a certain keycode, similar to the way you can specify ASCII codes. I am using the AutoIt DLL in VB to make a program that I can use to control any of the computers on my network from any of the other computers on it. I am simply using the main form's KeyDown event to send the keystrokes across the network to the other computer's running instance of the program which will then execute the same keystroke. The KeyDown event obviously specifies the key code to the key pressed. So basically, what I'm looking to do is something like Send("{KEYCODE N}"), where N is the keycode from 0 to 255, so that I can execute a variable keystroke. If there's no way to do this, I'll just have to write a function that takes a keycode and generates the text string required to pass to Send. It would be nice if there's a way to just specify a variable keycode though. Thanks ahead of time.
  6. Yes, I have it set to look for system files too. odd Either way, I looked over the source in that demo you found, and after messing with the demo for a while I realised VB now has AutoIt in with the stuff you can include in the Project|References menu; the AutoIt installation must have put it there without my knowing. That makes it easy enough. At least it works now. Thanks much.
  7. I've been searching all over, but there doesn't seem to be enough documentation on using AutoIt as a DLL in other languages. The little documentation there is in the AutoItX help file is for C, in which the nice header file takes care of everything for you. And, oddly, the forum search feature here won't let me search for vb because it doesn't like the length of the accronym. I'm using VB for my current project, and it can't seem to find the required dll file. I ran a search for autoit files on my computer, and I was surprised to see that there aren't any. How do I use the AutoIt DLL functions in VB? Thanks ahead of time for any help.
×
×
  • Create New...