
danielmohr91
Active Members-
Posts
45 -
Joined
-
Last visited
About danielmohr91
- Birthday June 23
danielmohr91's Achievements

Seeker (1/7)
0
Reputation
-
Ha he. Thanks man. Wow, I feel like an idiot. I've been teaching myself JAVA and C++, and now coming back to AutoIt is the most unnatural thing. I keep mixing up the syntax. Things like declaring types for variables, and putting a semi-colon after every line lol. Thanks SO much for your help
-
I'm terribly confused. I've got a simple "for" loop. I changed the increment to .1, and suddenly the loop never counts up to the max. For example, For $i = 0 To $i = 100 Step .1 ConsoleWrite($i & @LF) Next outputs this: 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 shouldn't it go from 0 to 100 in .1 steps. ie, after 1 is 1.1 1.2 1.3 and so on until it reaches 100? Also, it has trouble with negative numbers. ie, using -5 to 5 step 1 it will print -5 -4 -3 -2 -1 0 and stop at zero?! I'm so confused. I want to count in decimal steps from -5 to 5, but I can't do either, even separately. Am I doing something wrong, or is this simply a limitation of the language?
-
Edit Control, removing line breaks?
danielmohr91 replied to danielmohr91's topic in AutoIt General Help and Support
Brilliant! Thank you enaiman SO much for your help! It's working beautifully -
Hi everyone. I have an simple edit control in one of my scripts, and I save it's contents to an .ini file. Pretty straightforward. The problem is when I press enter, it puts in a line-break (I think that's the term) which messes with the .ini file. When I go to read it back from the .ini file, everything after the first enter press is on a separate in in the .ini file, and thus, doesn't read. As a temporary crutch, I threw in $ES_MULTILINE, so I can't press enter, and it wraps automatically. Not being able to make new paragraphs is a pain, and I'm also limited to the the physical size of the edit box, it doesn't scroll with the $ES_MULTILINE flag. I'de like figure out a more permanent solution. I think I want to search for line breaks, and replace them with " & @LF & " or something similar. How would I go about searching for the line breaks. I don't even know what I'm looking for. I'm learning the very basics of html, would I be searching for the html line break code? Is there a simple, built-in way of doing this that perhaps I missed? Thanks SO much for your help! Daniel Mohr P.S. The ideal way would be to use something like $ES_WANTRETURN where It automatically wraps for me, but still leaves the option of manually creating a new line. Two problems here, one I need to search for and remove the line breaks before writing to the .ini. Second, I need to get the scroll option back in. Not sure if this is even possible, but I'de love to hear any ideas...
-
Thanks, so much. I was playing around with your example for a while. It works great - and it's a lot faster than mine, except now I can't get it to show off the GUI (which is the point, showing the grid on the screen). I tried what they said in the help file with the styles for transparency , $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), but it's still not going. Is this just not possible with only one GUI window? They've got an example in the help file that's pretty good - #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $gui, $guiPos, $pic, $picPos Example1() Example2() ;----- example 1 ---- Func Example1() Local $n, $msg GUICreate("My GUI picture", 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) $n = GUICtrlCreatePic("..\GUI\mslogo.jpg", 50, 50, 200, 50) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; resize the control $n = GUICtrlSetPos($n, 50, 50, 200, 100) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>Example1 ;----- example 2 Func Example2() Local $msg $gui = GUICreate("test transparentpic", 200, 100) $pic = GUICreate("", 68, 71, 10, 20, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui) GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0) GUISetState(@SW_SHOW, $pic) GUISetState(@SW_SHOW, $gui) HotKeySet("{ESC}", "main") HotKeySet("{LEFT}", "left") HotKeySet("{RIGHT}", "right") HotKeySet("{DOWN}", "down") HotKeySet("{UP}", "up") $picPos = WinGetPos($pic) $guiPos = WinGetPos($gui) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example2 Func main() $guiPos = WinGetPos($gui) WinMove($gui, "", $guiPos[0] + 10, $guiPos[1] + 10) EndFunc ;==>main Func left() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0] - 10, $picPos[1]) EndFunc ;==>left Func right() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0] + 10, $picPos[1]) EndFunc ;==>right Func down() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0], $picPos[1] + 10) EndFunc ;==>down Func up() $picPos = WinGetPos($pic) WinMove($pic, "", $picPos[0], $picPos[1] - 10) EndFunc ;==>up ;----- example 3 PNG work araund by Zedna #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", 250, 250) ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("..\GUI\Torus.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc the second one in where they show merlin, you can move him around with the arrow keys - right off the gui. That's exactly what I need, and I can do the same thing, but I need to create an individual GUI for each separate picture - which isn't really practical, it gets REALLY slow after a few dozen. Any way to combine this with your way of only using one GUI?
-
Ah, I see what you mean. I assumed we needed an individual GUI for each picture. I completely scrapped what I had and started from scratch - here's what I got so far: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $image = @ScriptDir & "\icon.gif" $gui = GUICreate("test transparentpic", 200, 100) $pic = GUICreate("", 68, 71, 10, 20, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui) $max = 10 $w = 0 $h = 0 local $image[$max] GUISetState(@SW_SHOW, $pic) GUISetState(@SW_SHOW, $gui) For $i = 0 To $max -1 ;~ MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$i' & @lf & @lf & 'Return:' & @lf & $i) ;### Debug MSGBOX GUICtrlCreatePic($image[$i], $i * 10 + 50, $i * 10 + 50, $w, $h) GUISetState(@SW_SHOW, $image[$i]) Next MsgBox(64, "Done", "") Not sure what I'm doing wrong this time. The blank GUI shows up, but the image's aren't showing up. I've been fooling around with the width and height variables.
-
Wow! I must say, I'm impressed. I never thought of that. It took me a while to figure out how to make it work with the transparent gif OFF the GUI, but I finally got it. Unfortunately it locks up my computer and goes REALLY slow when I open up dozens of GUI's like that. Here's how it is right now, I'm calculating the grid with the for... loop, and using the coordinates to make the GUI. I make two, a parent, and a child. That's how they did it in the help file. Scroll down to my comment to skip right to where I make the images Func _preview($x, $y, $xx, $yy, $size, $column, $row) Local Const $num_icons = 10 Local Const $w = 8 Local Const $h = 8 Local $x_pos = $xx Local $y_pos = $yy Local $direction = 1 Local $GUI_ICON[$num_icons] Local $GUI_ICON_Parent[$num_icons] For $i = 1 To $x For $j = 1 To $y $GUI_ICON_Parent[$i] = GUICreate("", 100, 50, -500, -500, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) ; HERE'S WHERE I'M MAKING IT: $GUI_ICON[$i] = GUICreate("", $w, $h, $x_pos, $y_pos, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD, $WS_EX_TOPMOST), $GUI) GUICtrlCreatePic($ICON_PREVIEW, 0, 0, 0, 0) GUISetState(@SW_SHOW, $GUI_ICON_Parent[$i]) GUISetState(@SW_SHOW, $GUI_ICON[$i]) ;$x_pos and $y_pos $x_pos += $column * $direction $y_pos -= -$row * $direction If $stop = True Then Return Next $x_pos -= $column * $direction ; Undo the very last move $y_pos += -$row * $direction ; Undo the very last move $x_pos += $column; * $size $y_pos -= $row; * $size If $direction = 1 Then Local $direction = -1 Else Local $direction = 1 EndIf If $stop = True Then Return Next EndFunc ;==>_previewIt's unusably slow. I'm thinking perhaps calling a DLL function to draw dots instead? I've never used a DLL before, but I've seen drawings done onscreen before with gdi32.dll. Something like this $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor) DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $Mpos_1, "int", $Mpos_2, "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $Mpos_1A, "int", $Mpos_2A) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])I saw it on the forums, but not realy sure how to change it into single dots. I looked for documentation on the DLL files and couldn't find out what all the parameters were for it. Do you have any suggestions where to look?
-
I'm looking for a way to display a bunch of images (actually the same one multiple times) on screen. It's a little 8x8 gif. SplashImageOn() is limited to only one at a time. Anyone know of a UDF for images that I missed, or perhaps another way around this? Something kind-of like this, only we're looking at about 25-50 of them in a grid. for $i=0 to 20 $x +=10 $y += 10 SplashImageOn() ; splash image here @ $x,$y next
-
EDIT: Problem solved, the mouse was going down while it was still over the gui
-
Ok, I've seen this error before, but I don't have a clue why I'm getting it here. I'm making a second GUI. Since this is only small part of a larger project, it needs to be within a function. I'm using a for... to... loop to make a bunch of input boxes, but if I add "global" to line 82 (the line where I make the boxes), I get the error, "Array variable subscript badly formatted." I looked it up on the forums, and it looks like that's caused by having a subscript less than zero, but I know here that $i = 0 - and it works fine without the global in front. It also seems to work if it's not inside a function. I'm really confused. Help would be greatly appreciated! I don't need you to rewrite the code or anything, I just would like to know what I'm doing wrong with the array's subscript and how to fix it. Thanks! This is the problem part: For $i = 0 To UBound($GUI_Gift_Input) - 1 ; Why does this give me so many problems when I make it global? ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Global $GUI_Gift_Input[$i] = GUICtrlCreateInput($array[0], 24, $bottom + 135 + (32 * $i), $width, 31) ;; If I take off global here it doesn't work for the other functions. @@@@ ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;; Error - Array variable subscript badly formatted. GUICtrlSetFont(-1, $__Input_Font_size, $bold, 0, $font) $temp = IniRead($file, $section, "$GUI_Gift_Input[" & $i & "]", $name & $i + 1) GUICtrlSetData($GUI_Gift_Input[$i], $temp) Next Here's the whole bottom part of my script that's giving the error. It's line 87 on here, and I commented around it - you'll see it. HotKeySet("{f3}", "_GIFT_GUI") HotKeySet("{f4}", "Gifting_Start_Pos") ; Include #include <WinAPI.au3> #include <GUIScroll.au3> ; UDF for scrolling #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Global $file = @ScriptDir & "\Settings.ini" _GIFT_GUI() ;********************************************************************************************************************************************** ;****************************************** Form Entry ***************************************************** ;********************************************************************************************************************************************** ;********************************************************************************************************************************************** Func _GIFT_GUI() MsgBox(0, "", "hey") ; GUI variables $GUI_Gift_Title = "Form Entry" $bold = 800 $width = 250 $__Group_Font_size = 11 $__Tab_Font_size = 10 $__Input_Font_size = 12 Global $id_Start_Gifting = 28 Global $id_end = 51 ; font $temp = @OSVersion If $temp = "WIN_XP" Then Local $font = "Times New Roman" Else ;$font = "Times New Roman" Local $font = "Segoe Print" EndIf ; GUI $GUI = GUICreate($GUI_Gift_Title, 300, 600, @DesktopWidth - 350, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_SYSMENU)) ;$WS_THICKFRAME; and vertical resize here WinSetOnTop($GUI_Gift_Title, "", 1) GUISetFont(10, 400, 0, $font) $GUI_Gift_Label10 = GUICtrlCreateLabel("Form Entry", 72, 8, 280, 32) GUICtrlSetFont(-1, 14, $bold, 0, $font) GUICtrlCreateGroup("Start", $__Group_Font_size, 50, 280, 150) GUICtrlSetFont(-1, $__Group_Font_size, $bold, 0, $font) Global $GUI_Gift_Slider1 = GUICtrlCreateSlider(24, 80, $width, 33) Global $GUI_Gift_Button1 = GUICtrlCreateButton("Start", 24, 140, $width - 10, 50, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlCreateLabel("Fast", 40, 112, 27, 23) GUICtrlSetFont(-1, 8, 400, 0, $font) GUICtrlCreateLabel("Slow", 224, 112, 30, 23) GUICtrlSetFont(-1, 8, 400, 0, $font) $bottom = 240 ;; Bottom of ^ start group GUICtrlCreateGroup("Friends", $__Group_Font_size, $bottom - 25, 280, 815) GUICtrlSetFont(-1, $__Group_Font_size, $bold, 0, $font) GUICtrlCreateLabel("Fill in these boxes with the names", 24, $bottom, $width, 27) GUICtrlCreateLabel("of the friends you want to gift to.", 24, $bottom + 25, $width, 27) GUICtrlCreateLabel("First name and last name initial", 24, $bottom + 50, $width, 27) GUICtrlCreateLabel("should do, just enough to tell", 24, $bottom + 75, $width, 27) GUICtrlCreateLabel("them apart.", 24, $bottom + 100, $width, 27) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetFont(10, 400, 0, "Segoe Print") Dim $GUI_Gift_Input[20] Dim $array[UBound($GUI_Gift_Input)] Global $name = "Name " For $i = 0 To UBound($GUI_Gift_Input) - 1 ; Why does this give me so many problems when i make it global? ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Global $GUI_Gift_Input[$i] = GUICtrlCreateInput($array[0], 24, $bottom + 135 + (32 * $i), $width, 31) ;; If I take off global here it doesn't work for the other functions. @@@@ ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;; Error - Array variable subscript badly formatted. GUICtrlSetFont(-1, $__Input_Font_size, $bold, 0, $font) $temp = IniRead($file, $section, "$GUI_Gift_Input[" & $i & "]", $name & $i + 1) GUICtrlSetData($GUI_Gift_Input[$i], $temp) Next ; Activate memory bank and fill in the input boxes Memory_Bank_1() ; Scrolling feature Scrollbar_Create($GUI, $SB_VERT, $bottom + 800); Last number is the length to scroll for (in pixels) Scrollbar_Step(20, $GUI, $SB_VERT); Scrolls per 20 pixels. If not set the default is 1 (smooth scrolling) GUICtrlSetLimit($GUI_Gift_Slider1, 50, 0) $speed = IniRead($file, "Speed", "$speed", 10) GUICtrlSetData($GUI_Gift_Slider1, $speed) GUISetState(@SW_SHOW) MsgBox(0, "", @ScriptLineNumber) Global $EditFocus = 0 ; no edit has focus Global $LastEdFocus = 0 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") ; or some function name GUISetState() While 1 $iScrollPos = Scrollbar_GetPos($GUI, $SB_VERT) ConsoleWrite($iScrollPos & @CRLF) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_Gift_Input[0] To $GUI_Gift_Input[UBound($GUI_Gift_Input) - 1] ;one way of dealing With it, because we know that the control has the ID $nMsg $temp = GUICtrlRead($GUI_Gift_Input[$nMsg - $id_Start_Gifting]) $key = "$GUI_Gift_Input[" & $nMsg - $id_Start_Gifting & "]" IniWrite($file, $section, $key, $temp) Case $GUI_Gift_Button1 Start_Gifting() Case $GUI_Gift_Slider1 $temp = GUICtrlRead($GUI_Gift_Slider1) IniWrite($file, "Speed", "$speed", $temp) EndSwitch WEnd EndFunc ;==>_GIFT_GUI Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $old_ID = "anything" Local $new_ID = "anything unequal to $old_ID" Local $iIDFrom, $iCode $iIDFrom = _WinAPI_LoWord($iwParam) ;The wParam has 8 bytes. Depending on the message or notification windows will use those bytes in different ways. For $EN_SETFOCUS it uses it for 2 ;completely different things. The high order bytes are used for the id number of the control, and the low order bytes are used for the notification ;reference number. So if wParam is 0x00090100 it means that the control with ID 9 wants to tell you that it has just received focus because ;$EV_SETFOCUS is 0x0100. $iCode = _WinAPI_HiWord($iwParam) ;the high word of the $iwParam is the notification code, ie the reason for the message - The text has changed, focus gained/lost etc Switch $iCode Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus $EditFocus = 0 Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus $EditFocus = $iIDFrom EndSwitch ;~ If control get's focus we get the ID, if it loses focus, zero If $EditFocus <> $LastEdFocus And Not WinExists("Address") Then ;~ $msg1 = GUICtrlRead($Edit1) $msg2 = "$iCode = " & $iCode & @CRLF $msg4 = "$iwParam = " & $iwParam & @CRLF $msg3 = "$EditFocus = " & $EditFocus & @CRLF ;TrayTip("Focus", $EditFocus, 2, 1) Switch $EditFocus Case $id_Start_Gifting To $id_end TrayTip("", $EditFocus, 10) $temp = $EditFocus - $id_Start_Gifting $temp2 = GUICtrlRead($GUI_Gift_Input[$temp]) ;TrayTip("", $temp2, 10) ;~ If StringLeft($temp2, 4) = $name Then If StringLeft($temp2, 4) = "Name" Then GUICtrlSetData($GUI_Gift_Input[$temp], "") EndIf Case 0 ;TrayTip("Focus lost", $EditFocus, 2, 1) $temp = $LastEdFocus - $id_Start_Gifting If $temp >= 0 And IsNumber($temp) Then $temp2 = GUICtrlRead($GUI_Gift_Input[$temp]) If $temp <= UBound($GUI_Gift_Input) And $temp2 = "" Then ; ubound = 20 in this case GUICtrlSetData($GUI_Gift_Input[$temp], "Name " & $temp + 1) $data = GUICtrlRead($GUI_Gift_Input[$temp]) $key = "$GUI_Gift_Input[" & $temp & "]" IniWrite($file, $section, $key, $data) EndIf EndIf EndSwitch EndIf $LastEdFocus = $EditFocus Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Func Start_Gifting() $speed = GUICtrlRead($GUI_Gift_Slider1) $msg = "Place your cursor over the top checkbox, then press F4 to begin" $temp = SplashTextOn("", $msg, "725", "55", "-1", "-100", 1, "Segoe Print", "16", "400") $temp = 100 WinSetTrans("", $msg, $temp) WinMove("", $msg, @DesktopWidth / 2 - 350, 35, 725, 55, 5) For $i = $temp To 230 Step 5 WinSetTrans("", $msg, $i) Sleep(50) Next Do Sleep(10) $temp = @HotKeyPressed Until $temp = "{f4}" EndFunc ;==>Start_Gifting Func Gifting_Start_Pos() $pos = MouseGetPos() $delay = 150 SplashOff() Send("^{f10}") ; to reset the @HotKeyPressed macro... For $i = 0 To UBound($GUI_Gift_Input) - 1 ; GUI_Gift_Input[24] $key = "$GUI_Gift_Input[" & $i & "]" $name = IniRead($file, $section, $key, "none") $data = StringLeft($name, 4) If $name <> "none" And $data <> "Name" Then MouseClick("primary", $pos[0], $pos[1] - 20, 1, $speed) Sleep($delay / 2 + 25 * $speed) Send("^{a}") Sleep($delay + 25 * $speed) TrayTip($i, $name, 5) Send($name) Sleep($delay + 25 * $speed) MouseClick("primary", $pos[0], $pos[1], 1, $speed) Sleep($delay + 25 * $speed) EndIf Next EndFunc ;==>Gifting_Start_Pos Func _reset() ; this function is called when I need to reset the @hotkeypressed macro EndFunc ;==>_reset Func Memory_Bank_1() $i = 1 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_1 Func Memory_Bank_2() $i = 2 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_2 Func Memory_Bank_3() $i = 3 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_3 Func Memory_Bank_4() $i = 4 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_4 Func Memory_Bank_5() $i = 5 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_5 Func Memory_Bank_6() $i = 6 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_6 Func Memory_Bank_7() $i = 7 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_7 Func Memory_Bank_8() $i = 8 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_8 Func Memory_Bank_9() $i = 9 Memory_Bank_Switch($i) EndFunc ;==>Memory_Bank_9 Func Memory_Bank_Switch($i) ; This runs on startup with a variable of 1 Global $section = "Friends" & $i For $i = 0 To UBound($GUI_Gift_Input) - 1 $temp = IniRead($file, $section, "$GUI_Gift_Input[" & $i & "]", $name & $i + 1) GUICtrlSetData($GUI_Gift_Input[$i], $temp) NextEndFunc ;==>Memory_Bank_Switch
-
Adding a menu item to the taskbar icon?
danielmohr91 replied to ColtsFan's topic in AutoIt General Help and Support
Great question. I've often wondered the same thing myself. Thanubus, you made a great suggestion with the _GUICtrlMenu_GetSystemMenu() functions. ColtsFan, Here's a quick example I made on how to add a menu items. This is my first time, this just shows how to get them there. Perhaps someone else here more experienced than myself can enlighten us as how to make it actually do something. I'm thinking something along the lines of GUIRegisterMsg to get started. ; gui create menu #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> ; This is needed for the GUI Menu... $title = "Menu Test" $Form1 = GUICreate($title, 600, 275, 300, 125) $Button1 = GUICtrlCreateButton("Button1", 10, 15, 580, 60, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 10, 80, 580, 180) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _menu() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _menu() Local $hWnd, $hMenu $hWnd = WinGetHandle($title) $hMenu = _GUICtrlMenu_GetSystemMenu($hWnd) For $i = 5 to 10 _GUICtrlMenu_InsertMenuItem($hMenu, $i, "Menu Item " &$i) Next ; Display system menu $iCount = _GUICtrlMenu_GetItemCount($hMenu) EndFunc ;==>_Main -
Awesome! Thank you everyone! And I love the idea of using StringIsInt and StringIsFloat, so now it works with decimals too. Do $temp = InputBox("Start delay", "Enter a new value (in seconds) for starting delay.", $temp) If @error Then $temp = 5 ; If cancel is hit or box is closed, it defualts to 5 seconds Else If StringIsInt($temp) Or StringIsFloat($temp) Then $temp = Int($temp) TrayTip("Starting Delay", "Delay of " & $temp & " seconds before playback begins.", 10) Else $temp = "Enter a number" EndIf EndIf Until $temp > 0 Here's my final code. Much better.
-
Perfect! I replaced IsNumber with StringIsDigit, and it's working. I didn't realize there was a difference between the number returned by an input box, and normal. How would I read up more on this? What's the term for this?
-
"IsNumber: Success: Returns 1. Failure: returns 0 if expression is not numeric. "So IsNumber returns one if it is a number, if not, zero. I used the IsNumber command with an actual number, and it worked as expected. But when I use it with a variable it doesn't work. I added a msgbox to manually make sure $temp was actually a number. What am I doing wrong? Func Start_Delay() $temp = $Start_Delay Do $temp = InputBox("Start delay", "Enter a new value (in seconds) for starting delay.", $temp) MsgBox(0, "", $temp) $ans = IsNumber($temp) ; returns 1 if number, 0 if not MsgBox(0, "", $ans) If $ans = 0 Then $temp = "Enter a number" Else TrayTip("Starting Delay", "Delay of " & $temp & " seconds before playback begins.", 10) EndIf Until $temp > 0 Global $Start_Delay = $temp EndFunc ;==>Start_Delay