ledigeine Posted June 11, 2012 Share Posted June 11, 2012 Ok so this project im working on is to make a UI that will let you pick a version of software then map to the drives needed based on an XML file. I have many parts already setup but now im getting to the point where i might need to run commands to a cmd prompt or as i found out theres a DriveMap function. The plans i had were to make the UI have 3 or 4 buttons: Map = check if the drive letters we use are used already, if they are clear those. The user could have the drives Mapped or Subst'd so i will have to figure out how to check for either of those. Then clear them so my mapping will go through with out issue. Clear = button will clear any thing mapped to the letters we use g/h, clearing mapped or subst'd drives. Run = this will be a button that will run an EXE from the drives that the user has hopefully mapped with out error. Exit = exits the ui Now before starting any of these i was wondering if you guys have found easy or quick ways to help me out. Luckily i found the DriveMap fuctions or id have been looking for cmdprompt stuff this whole time. Any tips on any button would be great... cept the exit.. i already got that done Link to comment Share on other sites More sharing options...
Kidney Posted June 11, 2012 Share Posted June 11, 2012 in SciTE, there is an add-on included in autoIT called Koda(FormDesigner). its located under Tools. that will get you started on the GUI. once you have the GUI setup like you want it, click the button on the top left corner of Koda that is called "Generate Code" the hot key is F9. copy all the code that was generated to your autoIT script and when you run it, the GUI should show. in the While loop, i would change the Switch case to a Select case so that way the form doesnt close after 1 button click. here is what yours might look like: While 1 $nMsg = GUIGetMsg() Select $nMsg Case $GUI_EVENT_CLOSE Or $nMsg = $btnExit Exit Case $nMsg = $btnMap _Func_Map() Case $nMsg = $btnRun _Func_Run() Case $nMsg = $btnClear _Func_Clear() EndSelect WEnd Link to comment Share on other sites More sharing options...
ledigeine Posted June 11, 2012 Author Share Posted June 11, 2012 Ahh yes thnx i never noticed that area before. I already kinda got the UI and stuff going. I will be having the map button run a new function so that will be fine. I think my issue right now is coding the checking for mapped drives then mapping and all that. I feel like its hard to believe that DriveMapGet/DriveMapAdd/DriveMapDelete will do all i need. Usually when something is too easy I end up having to go back to fix it like 9 times. Also i will need to figure out how to check for subst'd drives so i can clear them. But i havent even started researching that yet. Link to comment Share on other sites More sharing options...
BrewManNH Posted June 11, 2012 Share Posted June 11, 2012 While 1 $nMsg = GUIGetMsg() Select $nMsg Case $GUI_EVENT_CLOSE Or $nMsg = $btnExit Your code for the Select statement is wrong, that is the format for a Switch statement. Select is different, see below. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $btnExit If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
EndFunc Posted June 11, 2012 Share Posted June 11, 2012 (edited) Ok so this project im working on is to make a UI that will let you pick a version of software then map to the drives needed based on an XML file. I have many parts already setup but now im getting to the point where i might need to run commands to a cmd prompt or as i found out theres a DriveMap function. The plans i had were to make the UI have 3 or 4 buttons: Map = check if the drive letters we use are used already, if they are clear those. The user could have the drives Mapped or Subst'd so i will have to figure out how to check for either of those. Then clear them so my mapping will go through with out issue. Clear = button will clear any thing mapped to the letters we use g/h, clearing mapped or subst'd drives. Run = this will be a button that will run an EXE from the drives that the user has hopefully mapped with out error. Exit = exits the ui Now before starting any of these i was wondering if you guys have found easy or quick ways to help me out. Luckily i found the DriveMap fuctions or id have been looking for cmdprompt stuff this whole time. Any tips on any button would be great... cept the exit.. i already got that done Question.. Do you have to use G or H drive. Because like you said if the user already has it mapped you'd have to disconnect it and remap, Why not just use any available drive for your script so that way its more dynamic and it doesn't matter if they have those drives mapped already. i do this all the time with autoit. Use DriveMapAdd to map any drive, run your script then disconnect it. Example $Drive = DriveMapAdd("*", "server1c$") ;Do something with $Drive which will contain the $Drive autoit mapped. ;Example Run($Drive & "script.exe") ;Then to remove the drive use DriveMapDel DriveMapDel($Drive) ;This way you never need to know or hardcode a Drive letter. It will pick any unused drive letter. Edited June 11, 2012 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Kidney Posted June 11, 2012 Share Posted June 11, 2012 Your code for the Select statement is wrong, that is the format for a Switch statement. Select is different, see below. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $btnExit thanks for catching my error Link to comment Share on other sites More sharing options...
ledigeine Posted June 11, 2012 Author Share Posted June 11, 2012 Question.. Do you have to use G or H drive. Because like you said if the user already has it mapped you'd have to disconnect it and remap, Why not just use any available drive for your script so that way its more dynamic and it doesn't matter if they have those drives mapped already. i do this all the time with autoit. Use DriveMapAdd to map any drive, run your script then disconnect it. Example $Drive = DriveMapAdd("*", "server1c$") ;Do something with $Drive which will contain the $Drive autoit mapped. ;Example Run($Drive & "script.exe") ;Then to remove the drive use DriveMapDel DriveMapDel($Drive) ;This way you never need to know or hardcode a Drive letter. It will pick any unused drive letter. Nah i need g and h sadly, the software im trying to work with is already set to use G/H. its shared data too so if i just start changing what drive it should be looking for I would jack everybody else up. I already have .bat files that will do all this but im trying to learn to use autoit just as a hobby and I figured having autoit call a .bat file is kinda cheating myself out of learning. While im trying to learn I dont want this thing to take a year to make ha. So i post on here for help or tips mainly to avoid doing the work 4 times as i learn theres a fuction for this or that. As a lil test i tried using drivemapget to see G: while its subst'd and it just comes back blank. I might have to jump out to a CMD with it to clear those. Link to comment Share on other sites More sharing options...
jdelaney Posted June 11, 2012 Share Posted June 11, 2012 If Not DriveMapGet("G:") = $sDriveMap Then DriveMapDel("G:") If Not DriveMapAdd("G:", $sDriveMap, 8) Then MsgBox(4096, "Map G:", "Unable to Map: " & $sDriveMap) EndIf the above works for me ledigeine 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
ledigeine Posted June 11, 2012 Author Share Posted June 11, 2012 Ok thats kinda what i was thinking id do, maybe aslo have something before adding the drive to clear g/h subst drives as well. Not even check for them just clear g/h each time. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now