SirBob Posted June 17, 2005 Share Posted June 17, 2005 (edited) short story: ; line 2 in $file reads "F5", no quotes $var = FileReadLine($file,2) Send("{$var}") does not work. Now i know since it's a function key (F1-F10) i could check it with a series of if-else's (if i dont stumble across a switch statement - that accepts strings, or i change var to int without the F), but i'd rather do this proper (and keep the code vaguely readable). Anyway, i was just wondering if this was possible. Also, i can hear windows' "what-the-hell-am-i-supposed-to-do-with-that-keypress" error sound, so it's pressing _some_ key... ________ Long story: settings.ini (i added line numbers here they're not in file): line1: // comment explaining line2: F5 line3: // another comment explaining line4: F9 line5: //EOF just in case line6: script.au3: ; ... bit of code focusing on right window, settings mouse/pixel to local window etc... $file = FileOpen("settings.ini", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open settings.ini") Exit EndIf $KeyOne = FileReadLine($file,2) $KeyTwo = FileReadLine($file,4) FileClose($file) ; bit of code HotKeySet("{F11}", "PauseMacro") ; just including HotKeySet("{PAUSE}", "Terminate") ; cause this works ; more code including main loop CheckIt() ; end mainloop Func CheckIt() $PixelX = 36 $PixelY = $WinH - 36; $WinH = window height $color = PixelGetColor($PixelX,$PixelY) $blue = mod($color, 256) IF $blue > 80 then Send("{$KeyOne}"); as said above, Send("{F5}") works fine Sleep(400) ENDIF EndFunc thanks Edited June 17, 2005 by SirBob Link to comment Share on other sites More sharing options...
FuryCell Posted June 17, 2005 Share Posted June 17, 2005 (edited) Try; line 2 in $file reads "F5", no quotes $var = FileReadLine($file,2) Send("{" & $var & "}")Edit: or you could use this function and do this.; line 2 in $file reads "F5", no quotes $var = FileReadLine($file,2) Send(_ExpandVarStrings("{$VAR$}")) Func _ExpandVarStrings($sInput) Dim $aPart = StringSplit($sInput,'$') If @error Then SetError(1) Return $sInput EndIf Dim $sOut = $aPart[1], $i = 2, $Var = '' ;loop through the parts While $i <= $aPart[0] $Var = Eval ($aPart[$i]) If $Var <> '' Then;this part is an expandable Variable $sOut = $sOut & $Var $i = $i + 1 If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i] ElseIf $aPart[$i] = '' Then;a double-$ is used to force a single $ $sOut = $sOut & '$' $i = $i + 1 If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i] Else;this part is to be returned literally $sOut = $sOut & '$' & $aPart[$i] EndIf $i = $i + 1 WEnd Return $sOut EndFunc Edited June 17, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
SirBob Posted June 17, 2005 Author Share Posted June 17, 2005 hmm that second one sure looks impressive. but since i'm the only one seeing code, the first one's much clearer and suits my needs perfectly, i'll go with that. i'm such an idiot, never even occurred to me that it was actually sending along a string to a "Send" function to be parsed (... i dunno i guess i thought it was magic or something). So string concatenating is just what i need, tyvm. 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