Jump to content

w00blyn

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by w00blyn

  1. Hello Thanks for the UDF! It's very nice to be able to talk Autoit with my Arduino. I'm having one small problem perhaps someone could help with. My Arduino program listens for a command over the serial port (numbers 0-9), switches the corresponding relay on my circuit board, sends a confirmation (1 hi), then switches it off when it recieves a different command (letters A-H) and confirms (1 lo). Everything was working great when I was using Autoit to initiate the sequence (using a button). I've since added a button on my circuit board which sends the command "go" to Autoit over the serial bus. Once I've added the bit of code to listen for serial command, none of my buttons in the GUI work anymore. If (_CommSetPort (5, $setport_error, 9600, 8, 0, 1, 0)) <> 1 Then MsgBox (0, $t, "SetPort error: " & $setport_error) Fin () EndIf Sleep (2000) _Main () Func _Main () ;gui GUICreate ($t, 800, 600) ;main window For $e = 0 To 9 ;creates a matrix of labels and buttons If $e = 0 Then $x = 25 If $e = 5 Then $x = 645 If $e < 5 Then $y = 250 if $e >= 5 Then $y = 25 $lbl[$e] = GUICtrlCreateLabel ("", $x, $y, 130, 200, $WS_BORDER) $btn[$e] = GUICtrlCreateButton ("", $x, $y, 130, 200, $WS_BORDER) GUICtrlSetState ($lbl[$e], $GUI_HIDE) IF $e < 5 Then $x = $x + 155 If $e >= 5 Then $x = $x - 155 Next $btn_program = GUICtrlCreateButton ("Program All", 25, 466.725, 750, 100) GUICtrlSetFont (-1, 32) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Fin () Case $m_exit Fin () Case $btn_program _Start () Case $btn[0] _Program (0) Case $btn[1] _Program (1) EndSwitch $inn = _CommGetLine (@CR, 0, 0) If StringInStr ($inn, "go") <> 0 Then _Start () EndIf WEnd EndFunc I've also tried putting the _CommGetLine into the Case Else of my GUI loop but it doesn't work either. With the code, my hardware button works to initiate _Start (), but not my GUI buttons. Any ideas? Sorry if this is off topic, I do not mean to jack your thread and I'd be happy to start a new thread if you'd like. Thanks!
  2. Cool! Thanks man, didn't know about that function. Neat.
  3. Yup, simple solution. Muaha. CODE$entries = IniReadSectionNames ($ini) For $e = 1 to $entries[0] $usr = IniRead ($ini, "User" & $e, "username", "") $pwd = IniRead ($ini, "User" & $e, "password", "") $grp = IniRead ($ini, "User" & $e, "group", "Users") $aut = IniRead ($ini, "User" & $e, "autologon", "False") AddUser ($usr, $pwd, $grp, $aut) Next Func AddUser ($user, $pass, $group, $auto) RunWait(@Comspec & " /c net user " & $user & " " & $pass & " /add") RunWait(@Comspec & " /c net localgroup " & $group & " " & $user & " /add") RunWait(@Comspec & " /c net accounts /maxpwage:unlimited") If $auto = True Then RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName","REG_SZ", $user) RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword","REG_SZ", $pass) RegWrite ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon","REG_SZ", "1") EndIf EndFunc
  4. Hello I'm trying to make a script to add users during my winxp unattended install. Inside the $OEM$ there's a userinfo.ini file which looks something like this: CODE[user1] username=Me! password=**** group=Administrators autologon=True [user2] username=Somebody Else password=**** group=Users autologon=False In my script, I'm trying to generate variables according to how many users are entered in the ini. This part is tricking me: CODE$entries = IniReadSectionNames ($ini) For $e = 1 to $entries[0] $usr & $e = IniRead ($ini, "User " & $e, "username", "") msgbox (1, "bah", $usr) Next My plan is to read the section names, and for each 'user1', 'user2' section, create corresponding variables $usr1, $usr2. I can't figure out how to use the array number ($e) inside my variable name. I'm sure the solution is simple, it always seems to be in after thought.. Thanks!
  5. this'll work: dir *.ini /b >profiles.txt then just FileReadLine Thanks dude, I never knew of the dir /b before.
  6. yeah, just like dir /b. is there a file.au3 like the one your talking about? sounds like it'd work.
  7. Ahoy! This took me 6 hours last night and 4 more today, brutal I know, but its my first "real" script. All it does is start a timer when windows starts, then start shortcuts one by one with a countdown between each. I'd normally use WinWait, but my friend wants something easy to use. And I had trouble getting WinWait to work with Gigastudios. I'd like to add a gui that can scan the profiles directory then show each *.ini in a combo box so the user can choose which one to use at startup. Maybe even allow editing of each. For now its just a bunch of input boxes, quick 'n dirty. Can I do a GetFileLongName with *.ini somehow? Return an array that's got each filename from the folder? Haven't done anything with arrays yet, maybe someone can steer me the right way. One more quick question, does #include <GUIConstants.au3> scan the scriptdirectory for the file as well as the autoit install folder? Or does it add the guiconstants to the exe when it compiles, so it doesn't really have to look anywhere for it? Heres my scripts: autorun.au3 #include <GUIConstants.au3> opt("GUIOnEventMode", 1) ;variables $profile = IniRead(@ScriptDir & "\" & "autorun.ini", "Options", "Profile", "default") $time = IniRead(@ScriptDir & "\" & $profile & ".ini", "Options", "Countdown", "15") $launch = 0 $debug = 0 ;controls $form = GUICreate("Launch Software in:", 200, 125, -1, -1, "", $WS_EX_TOPMOST) $progress = GUICtrlCreateProgress(10, 10, 180, 20, "") $label = GUICtrlCreateLabel("", 10, 40, 180, 20, $SS_CENTER) ;buttons $cancel = GUICtrlCreateButton("Cancel", 120, 60, 60, 30) GUICtrlSetOnEvent($cancel, "Done") $pause = GUICtrlCreateButton("Pause", 20, 60, 60, 30) GUICtrlSetOnEvent($pause, "Pause") ;---initiate the countdown GUISetState(@SW_SHOW) $msg = GUIGetMsg() While $launch = 0 For $s = $time To 0 Step - 1 GUICtrlSetData($label, "Launch in " & $s & "...") GUICtrlSetData($progress, (1 - $s / $time) * 100) Sleep(1000) Next Call("Launch") WEnd ;---launch shortcut Func Launch() Do $launch = $launch + 1 $appcount = IniRead(@ScriptDir & "\Profiles\" & $profile & ".ini", "Options", "AppCount", "1") $title = IniRead(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $launch, "Title", "default") $cycles = IniRead(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $launch, "Cycles", "1") $sleep = IniRead(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $launch, "Sleep", "1") GUICtrlSetData($label, $title) Sleep(1000) Do $cycles = $cycles - 1 If FileExists(@ScriptDir & "\Shortcuts\" & $title & ".lnk") Then Run(@ComSpec & " /c Start Shortcuts\" & $title, "", @SW_HIDE) Else If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(48, "AutoRun", "Cannot find shortcut! Skipping...", 2) Select Case $iMsgBoxAnswer = -1 Case Else EndSelect EndIf For $s = $sleep To 0 Step - 1 GUICtrlSetData($label, $title & " will finish in " & $s) GUICtrlSetData($progress, (1 - $s / $sleep) * 100) Sleep(1000) Next GUICtrlSetData($label, $title & " is finished...") Sleep(1000) Until $cycles < 1 Until $launch >= $appcount Call("Done") EndFunc ;==>Launch ;---pause Func Pause() MsgBox(262192, "Software Launch", "Paused!") EndFunc ;==>Pause ;---exit Func Done() GUICtrlSetData($label, "Done!") Sleep(1000) Exit EndFunc ;==>Done configmaker.au3 #include <GUIConstants.au3> opt("GUIOnEventMode", 1) $ap = 0 Dim $iMsgBoxAnswer, $sInputBoxAnswer, $cd, $a ;create profile $iMsgBoxAnswer = MsgBox(1, "AutoRun", "Would you like to create a new profile?") Select Case $iMsgBoxAnswer = 1;OK Case $iMsgBoxAnswer = 2;Cancel done("OK, ") EndSelect ;---name profile $sInputBoxAnswer = InputBox("Profile", "Please name your profile:", "default", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid $profile = $sInputBoxAnswer Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect ;---find countdown $sInputBoxAnswer = InputBox("AutoRun", "How many seconds should the initial countdown be?", "10", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid _countdown($sInputBoxAnswer) Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect ;---find appcount $sInputBoxAnswer = InputBox("AutoRun", "How many *different* programs would you like to run?", "1", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid $appcount = ($sInputBoxAnswer) _appcount($sInputBoxAnswer) Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect ;---start adding info While $ap < $appcount $ap = $ap + 1 ;---find title $sInputBoxAnswer = InputBox("AutoRun", "Enter the title for shortcut number " & $ap, "default", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid _title($iMsgBoxAnswer) Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect ;---find cycles $sInputBoxAnswer = InputBox("AutoRun", "How many times would you like that program to run?", "1", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid _cycles($iMsgBoxAnswer) Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect ;---find sleep $sInputBoxAnswer = InputBox("AutoRun", "How many seconds should we wait for this program to finish loading?", "1", " M", "-1", "-1", "-1", "-1") Select Case @error = 0;OK - The string returned is valid _sleep($iMsgBoxAnswer) Case @error = 1;The Cancel button was pushed done("Cancelled, ") Case @error = 3;The InputBox failed to open done("Something went wrong, ") EndSelect WEnd done("Finished, ") ;---set countdown Func _countdown($cd) IniWrite(@ScriptDir & "\Profiles\" & $profile & ".ini", "Options", "Countdown", $cd) EndFunc ;==>_countdown ;---set appcount Func _appcount($a) IniWrite(@ScriptDir & "\Profiles\" & $profile & ".ini", "Options", "AppCount", $a) EndFunc ;==>_appcount ;---set title Func _title($t) IniWrite(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $ap, "Title", $t) EndFunc ;==>_title ;---set cycles Func _cycles($c) IniWrite(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $ap, "Cycles", $c) EndFunc ;==>_cycles ;---set sleep Func _sleep($s) IniWrite(@ScriptDir & "\Profiles\" & $profile & ".ini", "App" & $ap, "Sleep", $s) EndFunc ;==>_sleep ;---quit Func done($d) $iMsgBoxAnswer = MsgBox(0, "AutoRun", $d & "exiting...", 1) Select Case $iMsgBoxAnswer = -1;Timeout Exit Case Else ;OK Exit EndSelect EndFunc ;==>done Suggestions are very much appreciated AutoRun.rar
×
×
  • Create New...