
8daysaweek.co.uk
Members-
Posts
18 -
Joined
-
Last visited
Everything posted by 8daysaweek.co.uk
-
Change Button Colour?
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt GUI Help and Support
OK, thanks for the reply anyway -
Is it now possible to change the colour of a button (preferably background but otherwise text)? I can change the font, bold etc, but can't find a way to change the colour. I tried modifying the provided label colour change code... #include <GUIConstants.au3> GUICreate("My GUI color text"); will create a dialog box that when displayed is centered GUICtrlCreateButton ("my Red label", 10,20) GUICtrlSetColor(-1,0xff0000); Red GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend ...but that doesn't work TIA,
-
Hi vollyman, It's just a code fragment, the variable was declared earlier. I am using a Beta, not sure if it's the latest... 3.1.1.79 on the help files? Coincidentally I just finished the code today, (I spoke too soon before when I said "it works" I managed to find quite a few bugs when testing) here is some of it (it carries on in the same fashion )... $__msgbox = MsgBox ( 4, 'Startup Programs', 'Do you want to STOP all programs from starting?', 30 ) if ( $__msgbox = 6 ) then $var = "none" Else $sleepA = IniRead("sleep.ini", "Prompt1", "sleep", "10000") ;MsgBox(4096, "Result", $sleepA) Sleep($sleepA) $__msgbox = MsgBox ( 4, 'Startup Some Programs', 'Do you only want to start SOME programs?', 10 ) if ( $__msgbox = 6 ) then $var = "some" Else $var = "all" $sleepB = IniRead("sleep.ini", "Prompt2", "sleep", "10000") ;MsgBox(4096, "Result", $sleepB) Sleep($sleepB) EndIf EndIf ;MsgBox(4096,"Var", $var) If $var = "none" then Exit Else Const $workingDir = @WorkingDir ;------------------------- ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("P1Program1\*.lnk") FileChangeDir("P1Program1") ; Check if the search was successful If $search <> -1 Then While 1 $file1 = StringTrimRight(FileFindNextFile($search), 4) ;MsgBox(4096, "File:", $file1 ) If @error Then ExitLoop $details1 = FileGetShortcut($file1) ;MsgBox(4096, "Details:", $details1[0] ) $path1 = $details1[0] ;MsgBox(0, "Path:", $path1 ) If ( $var = "all" ) then $sleep1 = IniRead("sleep.ini", "P1Program1", "sleep", "10000") ;MsgBox(4096, "Result", $sleep1) Sleep($sleep1) Run ( $path1 ) FileChangeDir($WorkingDir) ExitLoop Else If ( $var = "some" ) then $__msgbox = MsgBox ( 4, "Start Program 1", "Do you want to start" &@LF&@LF& $file1 ) If NOT ( $__msgbox = 7 ) then Run ( $path1 ) EndIf FileChangeDir($WorkingDir) ExitLoop EndIf EndIf WEnd Else ;MsgBox(0, "Error", "No files/directories matched the search pattern (1)") FileChangeDir($WorkingDir) ; Close the search handle FileClose($search) EndIf ;------------------------- ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("P1Program2\*.lnk") FileChangeDir("P1Program2") ; Check if the search was successful If $search <> -1 Then While 1 $file2 = StringTrimRight(FileFindNextFile($search), 4) If @error Then ExitLoop $details2 = FileGetShortcut($file2) $path2 = $details2[0] If ( $var = "all" ) then $sleep2 = IniRead("sleep.ini", "P1Program2", "sleep", "10000") Sleep($sleep2) Run ( $path2 ) FileChangeDir($WorkingDir) ExitLoop Else If ( $var = "some" ) then $__msgbox = MsgBox ( 4, "Start Program 2", "Do you want to start" &@LF&@LF& $file2 ) If NOT ( $__msgbox = 7 ) then Run ( $path2 ) EndIf FileChangeDir($WorkingDir) ExitLoop EndIf EndIf WEnd Else ;MsgBox(0, "Error", "No files/directories matched the search pattern (2)") FileChangeDir($WorkingDir) ; Close the search handle FileClose($search) EndIf ;------------------------- I imagine that there might be a much "cleaner" way of doing it, but this is working for me ...so far BFN,
-
Thanks for the tip MHz. Here is my correct code (that works ): Const $workingDir = @WorkingDir ;------------------------- ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("Program1\*.lnk") FileChangeDir("Program1") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file1 = StringTrimRight(FileFindNextFile($search), 4) ;MsgBox(4096, "File:", $file1 ) If @error Then ExitLoop $details1 = FileGetShortcut($file1) ;MsgBox(4096, "Details:", $details1[0] ) $path1 = $details1[0] ;MsgBox(0, "Path:", $path1 ) If ( $var = "all" ) then Sleep(2000) Run ( $path1 ) FileChangeDir($WorkingDir) ExitLoop Else If ( $var = "some" ) then $__msgbox = MsgBox ( 4, "Start Program 1", "Do you want to start" &@LF&@LF& $file1 ) If NOT ( $__msgbox = 7 ) then Run ( $path1 ) FileChangeDir($WorkingDir) ExitLoop EndIf EndIf EndIf WEnd ; Close the search handle FileClose($search) No, that's what is strange different shortcuts in exactly the same folder (i.e. Program1) behaved differently. Not sure why, but the above is working now, so thanks very much BFN,
-
I'm trying to create a script that allows a user to run any file by dropping a shortcut (.lnk) to it into a predefined folder. ;------------------------- ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("Program1\*.lnk") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file1 = StringTrimRight(FileFindNextFile($search), 4) MsgBox(4096, "File:", $file1 ) If @error Then ExitLoop $details1 = FileGetShortcut($file1) MsgBox(4096, "Details:", $details1 ) $path1 = $details1[0] MsgBox(0, "Path:", $path1 ) If ( $var = "all" ) then Sleep(2000) Run ( $path1 ) Else If ( $var = "some" ) then $__msgbox = MsgBox ( 4, "startup program 1", "Do you want to start" &@LF&@LF& $file1 ) If NOT ( $__msgbox = 7 ) then Run ( $path1 ) ExitLoop EndIf ExitLoop EndIf EndIf WEnd ; Close the search handle FileClose($search) ;------------------------- The strange thing is, this works with some shortcuts, but not with others, and I have no idea why. Depending on the shortcut I copy into the folder, either 1) everything works correctly or 2) I get the error: Line 18 (File "<file path here.au3") $path1 = $details1[0] $path1 = $details1^ERROR Error: Subscript used with non-Array variable. I realize there may be many improvements that could be made to this code, but mostly I'd like to know why this works with some shortcuts but not with others? TIA,
-
I have searched and found some possible solutions but they don't seem as simple as they *should*? I'd like to be able to create a button which will eject a CD tray. I know about CDTray ( "drive", "status" ) but the problem is I don't know what the CD drive letter will be on each different machine. I'm working on a solution using DriveGetDrive( "CDROM" ) and If FileExists () as I don't want the wrong tray to be ejected if there is more than one CD drive on a computer. However, as the script will be run from the CD drive, I thought there might be a way to just find the current drive's letter, then use it in CDtray(). TIA ,
-
Run exe program from button
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt GUI Help and Support
Ron, that's great, thank you. I'm understanding it better now. I've also found out how to insert labels, format the text and open a URL from a button, so things are looking up BFN, -
Run exe program from button
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt GUI Help and Support
Yep saves screwing something up in the typing I started with the imagebutton.au3 example and pasted in mr_carter's suggested code above. Thanks for the tip, it works now. I tried repeating the code... While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run("pathtofile1.exe") Case Else ;;; EndSelect While 2 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button2 Run("pathtofile2.exe") Case Else ;;; EndSelect...for each additional button, but it doesn't work. I obviously don't understand what's going on with it yet. If someone could let me know how to add second and thrid buttons etc, I *should* be able to run with it from there. BFN , -
Run exe program from button
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt GUI Help and Support
Thanks for replying mr_carter. This is what I have now, but the menu no longer appears ; AutoIt 3.1.1 #include <GuiConstants.au3> ; GUI GuiCreate("Menu", 400, 380) GuiSetIcon("Icon1.ico", 0) ; PIC GuiCtrlCreatePic("pic.jpg", 75, 10, 250, 87) ; BUTTONS $button1 = GUICtrlCreateButton ("1", 30,120,40,40,$BS_ICON) GUICtrlSetImage (-1, "Icon2.ico",-1) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run("pathtofile.exe") Case Else ;;; EndSelect WEnd ; GUI MESSAGE LOOP GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd -
This is my first experiment with an AutoIt GUI. I want to create a menu with buttons that, when clicked, start an executable file. Sounds simple. I have created the menu quite easily, but I can't find out how to associate the buttons with the exe to run when clicked. I have searched for a couple of hours before posting, but it's been a long day! If someone could give me some example code that I can work with I would appreciate it. Here's what I have so far: #include <GuiConstants.au3> ; GUI GuiCreate("Menu", 400, 380) GuiSetIcon("Icon1.ico", 0) ; BUTTONS $button1 = GUICtrlCreateButton ("1", 30,120,40,40,$BS_ICON) GUICtrlSetImage (-1, "Icon2.ico",-1) TIA,
-
Refresh Desktop?
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt General Help and Support
Great I'll put that in instead. Come to think of it, I don't know! I'll take it out - thanks -
Refresh Desktop?
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt General Help and Support
OK, I have a solution of sorts: ; Send Windows +D to show desktop Send("#d") ; Send Windows +F5 to refresh Send("#{F5}") If anyone has a more elegant solution I'd be interested -
Before I start, I apologise if this has been answered before - I couldn't find it I have a very simple script which: Copies a file to a folder and overwrites the file already there.Deletes the existing shortcut to it on the desktop.Creates a new shortcut (with a new name) on the desktopMy problem is that, although the existing shortcut has been deleted, it isn't removed from the desktop until I right-click > Refresh (WinXP Pro). Is there a way of doing a Desktop Refresh in AutoIt? TIA
-
Background Colour
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt General Help and Support
Thanks scriptkitty, I think I will put it into the idea lab, but your post has made me realize another solution I can simply type the text I want into Paint or another image editor / wordprocessor (screen print if necessary) and use SplashImageOn to display it, then I can give it whatever bgcolour I want. This will be the easiest for me to get what I want done quickly, however I'm sure I'll learn from your code for opening html files. Thanks m8 -
Background Colour
8daysaweek.co.uk replied to 8daysaweek.co.uk's topic in AutoIt General Help and Support
I'd like to be able to colour each successive Text Box with a different colour. Any thoughts? -
Is it possible to change the background colour of a text popup window (SplashTextOn) ?