Jump to content

MrYonG

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by MrYonG

  1. because i didn't post the hole script here...only the part that was giving me problems. so i am even more confused now... this part of the script works (the url's get writen to a txt file) all i want to do is read the .txt file and chose a url at random to be opened. this looks nice !! and thank you for this: #include <file.au3> Dim $aSite If Not _FileReadToArray("url.txt",$aSite) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf $x = Random(1, $aSite[0], 1) ShellExecute( $aSite ) But it somehow does not work ... at first i got the "Error reading file to Array" and then the shellexecute didnt open the url's, basically it just took me to the fodler that contained the .txt file (same folder as the script) ... if their is another way of doing this please let me know...i am new to scripting
  2. hey hey, i had a problem with it always giving me, the error message: error reading file to array...i have now sorted that, but it just opens up the location of the .txt file...it does not open the url's from within... any sugestions? ; Save Links to Text file FileWrite("url.txt", $var1 & @CRLF) FileWrite("url.txt", $var2 & @CRLF) FileWrite("url.txt", $var3 & @CRLF) FileWrite("url.txt", $var4 & @CRLF) FileWrite("url.txt", $var5 & @CRLF) #include <file.au3> Dim $aSite If Not _FileReadToArray("url.txt",$aSite) Then MsgBox(4096,"Error", " Error reading file to Array error:" & @error) Exit EndIf $x = Random(1, $aSite[0], 1) ShellExecute( $aSite ) EDIT*** i just looked over it again and i realised i am missing the function for _FileReadToArray ... any help for that would be nice im kinda new to autoit and dont know what to do?
  3. THANX ALOT, Spammer! That did the trick !
  4. Hello, i was wondering how i would go about opening a random URL from a predefined list? i am trying to create a small game for the kids, where they have a question and they have to find out the answer (finish the story) from the pages that open...but i need all the pages to be at random, so they need to work out which part comes first, second, third...etc. the code i use to open the URL is and to close the browser: shellexecute("THE URL") If ProcessExists("firefox.exe") Then ProcessClose("firefox.exe") endif is it possible to creaet like a shellexecute("$random") and then add my url's as a ranodm variables? or would it be better to add each script with URL / porcessclose and randomly pick which "url" to open? all help much appreciated MrYonG
  5. memphist0, i was just about to go to bed as its 4am here...but needed to post this. if your screen resolution is already is 1024x768 ... nothing will change. edit this part of the script to get your desired resolution during the running of the script ; Define screen resolution $Width = 1024 $Height = 768 $BitsPerPixel = 32 $RefreshRate = 85 ; Define and set resolution _ChangeScreenRes(1024,768,32,85) and the rest will change your resolution back to what is was before your ran it.
  6. winXP pro ... running with out an issue. download my last .au3 file as it might have something to do with the copy paste...
  7. I wish i could help, i just started with auto it 4days ago...but i hope in time i will be able to repay the help i have received. but: try running as administrator ... or try searching for "run as admin" im sure their is a script you can add to the start...
  8. haha, makes sense danwilli ... *is happy red faces are not visible via forums* ok so when i remove the function on the part where i want to change back to the resolution stored in the .ini file the error is gone ! HATS OFF to danwilli + saywell ... you saved me MANY grey hairs ... haha to anyone interested: Attached is the working script working.au3
  9. I fixed my problem but my script wont run now. this is the error im getting: C:Documents and SettingsMrYonGDesktopTEST.au3 (86) : ==> Duplicate function name.: Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh) ; Save screen resolution IniWrite("RESsave.ini","Width","Default",@DesktopWidth) IniWrite("RESsave.ini","Height","Default",@DesktopHeight) IniWrite("RESsave.ini","Depth","Default",@DesktopDepth) IniWrite("RESsave.ini","Refresh","Default",@DesktopRefresh) ; Define screen resolution $Width = 1024 $Height = 768 $BitsPerPixel = 32 $RefreshRate = 85 ; Define and set resolution _ChangeScreenRes(1024,768,32,85) Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $HWND_BROADCAST = 0xffff Local Const $WM_DISPLAYCHANGE = 0x007E If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) If @error Then $B = 0 SetError(1) Return $B Else $B = $B[0] EndIf If $B <> 0 Then DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) DllStructSetData($DEVMODE, 4, $i_Width, 2) DllStructSetData($DEVMODE, 4, $i_Height, 3) DllStructSetData($DEVMODE, 4, $i_BitsPP, 1) DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5) $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) If @error Then $B = -1 Else $B = $B[0] EndIf Select Case $B = $DISP_CHANGE_RESTART $DEVMODE = "" Return 2 Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" SetError(1) Return $B EndSelect EndIf EndFunc ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: sleep (3500) ;THE SLEEP FUNCTION IS SIMULATING MY SCRIPT ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: $DRW = IniRead("RESsave.ini","Width","Default",@DesktopWidth) $DRH = IniRead("RESsave.ini","Height","Default",@DesktopHeight) $DD = IniRead("RESsave.ini","Depth","Default",@DesktopDepth) $DR = IniRead("RESsave.ini","Refresh","Default",@DesktopRefresh) ; Define and set resolution _ChangeScreenRes($DRW,$DRH,$DD,$DR) Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh) Local Const $DM_PELSWIDTH = 0x00080000 Local Const $DM_PELSHEIGHT = 0x00100000 Local Const $DM_BITSPERPEL = 0x00040000 Local Const $DM_DISPLAYFREQUENCY = 0x00400000 Local Const $CDS_TEST = 0x00000002 Local Const $CDS_UPDATEREGISTRY = 0x00000001 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $HWND_BROADCAST = 0xffff Local Const $WM_DISPLAYCHANGE = 0x007E If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]") Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE)) If @error Then $B = 0 SetError(1) Return $B Else $B = $B[0] EndIf If $B <> 0 Then DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5) DllStructSetData($DEVMODE, 4, $i_Width, 2) DllStructSetData($DEVMODE, 4, $i_Height, 3) DllStructSetData($DEVMODE, 4, $i_BitsPP, 1) DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5) $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) If @error Then $B = -1 Else $B = $B[0] EndIf Select Case $B = $DISP_CHANGE_RESTART $DEVMODE = "" Return 2 Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" SetError(1) Return $B EndSelect EndIf EndFunc
  10. ummm ok so saving resolutions etc in the .ini works perfect but when i want to revert back to the resolution i had the script...nothing why does this not work?? ; Define screen resolution $Width = IniRead("RESsave.ini", "Width","",@DesktopWidth) $Height = IniRead("RESsave.ini", "Height","",@DesktopHeight) $BitsPerPixel = IniRead("RESsave.ini", "Depth","",@DesktopDepth) $RefreshRate = IniRead("RESsave.ini", "Refresh","",@DesktopRefresh) ; Define and set resolution _ChangeScreenRes($Width, $Height, $BitsPerPixel, $RefreshRate) the script continues but this is the part that is not working i dont get an error or anything, it simple runs without changing the screen resolution im confused
  11. Thank you saywell !! this indeed saves the information before anything is changed !! tested and confirmed ! the code: IniWrite("RESsave.ini","Height","",@DesktopHeight) IniWrite("RESsave.ini","Width","",@DesktopWidth) IniWrite("RESsave.ini","Depth","",@DesktopDepth) IniWrite("RESsave.ini","Refresh","",@DesktopRefresh) and i guess i just change Iniwrite with IniRead to get the info out of the inifile...now i just have to play around with how to get it into the script from their (yes im new to autoit ) thanx for the help and i hope i dont need to waste your time any more with the last bit i mentioned . peace and love all !!
  12. @danwilli, thnx for the welcome and reply . I already have the script to change desktop res + frequency. It is step 1 and 4 i am mainly having problems with. Is their a way of detecting the current display resolution and have autoit save it so that i can revert back to it at a later point in the script. The reason for this is i am using send key commands which fail if the screen resolution is different then what i use to write the script ( 1024x768 at the moment). I can think of 1 way around it ...but that would mean a massive script: if screen resolution is 800x600 then run the script for 800x600 (so it would go from 800x600 > 1024x768 > 800x600) and do this for every screen resolution ...as you can imagine a horrible mess and massive size . help much appreciated the code i have so far: saveCHANGErunBACK.au3
  13. I was wonding if some one could help me out with a code that will: 1. Save the current Screen Resolution + refresh rate. 2. Change to 1024x768 and a refresh rate of 75 3. Run a part of my Autoit script. 4. revert back to the saved screen resolution + refresh rate. I have only found scripts that will change the screen resolution, but, which is saddly only a part of what i need. thank you in advance !! MrYonG
×
×
  • Create New...