Great news, guys! Along with the Storage Card-friendly new Jbed 3.1 (as soon as it's fixed by its dev), I post an update of you both.
badbob001, I think this time you did the motivating. You finally figured out how to get rid of the hard coded pauses, very cool! I tried messing with this concept a while ago but gave up after 20 minutes of no success, go figure. Hope you don't mind I snagged your concept alsoI decided to validate 2 pixels, to really make sure. I got it fully working in my script on all 3 browsers OM2, OM4 & OM4.1 but only in JBed, I should probably drop TAO Intent support, the blue softkeys at the bottom make it a pain to get color. I wonder what the market share is comparing TAO & JBed. Do most Windows Mobiles now use JBed or is TAO still in the game? Anybody?
I wonder what the market share is comparing TAO & JBed. Do most Windows Mobiles now use JBed or is TAO still in the game? Anybody?.
Curious, where is the second pixel that you are checking? I initially wanted to check a row of pixels... specifically part of the scrollbar, which is always present, even in full screen. But I couldn't get mortscript to read the color of the pixels I wanted. I also couldn't get the color from the bottom opera bar. It's almost as if parts of the interface is off-limits to the mortscript function. Also be aware that if the opera font size is changed, the top bar changes size as well.
I think you can safely drop TAO support. A lot of TAO users have continuously moving to Jbed, particularly after reading my articles telling them to do so.
Thanks for the suggestions, gotta watch the size, so I'll mess with that. Here's what I use for the two pixels. BTW you use RGB value, I use string, how did you convert to RGB?
color = colorat(x,y)
rgb = red(color) &",",& green(color) &",",& blue(color)
Mortscript's colorat uses a color system I don't know how to visualize, but mortscript can convert it back to rgb.
Code:color = colorat(x,y) rgb = red(color) &",",& green(color) &",",& blue(color)
Yep, tried that, but I messed with logic at the same time so I thought this way is no good, will re-do my code. Thanks!
wait_time_for_opera = 10 #seconds allowed for opera to start
wait_time_between_keys = 100 #milliseconds between key commands
check_for_text_window = True #check if address text window appears
operaRed = rgb(107, 12, 8)
checkPixelx = 0
checkPixely = 0
ini_file = SystemPath("ScriptPath") &"\"& SystemPath("ScriptName") &".ini"
if (substr(url,1,1) eq " ")
url = substr(url,2)
EndIf
If (url ne "")
If (Find("file://", ToLower(url)))
Run("\Windows\iexplore.exe", url)
exit
EndIf
EndIf
main_loop_done = False
while(main_loop_done eq False)
ini_ok = False
call validate_ini
if ( (ini_ok eq True) AND (main_loop_done = False) )
call startOM
EndIf
if ( (ini_ok eq False) AND (main_loop_done = False) )
kill("jbed.exe")
call create_ini
EndIf
EndWhile
Sub validate_ini
if FileExists ( ini_file )
split(ReadFile(ini_file),"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini, direct_address_input)
if ( (opera_version_ini eq "") OR (jbed_exe_ini eq "") OR (jbed_params_ini eq "") OR (direct_address_input eq "") )
error_msg = ini_file &" is invalid.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings?"
if (question(error_msg, "ERROR", "YesNo") eq No)
exit
#main_loop_done = True
EndIf
else
ini_ok = True
EndIf
EndIf
EndSub
Sub create_ini
ShowWaitCursor
opera40_string = "Opera Mini,"
opera41_string = "Opera Mini 4.1,"
jbed_exe_ini = Part(RegRead("HKCR","jarfile\Shell\Open\Command",""),"""",2,1)
utf_file = ReadFile(RegRead("HKCR","jarfile\Shell\Save\Save Location","") & "\selector.utf")
linenum = 0
opera_count = 0
ForEach line in split (utf_file, "^LF^", 1)
linenum = linenum + 1
opera_version_found = "unknown"
prog_id = ""
If (Find(line,"suite=" & opera40_string) ne 0)
opera_version_found = "4.0"
ElseIf (Find(line,"suite=" & opera41_string) ne 0)
opera_version_found = "4.1"
EndIf
prog_line = Part( utf_file,"^LF^",linenum+3,1)
prog_line_position = find(prog_line,"root=")
if (prog_line_position ne 0)
prog_id = substr(prog_line, prog_line_position+5, 3)
if (prog_id ne "")
jbed_params_ini = "-run " & prog_id
opera_count = opera_count + 1
opera_array[opera_count] = opera_version_found &"|"& jbed_exe_ini &"|"& jbed_params_ini
EndIf
EndIf
EndForEach
HideWaitCursor
opera_array_choice = 1
If (opera_count = 0)
message ("Opera Mini does not appear to be installed.", "ERROR")
exit
#main_loop_done = True
ElseIf (opera_count = 1)
opera_array_choice = opera_count
ini_ok = True
Else
idx = choice("Question", "Which Opera Mini version do you want to run by default?", 0, 0, opera_array)
if (idx = 0)
exit
#main_loop_done = True
Else
opera_array_choice = idx
ini_ok = True
EndIf
EndIf
direct_address_input = False
If (ini_ok eq True)
split(opera_array[opera_array_choice],"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini)
if (opera_version_ini eq "4.1")
if (question("In Opera Mini 4.1, do you have Direct Address Input enabled?^NL^(It's enabled by default.)", "", "YesNo") eq Yes)
direct_address_input = True
EndIf
EndIf
WriteFile (ini_file, opera_version_ini&"|"&jbed_exe_ini&"|"&jbed_params_ini&"|"&direct_address_input)
EndIf
Endsub
Sub StartOM
Run(jbed_exe_ini, jbed_params_ini)
Call waitForOperaRed
if ( (url ne "") AND (ini_ok eq True) )
sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
if (opera_version_ini = "4.1" AND direct_address_input eq True)
sendup
Sleep(wait_time_between_keys)
sendup
Sleep(wait_time_between_keys)
sendcr
Sleep(wait_time_between_keys)
Endif
checkColor = colorat(checkPixelx,checkPixely)
if ( (checkColor = operaRed) AND (check_for_text_window eq True) )
error_msg = "Did not find the address input window.^NL^^NL^Re-detect Opera Mini settings?"
if (question(error_msg, "ERROR", "YesNo") eq No)
exit
#main_loop_done = True
else
main_loop_done = False
ini_ok = False
EndIf
else
SetClipText(url)
SendHome ("",1,0)
sleep(wait_time_between_keys)
SendEnd ("",1,1)
sleep(wait_time_between_keys)
SendCtrlKey("V")
Sleep(wait_time_between_keys)
SendLeftSoft
sleep(wait_time_between_keys)
if (opera_version_ini = "4.1" AND direct_address_input eq True)
sendcr
endif
endif
endif
EndSub
sub waitForOperaRed
loop_count = 0
loop_done = False
ShowWaitCursor
while (loop_done = False)
checkColor = colorat(checkPixelx,checkPixely)
if (checkColor = operaRed)
loop_done = True
main_loop_done = True
HideWaitCursor
ElseIf (loop_count >= wait_time_for_opera * 2)
HideWaitCursor
error_msg = "Did not find Opera Mini running after " & wait_time_for_opera &" seconds. (I can't find Opera Mini if it's running in full-screen mode.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings?"
if (question(error_msg, "ERROR", "YesNo") eq No)
exit
#main_loop_done = True
Else
ini_ok = False
EndIf
loop_done = True
Else
sleep(500)
loop_count = loop_count + 1
EndIf
endwhile
endsub
There really isn't much happening in the first line that would be version specific.error: "operator expected"
line: 1
I simply replaced your script over Werner's orginal "OMInvokeAndPasteScript.mscr" which lives in the \program files\mortscript.
Don't recall the version of mortscript, but within the last 6 months...
Thoughts?
wait_time_for_opera = 10 #seconds allowed for opera to start
wait_time_for_opera = 10
#default = 10 seconds
wait_time_between_keys = 100
#default = 100 milliseconds
check_for_text_window = True
operaRed = rgb(107, 12, 8)
checkPixelx = 0
checkPixely = 0
ini_file = SystemPath("ScriptPath") &"\"& SystemPath("ScriptName") &".ini"
if (substr(url,1,1) eq " ")
url = substr(url,2)
EndIf
If (url ne "")
If (Find("file://", ToLower(url)))
Run("\Windows\iexplore.exe", url)
exit
EndIf
EndIf
main_loop_done = False
while(main_loop_done eq False)
ini_ok = False
call validate_ini
if ( (ini_ok eq True) AND (main_loop_done = False) )
call startOM
EndIf
if ( (ini_ok eq False) AND (main_loop_done = False) )
kill("jbed.exe")
call create_ini
EndIf
EndWhile
Sub validate_ini
if FileExists ( ini_file )
split(ReadFile(ini_file),"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini, direct_address_input)
if ( (opera_version_ini eq "") OR (jbed_exe_ini eq "") OR (jbed_params_ini eq "") OR (direct_address_input eq "") )
error_msg = ini_file &" is invalid.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
EndIf
else
ini_ok = True
EndIf
EndIf
EndSub
Sub create_ini
ShowWaitCursor
opera40_string = "Opera Mini,"
opera41_string = "Opera Mini 4.1,"
jbed_exe_ini = Part(RegRead("HKCR","jarfile\Shell\Open\Command",""),"""",2,1)
utf_file = ReadFile(RegRead("HKCR","jarfile\Shell\Save\Save Location","") & "\selector.utf")
linenum = 0
opera_count = 0
ForEach line in split (utf_file, "^LF^", 1)
linenum = linenum + 1
opera_version_found = "unknown"
prog_id = ""
If (Find(line,"suite=" & opera40_string) ne 0)
opera_version_found = "4.0"
ElseIf (Find(line,"suite=" & opera41_string) ne 0)
opera_version_found = "4.1"
EndIf
prog_line = Part( utf_file,"^LF^",linenum+3,1)
prog_line_position = find(prog_line,"root=")
if (prog_line_position ne 0)
prog_id = substr(prog_line, prog_line_position+5, 3)
if (prog_id ne "")
jbed_params_ini = "-run " & prog_id
opera_count = opera_count + 1
opera_array[opera_count] = opera_version_found &"|"& jbed_exe_ini &"|"& jbed_params_ini
EndIf
EndIf
EndForEach
HideWaitCursor
opera_array_choice = 1
If (opera_count = 0)
message ("Opera Mini does not appear to be installed.", MortScriptVersion())
exit
ElseIf (opera_count = 1)
opera_array_choice = opera_count
ini_ok = True
Else
idx = choice(MortScriptVersion(), "Which Opera Mini version do you want to run by default?", 0, 0, opera_array)
if (idx = 0)
exit
Else
opera_array_choice = idx
ini_ok = True
EndIf
EndIf
direct_address_input = False
If (ini_ok eq True)
split(opera_array[opera_array_choice],"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini)
if (opera_version_ini eq "4.1")
if (question("In Opera Mini 4.1, do you have Direct Address Input enabled?^NL^(It's enabled by default.)", MortScriptVersion(), "YesNo") eq Yes)
direct_address_input = True
EndIf
EndIf
WriteFile (ini_file, opera_version_ini&"|"&jbed_exe_ini&"|"&jbed_params_ini&"|"&direct_address_input)
EndIf
Endsub
Sub StartOM
Run(jbed_exe_ini, jbed_params_ini)
Call waitForOperaRed
if ( (url ne "") AND (ini_ok eq True) )
sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
if (opera_version_ini = "4.1" AND direct_address_input eq True)
sendup
Sleep(wait_time_between_keys)
sendup
Sleep(wait_time_between_keys)
sendcr
Sleep(wait_time_between_keys)
Endif
checkColor = colorat(checkPixelx,checkPixely)
if ( (checkColor = operaRed) AND (check_for_text_window eq True) )
error_msg = "Did not find the address input window.^NL^^NL^Re-detect Opera Mini settings?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
else
main_loop_done = False
ini_ok = False
EndIf
else
SetClipText(url)
SendHome ("",1,0)
sleep(wait_time_between_keys)
SendEnd ("",1,1)
sleep(wait_time_between_keys)
SendCtrlKey("V")
Sleep(wait_time_between_keys)
SendLeftSoft
sleep(wait_time_between_keys)
if (opera_version_ini = "4.1" AND direct_address_input eq True)
sendcr
endif
endif
endif
EndSub
sub waitForOperaRed
loop_count = 0
loop_done = False
ShowWaitCursor
while (loop_done = False)
checkColor = colorat(checkPixelx,checkPixely)
if (checkColor = operaRed)
loop_done = True
main_loop_done = True
HideWaitCursor
ElseIf (loop_count >= wait_time_for_opera * 2)
HideWaitCursor
error_msg = "Did not find Opera Mini running after " & wait_time_for_opera &" seconds. (I can't find Opera Mini if it's running in full-screen mode.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
Else
ini_ok = False
EndIf
loop_done = True
Else
sleep(500)
loop_count = loop_count + 1
EndIf
endwhile
endsub
Nice concept in parsing browser versions and the sort, but for me I prefer to be able to choose whether IE or Opera and use full-screen (small Treo 750 screen so need all the real estate I can get).
Keep up the good work! I'll keep my eye on this as it continues to develop...
wait_time_for_opera = 10
#default = 10 seconds
wait_time_for_address = 2
#default = 2 seconds
wait_time_between_keys = 100
#default = 100 milliseconds
operaRed = rgb(107, 12, 8)
operaBlue = rgb(247, 243, 247)
checkPixelx = 0
checkPixely = 0
ini_file = SystemPath("ScriptPath") &"\"& SystemPath("ScriptName") &".ini"
if (substr(url,1,1) eq " ")
url = substr(url,2)
EndIf
If (url ne "")
If (Find("file://", ToLower(url)))
Run("\Windows\iexplore.exe", url)
exit
EndIf
EndIf
main_loop_done = False
while(main_loop_done eq False)
ini_ok = False
call validate_ini
if ( (ini_ok eq True) AND (main_loop_done eq False) )
#if (url ne "")
kill("jbed.exe")
#EndIf
call startOM
EndIf
if ( (ini_ok eq False) AND (main_loop_done eq False) )
kill("jbed.exe")
call create_ini
EndIf
EndWhile
Sub validate_ini
if FileExists ( ini_file )
split(ReadFile(ini_file),"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini, direct_address_input)
if ( (opera_version_ini eq "") OR (jbed_exe_ini eq "") OR (jbed_params_ini eq "") OR (direct_address_input eq "") )
error_msg = ini_file &" is invalid.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
else
ini_ok = False
EndIf
else
ini_ok = True
EndIf
EndIf
EndSub
Sub create_ini
ShowWaitCursor
opera40_string = "Opera Mini,"
opera41_string = "Opera Mini 4.1,"
jbed_exe_ini = Part(RegRead("HKCR","jarfile\Shell\Open\Command",""),"""",2,1)
utf_file = ReadFile(RegRead("HKCR","jarfile\Shell\Save\Save Location","") & "\selector.utf")
if (Find(jbed_exe_ini,"jbed") = 0)
message ("This script only works with Jbed.", MortScriptVersion())
exit
EndIf
linenum = 0
opera_count = 0
ForEach line in split (utf_file, "^LF^", 1)
linenum = linenum + 1
opera_version_found = "unknown"
prog_id = ""
If (Find(line,"suite=" & opera40_string) ne 0)
opera_version_found = "4.0"
ElseIf (Find(line,"suite=" & opera41_string) ne 0)
opera_version_found = "4.1"
EndIf
prog_line = Part( utf_file,"^LF^",linenum+3,1)
prog_line_position = find(prog_line,"root=")
if (prog_line_position ne 0)
prog_id = substr(prog_line, prog_line_position+5, 3)
if (prog_id ne "")
jbed_params_ini = "-run " & prog_id
opera_count = opera_count + 1
opera_array[opera_count] = opera_version_found &"|"& jbed_exe_ini &"|"& jbed_params_ini
EndIf
EndIf
EndForEach
HideWaitCursor
opera_array_choice = 1
If (opera_count = 0)
message ("Opera Mini does not appear to be installed.", MortScriptVersion())
exit
ElseIf (opera_count = 1)
opera_array_choice = opera_count
ini_ok = True
Else
idx = choice(MortScriptVersion(), "Which Opera Mini version do you want to run by default?", 0, 0, opera_array)
if (idx = 0)
exit
Else
opera_array_choice = idx
ini_ok = True
EndIf
EndIf
direct_address_input = False
If (ini_ok eq True)
split(opera_array[opera_array_choice],"|", True, opera_version_ini, jbed_exe_ini, jbed_params_ini)
if (opera_version_ini eq "4.1")
if (question("In Opera Mini 4.1, do you have Direct Address Input enabled?^NL^(It's enabled by default.)", MortScriptVersion(), "YesNo") eq Yes)
direct_address_input = True
Else
direct_address_input = False
EndIf
EndIf
WriteFile (ini_file, opera_version_ini&"|"&jbed_exe_ini&"|"&jbed_params_ini&"|"&direct_address_input)
EndIf
Endsub
Sub StartOM
Run(jbed_exe_ini, jbed_params_ini)
Call waitForColor
if ( (url ne "") AND (ini_ok eq True) )
sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
SendLeftSoft
Sleep(wait_time_between_keys)
if (opera_version_ini eq "4.1" AND direct_address_input eq True)
sendup
Sleep(wait_time_between_keys)
sendup
Sleep(wait_time_between_keys)
sendcr
Sleep(wait_time_between_keys)
Endif
Call waitForNotColor
If (ini_ok eq True)
SetClipText(url)
SendHome ("",1,0)
sleep(wait_time_between_keys)
SendEnd ("",1,1)
sleep(wait_time_between_keys)
SendCtrlKey("V")
Sleep(wait_time_between_keys)
SendLeftSoft
sleep(wait_time_between_keys)
if (opera_version_ini eq "4.1" AND direct_address_input eq True)
sendcr
endif
endif
endif
EndSub
sub waitForColor
loop_count = 0
loop_done = False
ShowWaitCursor
while (loop_done = False)
checkColor = colorat(checkPixelx,checkPixely)
if ( (checkColor eq operaRed) OR (checkColor eq operaBlue) )
loop_done = True
main_loop_done = True
HideWaitCursor
ElseIf (loop_count >= wait_time_for_opera * 2)
HideWaitCursor
error_msg = "Did not find Opera Mini running after " & wait_time_for_opera &" seconds.^NL^^NL^"
error_msg = error_msg & "Re-detect Opera Mini settings and Retry?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
Else
ini_ok = False
loop_done = True
EndIf
Else
sleep(500)
loop_count = loop_count + 1
EndIf
endwhile
endsub
sub waitForNotColor
loop_count = 0
loop_done = False
ShowWaitCursor
while (loop_done = False)
checkColor = colorat(checkPixelx,checkPixely)
if ( (checkColor ne operaRed) AND (checkColor ne operaBlue) )
loop_done = True
main_loop_done = True
HideWaitCursor
ElseIf (loop_count >= wait_time_for_address * 2)
HideWaitCursor
error_msg = "Did not find the address input window after "& wait_time_for_address &" seconds.^NL^^NL^Re-detect Opera Mini settings and Retry?"
if (question(error_msg, MortScriptVersion(), "YesNo") eq No)
exit
Else
main_loop_done = False
ini_ok = False
loop_done = True
EndIf
Else
sleep(500)
loop_count = loop_count + 1
EndIf
endwhile
endsub
Menneisyys,
Found this over on ppcgeeks, coded in C++. works the same as yours but does not need mortscript. might be worth adding to your first post as an alternative? to quote the developer (and with thanks to same)
"Attached is a beta app that will set opera mini as the default web browser and open links when clicked from email, etc. The app has been tested to work in wm6. It assumes that java is at /windows/jbed.exe and the Opera mini app is the first applet installed. This app is similar to the mortscript version, but, is coded in c+ and does not rely on delays."
Found this over on ppcgeeks, coded in C++. works the same as yours but does not need mortscript. might be worth adding to your first post as an alternative? to quote the developer (and with thanks to same)
"Attached is a beta app that will set opera mini as the default web browser and open links when clicked from email, etc. The app has been tested to work in wm6. It assumes that java is at /windows/jbed.exe and the Opera mini app is the first applet installed. This app is similar to the mortscript version, but, is coded in c+ and does not rely on delays."
ReadFile(RegRead("HKCR","jarfile\Shell\Save\Save Location","") & "\selector.utf")
Couldn't help it. This version will work in fullscreen mode as well. To get a consistent starting state, I resorted to killing and restarting jbed.exe everytime if an url is specified. Otherwise, you're just running the script to launch opera mini and not expecting an url to be pasted in. So in non-fullscreen mode, the corner pixel is the red of the titlebar. In fullscreen mode, the corner pixel is the blueish selection box around the address input box. I hope this works on other devices.
Killing jbed does also solve the issue of Opera Mini being left in a state where the default key sequence to access the address bar doesn't work, such as when it already is in address input mode or on some other screen.
This version will also do a little wait for the address input window to appear before complaining.